Home All Groups Group Topic Archive Search About

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

Author
22 Dec 2004 12:38 AM
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)
Author
22 Dec 2004 1:42 AM
Daniel
my login code is like this:
bool returnValue = LogonUser(userName, domainName, password,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle);

Show quoteHide quote
"Daniel" <softwareengineer98***@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)
>
>
Are all your drivers up to date? click for free checkup

Author
22 Dec 2004 11:22 AM
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

Show quoteHide quote
"Daniel" <softwareengineer98***@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" <softwareengineer98***@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)
>>
>>
>
>

Bookmark and Share