Principal.IIdentity

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

We'd like to capture the windows account of the current web user. In our
code-behinds, this is cake using:

System.Security.Principal.IIdentity ii = User.Identity;
Reponse.Write("User: " + ii.Name);

However, we have a global error hander in the Global.asax Application_Error
event that it doesn't work so hot in. This is due to the fact that the User
class above is available only through the Page class. The global.asax isn't
a page, so it doesn't have access to User. Is there a way around this?

Note - we can't use WindowsPrincipal or WindowsIdentity because we're using
Impersonation to connect to SQL Server.
The WindowsPrincipal would give us the wrong user.

Thanks in advance!
Mark
 
How about using a Session variable as the user first hits the site to store
the Identity. Then check the Session variable from within the Error Page if
it gets fired.
 
Back
Top