Pergunta

I need to access to a shared resource with a windows service using local system user. I have a try with the class UserImpersonation, but it only works in debugging. When I install my service, I can't access to a shared folder.

I have read about this topic, and I would like to know if the only way is to create an user with network credentials and execute the service with this user.

Foi útil?

Solução

Your final paragraph of your question contains the answer. The service runs in the context of a specific user. You need to make sure that this user can access the resource in question. It's not uncommon to create dedicated users just for a particular service for this very reason.

Outras dicas

You can have the service run under an account (not necessarily NetworkService as in the screenshot) for which you've provisioned network access. To do this, go to your services manager, and right click on properties:

enter image description here

There are two types of permissions you have to consider when accessing network share, which you have to make sure that the account you use has: Share and NTFS permissions

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top