By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Network Share\Mapped Drive Access from a windows service

P: n/a
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.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

http://www.dotnet247.com/247referenc...28/144136.aspx

Ken
--------------------
"Dave Stewart" <Da*********@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...
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.
Nov 21 '05 #2

P: n/a

"Dave Stewart" <Da*********@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...
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.


Is there a specific reason you can't run the service under a domain account?
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.