Re: What permissions are needed for windows service to do C# impersonation when started under a user account?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dmitriy Lapshin [C# / .NET MVP] (x-code_at_no-spam-please.hotpop.com)
Date: 12/22/04


Date: Wed, 22 Dec 2004 13:22:30 +0200

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" <softwareengineer98037@yahoo.com> wrote in message 
news:uHY1ub85EHA.824@TK2MSFTNGP11.phx.gbl...
> my login code is like this:
> bool returnValue = LogonUser(userName, domainName, password,
> LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle);
>
> "Daniel" <softwareengineer98037@yahoo.com> wrote in message
> news:%23CK0%23375EHA.924@TK2MSFTNGP14.phx.gbl...
>> 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)
>>
>>
>
> 


Relevant Pages