none
Windows Service can't access files on the network RRS feed

  • Question

  • How do I create a Windows Service that can access files on the network?  Right now the service is logged on as "Local System" and cannot access network folders or files.
    Monday, February 5, 2007 8:12 PM

Answers

  • You probably need to change the account the service runs under to either (a) a specific domain account that has access to file share or (b) to "network service" which runs ander a pre-defined privilege level.  Alternatively, you can store the username and password of a domain account in some sort of (hopefully secure) config file and then impersonate that user when you need to access the file share.  You might also be able to get to the shared files if you allow access to "everyone", but that is probably not desirable.
    Tuesday, February 6, 2007 3:36 AM

All replies

  • You probably need to change the account the service runs under to either (a) a specific domain account that has access to file share or (b) to "network service" which runs ander a pre-defined privilege level.  Alternatively, you can store the username and password of a domain account in some sort of (hopefully secure) config file and then impersonate that user when you need to access the file share.  You might also be able to get to the shared files if you allow access to "everyone", but that is probably not desirable.
    Tuesday, February 6, 2007 3:36 AM
  • The service is running in a Internet-zone this zone hasn't got the rights to access your file system. To get this right configure the policy level of you service to run in a other zone.

    for information: Security Policy Management

    And if you really want to figure/out this kind of security things take a look how sharepoint has organized it... interesting learning

    Tuesday, February 6, 2007 12:21 PM
  • Thanks for your help Erik.  I changes the service to impersonate and it works now.
    Tuesday, February 6, 2007 2:36 PM
  • Hi,
    How do I do that? that is impersonate another user and read the config file? I'm assuming that the "run as" feature is different than impersonation that is being referred to in this thread.

    Thanks
    Wednesday, October 10, 2007 1:53 PM