G
Guest
I am attempting to write a vb.net windows service that will automate various
file movements on my network. When I attempt to access files on a mapped
drive or UNC file share, I get exceptions claiming that the file is not
there. However if I copy the file path directly in to explorer it pops right
up.
I know that my service is running as local system and this must be causing
the problems. When I write the windowsidentity.getcurrent().name to the event
log, it reads as NT AUTHORITY\SYSTEM. I have tried impersonation with no
success. The service stops immediatley when attempting to run this line:
Private Declare Auto Function LogonUser Lib "advapi32.dll" (ByVal
lpszUsername As [String], _
ByVal lpszDomain As [String], ByVal lpszPassword As [String], _
ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, _
ByRef phToken As IntPtr) As Boolean
**As an added bonus, the file share I am trying to access is on an AS400. I
have mapped the drive and am attempting to use the pre-mapped drive. It would
be nice to authenticate directly to the AS400 from my code, and the use the
UNC share name for the directory on the 400.
file movements on my network. When I attempt to access files on a mapped
drive or UNC file share, I get exceptions claiming that the file is not
there. However if I copy the file path directly in to explorer it pops right
up.
I know that my service is running as local system and this must be causing
the problems. When I write the windowsidentity.getcurrent().name to the event
log, it reads as NT AUTHORITY\SYSTEM. I have tried impersonation with no
success. The service stops immediatley when attempting to run this line:
Private Declare Auto Function LogonUser Lib "advapi32.dll" (ByVal
lpszUsername As [String], _
ByVal lpszDomain As [String], ByVal lpszPassword As [String], _
ByVal dwLogonType As Integer, ByVal dwLogonProvider As Integer, _
ByRef phToken As IntPtr) As Boolean
**As an added bonus, the file share I am trying to access is on an AS400. I
have mapped the drive and am attempting to use the pre-mapped drive. It would
be nice to authenticate directly to the AS400 from my code, and the use the
UNC share name for the directory on the 400.