I need the application impersonate UserA to access a shared folder.
I modify Web.config file to impersonate a userA and the web application access the shared folder successfully. web.config: <identity impersonate="true" userName="domain\userA" password="password" />
After the application access the shared folder, I check the security event on the shared folder's server, it showed anonymous logon. (I checked the WindowsIdentity.GetCurrent() is userA.)
ckmenx
0 Points
2 Posts
Cannot Impersonate the Authenticating User in Code
Dec 15, 2012 02:54 AM|LINK
I need the application impersonate UserA to access a shared folder.
I modify Web.config file to impersonate a userA and the web application access the shared folder successfully.
web.config:
<identity impersonate="true" userName="domain\userA" password="password" />
But I cannot Impersonate the userA in Code.
web.config:
<identity impersonate="true" />
Code:
System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext = WindowsIdentity.GetCurrent().Impersonate();
//my code
impersonationContext.Undo();
After the application access the shared folder, I check the security event on the shared folder's server, it showed anonymous logon. (I checked the WindowsIdentity.GetCurrent() is userA.)
What should I do? Thanks!!
molly_c
Participant
1590 Points
401 Posts
Re: Cannot Impersonate the Authenticating User in Code
Dec 17, 2012 09:37 AM|LINK
Looks weird... Tell us more inforamtion about your issue.
Molly
It's time to start living the life you are imagined.
ckmenx
0 Points
2 Posts
Re: Cannot Impersonate the Authenticating User in Code
Dec 19, 2012 06:44 AM|LINK
Could you tell me what information I should provide? Thanks!
molly_c
Participant
1590 Points
401 Posts
Re: Cannot Impersonate the Authenticating User in Code
Dec 19, 2012 07:22 AM|LINK
Something like authentication or something else...
Your step is total same as "How to implement impersonation in an ASP.NET application" said.. Im not sure where is your error part..
if you dont' set identity impersonate = "True" in web.config, does your code work?
Molly
It's time to start living the life you are imagined.