What permissions are needed for windows service to do C# impersonation when started under a user acc

D

Daniel

I have a windows service that impersonates another account fine when it runs
under system account but fails to impersonate when run under a user account.
What permissions must the windows service user account have inorder to do
impersonation?

the error i get is:

System.ComponentModel.Win32Exception: Access is denied
at myService.Service1.impersonatetest(String domain, String login, String
password, String path)
at myService.Service1.OnStart(String[] args)
 
D

Daniel

my login code is like this:
bool returnValue = LogonUser(userName, domainName, password,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle);
 
D

Dmitriy Lapshin [C# / .NET MVP]

Daniel,

Try granting the user the service runs under the "Log on as a service"
right.
Also, I'd use LOGON32_LOGON_SERVICE instead of LOGON32_LOGON_INTERACTIVE.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Daniel said:
my login code is like this:
bool returnValue = LogonUser(userName, domainName, password,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle);

Daniel said:
I have a windows service that impersonates another account fine when it runs
under system account but fails to impersonate when run under a user account.
What permissions must the windows service user account have inorder to do
impersonation?

the error i get is:

System.ComponentModel.Win32Exception: Access is denied
at myService.Service1.impersonatetest(String domain, String login, String
password, String path)
at myService.Service1.OnStart(String[] args)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top