title: agent on domino server cannot see network drives
body: <p>I know that the particular issue appears when you run Domino as a service that runs as local account or different user. However here I'm running it with user rights as a normal application. Then I start the agent from server console: <code>tell amgr run etc</code>.</p>
  
  <p>I'm trying to enumerate available drives in two ways - as Filesystem roots using Java functionality and using Windows specific wmic. The relevant code is:</p>
  
  <pre><code>        System.out.println("os:"+System.getProperty("os.name") + " user:" + System.getProperty("user.name"));
          File[] roots = File.listRoots();
          for (File root : roots) {
              if (root.canWrite()) { 
                  System.out.println("[rw] " + root.getPath());
              } else {
                  System.out.println("[ro] " + root.getPath());
              }
          }
          Process process = Runtime.getRuntime().exec(
                  new String[] { "wmic", "logicaldisk", "get",
                          "deviceid,volumename,volumeserialnumber" });
          process.getOutputStream().close();
          BufferedReader reader = new BufferedReader(
                  new InputStreamReader(process.getInputStream()));
          String line = null;
          while ((line = reader.readLine()) != null) {
              System.out.println(line);
          }
          reader.close();
  </code></pre>
  
  <p>Running if from client (or simply from a standalone Java application) I get all drives:</p>
  
  <pre><code>os:Windows 7 user:normunds
  [rw] C:\
  [ro] D:\
  [rw] N:\
  [rw] W:\
  DeviceID  VolumeName  VolumeSerialNumber  
  C:        Acer        12857911            
  D:                                        
  N:        video       EE1C7944            
  W:        DB_70       18389143       
  </code></pre>
  
  <p>Where N: 'video' is a mapped share on network drive.</p>
  
  <p>However when I'm running it on the server (same PC) I get only the local ones, not the remote smb drive:</p>
  
  <pre><code>19.11.2013 23:00:42   Agent Manager: Agent printing: os:Windows 7 user:normunds
  19.11.2013 23:00:42   Agent Manager: Agent printing: [rw] C:\
  19.11.2013 23:00:42   Agent Manager: Agent printing: [ro] D:\
  19.11.2013 23:00:42   Agent Manager: Agent printing: [rw] W:\
  19.11.2013 23:00:42   Agent Manager: Agent printing: DeviceID  VolumeName  VolumeSerialNumber  
  19.11.2013 23:00:42   Agent Manager: Agent printing: C:        Acer        12857911            
  19.11.2013 23:00:42   Agent Manager: Agent printing: D:                                        
  19.11.2013 23:00:42   Agent Manager: Agent printing: W:        DB_70       18389143      
  </code></pre>
  
  <p>Notice the user name, the code is running under my name; at least that's what Java thinks. I cannot figure out what causes the problem.</p>
  
  <p>I even tried to write another version of this by calling Windows API method from LotusScript code:
  <code>Declare Private Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (Byval nBufferLength As Long, Byval lpBuffer As String) As Long</code>
  with the same result - from client it works and returns all drives, on the server it misses. I guess one more step would be to ask Windows API the user name. <em>Update:</em> just did it, it also returns "normunds". </p>
  
  <p>Any ideas of how to approach this issue?</p>
  
  <p>Edited: What I think is happening is that Domino runs servertasks as separate processes impersonating the user that the server has been started with. In this way it closes down access to remote resources that would have been available if it ran servertasks with delegation level (of impersonation). </p>
  
  <p>Now can this situation be changed by modifying some security policies or registry? As far as I understand network access in this situation happens as NullSession (anonymous user), so I assume one solution would be to enable share access by anonymous on remote end and allow NullSession to access this share locally. Edited: does not seem to help either :-/</p>
  
  <p>Other, pretty wild solution, would be to log in from the agent using LogonUser Windows API to log in the same user again but with full rights (not sure if this is feasible and even if it is, imo it means to store somewhere username/password :-) And yes, it would limit us to the LotusScript solution, unless we want to install JNI wrapper; all this should actually sit in XPage (the agent is just an example of the problem)</p>
  
  <p>Third solution would be to use UNC pathes instead of mapped drives and access the path with appropriate username/password (or anonymously + allowing NullSession access), but this solution kind of beats my purpose to discover the mapped drives and do this or that depending on which ones are available.</p>