TechyMedia

A .NET Technology blog | .NET,C# Progamming,C# tutorials,WPF WCF|Software Engineer

NAVIGATION - SEARCH

Accessing Mapped Network Directories from Windows Service and Web Applications

Even though mapped drives are accessible from normal windows applications without any hassle it will often make your life difficult when you try to access mapped drives through a windows service. Because windows service always runs in system context .In such situations you should use the UNC path . .

Free ASP.NET Tutorials

There may come situations in your programming life where in you need to access mapped network drive(like R:\ , Z:\ etc.) from your windows service or web applications.


Eventhough mapped drives are accessible from normal windows applications it will often make your life difficult when try to access from a windows service since it runs on user security context. Because windows service always runs in system context.

The solution is,

1) Get the actual UNC path of the mapped drive (\\Machinename\\SharePath\ .. ).You need to use this as access path instead of mapped drive name.


2) Change the process installer property account to User. (Normal tendency is to keep this as Loca system)

3) While installing the service using installutil you will get a credential prompt. provide the userID(eg: domain\user1)   and  PWD of the user who has access to the shared drive.


4) Start the service

Your service can now access the shared network without any hassle.


Most of the time, This will work well for ASP.NET applications also to access the share networkpath (Especially when windows authenticated and user has access to the directory path)

4 Hours of Video Training for the Absolute Beginner

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading