Solved

.net windows service unable to access mapped network drives

Posted on 2008-06-21
3
1,061 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Post a good COM tutorial 1 68
Best environment for cross platform web development? 5 71
Graph API & MS Apps 1 56
Netbeans and org.apache.commons.lang3 issue 3 26
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

749 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