-
Network Folder Access in Windows Service
Hi
I am writing a windows service which is supposed to write some files on a network shared folder.
Through my research on net I came to know that I need to run this service under the same NetworkService account which has permission on Network shared folder. I set the UserName and Password in Project Installer File.
I run the service using UNC convention to access the network shared folder and got Path Not Found error.
Than I manually mapped the shared folder using the same domain account which I set to run the service and tried to use the Shared Drive path to access the destination folder and got the same Path Not Found error.
Now reading different posts on net about similar problem I came to know I can map the shared folder programatically in my windows service using WMI. I want to know someone succeeded to access the network resource in Windows service or not? If yes than how?
I am stuck. Please Help.
Thanks is advance
Regards
Wajid
-
No Worries I got it
Posting solution hope it will be helpfull for others.
1) Service account will remain same to LocalSystem.
2) You need to map the shared folder(mapped drive) inside your web service using
Win32 API mpr.dll
Method in API --> WNetAddConnection2A
this method needs parameters like Domain UserName and Password.
Later use that mapped drive letter to read, write or what ever you are allowed by this Domain User.
Cheers
-
Hello,
I have the same problem. Can you give a sample code
.
I'm trying to apply what you say in last post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks