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

  • Thread starter Thread starter Daniel
  • Start date Start date
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)
 
my login code is like this:
bool returnValue = LogonUser(userName, domainName, password,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle);
 
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)
 
Back
Top