Accessing network folder using windows service

rajthampi

Member
Joined
Jul 16, 2008
Messages
18
Location
Kuwait
Programming Experience
Beginner
Hi guys we are developing a small utility for synchronizing a network folder where, as domain admins we have the full privileges, with a local folder in another computer.
We had written a service to do this job and found that when the service starts the error returned is "Access denied". This service is running as "Local System" and if we manually input the username and password along with the domain details then the service runs successfully.
So our question is, there any methods through which we could pass the authentication credentials automatically to the service so that we may not have to manually pass the authentication credentials?
 
I'm not sure of the exact details of what your program is performing. But yes, it would depend on how your network security & permissions are set up.

For instance it is common to see that the average user in a network may not have permissions to write files to a particular network/shared drive. This includes when a client side/workstation app accesses a shared drive file. This might cause an attempt by the app to create a temp file in that location that the user do not have permission to do so.

Without know more detail, it's hard for me to answer your question better. There are plenty of methods that can be used to access a networks Active Directory and pass user credentials for authentication.

Or you could change user/usergroup permissions and/or alter the code so that it is not trying to do something against current permissions. Such as copying a file to the local drive before opening it.
 
Details

Thank you very much Tom

What we are trying to do is simple like following:


1. We are running the service from server A.
2. We want one folder within Server A to be synchronized with files from a particular folder from Server B.
3. Both A & B Servers are logged in with the same user credentials, ie a domain admin has logged on to both the servers
4. Both folders from Server A and Server B (in our case, source folder and target folder) is shared and domain admins have full privileges

5. When the service starts at a specific time, it tries to match the time stamps of files within the source and target folders and if the target folder files are older than the source folder files, replace them with the latest files.

I think you had suggested us already one work around, referring to the Active directory objects. However we would appreciate incase if you would provide more info about how to manipulate it in details.

Thanks and regards,
 
Run the service as User, use a user account that has access rights to the share. In a domain it is possible to use NetworkService or LocalSystem and grant access to the share for the machine account.
 
Back
Top