Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I want to pass admin user credentials programatically(VB.net).

there is my web application, i logged-in application as simple user but when i access scheduled tasks that time i want to application should take credentials programatically which i will hard coded into the code.

present code is as below:
VB
Dim wi As WindowsIdentity = HttpContext.Current.User.Identity
Dim wic As WindowsImpersonationContext = wi.Impersonate()

here at wi object should contains admin credentials.
is it possible?

Your help is appreciated.
Posted
Updated 11-May-12 5:27am
v2

1 solution

Have a look at this article, which gives you an 'Impersonator' class

A small C# Class for impersonating a User[^]

It's quite nice that you can wrap in a using block for obvious clarity about which section of code is executing under elevated priviliges.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900