Run code under diffrent user

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have some code that I want to run under another user. I know his password.

I want the vb.net code in my program to strart under under that user and not
start an external program.

This because the application will run as a windows service and I cannot
start an exe from a service that runs under user account with administrator
rights. The service cannot run under localsystem because it also havs to
create users and add them to administrators group.
 
this requires a filename of the application you want to start.

I do not want to start another application, I want part of my code to run
under a diffrent useraccount. This is because of the application is running
as a windows service.
 
Hi Philip,

From you description, I understand that you want to run some codes in your
VB.NET Windows Service application under another user account.

If I misunderstood, please feel free to let me know.

Based on my research, we can call the LogonUser API to get the user's
security token. In Whidbey, the WindowsImpersonationContext will use the
security token to set the current thread under that user's security context.

Here are some links for your reference.
How to Impersonate
http://blogs.msdn.com/shawnfa/archive/2005/03/21/400088.aspx

How To: Use Impersonation and Delegation in ASP.NET 2.0
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html
/paght000023.asp

Please try this and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Back
Top