How can I give a windows service access on a remot

2019-04-14 05:31发布

问题:

I'm working on a Windows Service that one of its tasks is archiving files on remote machine but I've a problem regarding access privileges in case of Workgroup.

回答1:

The simplest way is to mirror the username and password on both machines, creating the same account on both machines, then run your service under that account. As you're in a workgroup and not a domain the remote login will work, but once you're in a domain that no longer works.

You cannot use any of the built in service accounts (Network Service, Local Service, Local System for this)



回答2:

You can run it under user account that has access privileges on remote machine.

Or you can use impersonation when accessing remote machine. For impersonation you will need username and password that has access to remote machine. Look here for some code on impersonating in .net http://blogs.msdn.com/shawnfa/archive/2005/03/22/400749.aspx