A
Alberto Ortega
I'm trying to impersonate a user using the WindowsIdentity ctor. This is
what I'm doing
WindowsIdentity id = new WindowsIdentity( "(e-mail address removed)-dev.net" );
WindowsImpersonationContext wic = id.Impersonate();
try
{
DoSome();
}
finally
{
wic.Undo();
}
I'm getting this exception
Access is denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.ApplicationException: Access is denied.
[ApplicationException: Access is denied.
]
System.Security.Principal.WindowsIdentity._ResolveIdentity(IntPtr
userToken) +0
System.Security.Principal.WindowsIdentity.get_Name() +70
ImpersonationTest.WebForm1.DoSome() in
c:\inetpub\wwwroot\impersonationtest\webform1.aspx.cs:71
ImpersonationTest.WebForm1.ImpersonateWinId() in
c:\inetpub\wwwroot\impersonationtest\webform1.aspx.cs:41
ImpersonationTest.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\impersonationtest\webform1.aspx.cs:29
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
The configuration is:
* IIS: Anonynous checkbox ON and Integrated Security checkbox ON
* Web.config: <identity impersonate="true"> and <authentication
mode="Forms"> (auth mode forms is a requisite non negotiable on my app)
* The app pool for the virtual dir is configured with Network Service
Running on Win2K3 Domain Controller
Any idea of what I should do to make the impersonation work?
Thanks,
Beto
what I'm doing
WindowsIdentity id = new WindowsIdentity( "(e-mail address removed)-dev.net" );
WindowsImpersonationContext wic = id.Impersonate();
try
{
DoSome();
}
finally
{
wic.Undo();
}
I'm getting this exception
Access is denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.ApplicationException: Access is denied.
[ApplicationException: Access is denied.
]
System.Security.Principal.WindowsIdentity._ResolveIdentity(IntPtr
userToken) +0
System.Security.Principal.WindowsIdentity.get_Name() +70
ImpersonationTest.WebForm1.DoSome() in
c:\inetpub\wwwroot\impersonationtest\webform1.aspx.cs:71
ImpersonationTest.WebForm1.ImpersonateWinId() in
c:\inetpub\wwwroot\impersonationtest\webform1.aspx.cs:41
ImpersonationTest.WebForm1.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\impersonationtest\webform1.aspx.cs:29
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
The configuration is:
* IIS: Anonynous checkbox ON and Integrated Security checkbox ON
* Web.config: <identity impersonate="true"> and <authentication
mode="Forms"> (auth mode forms is a requisite non negotiable on my app)
* The app pool for the virtual dir is configured with Network Service
Running on Win2K3 Domain Controller
Any idea of what I should do to make the impersonation work?
Thanks,
Beto