Solved

.net windows service unable to access mapped network drives

Posted on 2008-06-21
3
1,056 Views
Last Modified: 2013-11-06
I have a windows service in C# ( not ASP .NET) which should read files from local and remote drives.
Local drives works fine but when i do a directory.Exists() on remote drive, it says filepath not found.
It was mentioned that we cannot use drive letters in windows service. I tried UNC paths also but no luck.
Both the machines are under the same domain, the remote directory has full access to everybody.
I could read the UNC path using windows application though. Tried running the windows service both under local system and network service. Any help is appreciated!
0
Comment
Question by:vizagboy
3 Comments
 
LVL 10

Expert Comment

by:Marcjev
ID: 21838269
You should use a real account. Both the local account nor the network service account have sufficient rights to access the other computers share. The local system has a name who says it all. The network service account has very limmited access rights and is intended for your computer to present itself to the network. (Like a default asp.net app listening only...)
0
 
LVL 5

Accepted Solution

by:
JuckMan earned 350 total points
ID: 21839639

the reason you are unable to use the drive lettes is, drive letter mapping is for the current login user only. Service run under a different security context and has no way of understanding it. Think of it another way, you can run a service without login to your computer. Mapped letters available once a user login.

Use the service properties and in the logon tab select a domain use account, which has rights to access both your local and remote drives.  Also note that this account needs to have "Log on as service" privilege, this will be granted automatically when you type in the user in the "logon" tab in service properties.

If your orgainization is paranoid with security issues, then you need to consider the following. Create a domain account, and when it is created set it as "deny login as local user" privilege. In this way it will be make it difficult for any body to hack or impersonate the service to do something else.

hope this helps
0
 

Author Closing Comment

by:vizagboy
ID: 31469432
Thanks a lot. Changed the service properties to run the service as a domain user who has access to both the accounts and it worked like a charm. Thank you for the help!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now