Does anyone know a way to programatically determine the Windows Account IIS is using from inside an ASP or ASP.Net page?
Programatically Determine IIS User Account?
Collapse
X
-
Tags: None
-
Hi,
At work I have used System.Security .Pricipal.Windo wsIdentity.GetC urrent()
Remember though that the identity of secondary processes (say, those who use foreign dll's) might not have the same permissions as the original process acount, this is especially a recurring issue when dealing with network resources.
You can enable impersonation of other user accounts if you need to. (refer to http://www.eggheadcafe .com/articles/20050703.asp )
An excerpt from http://www.eggheadcafe .com/articles/20050703.asp is a good read:
Determining Identity
To determine the identity used for the request I set up a single aspx page that writes out the three most common ways of getting the current identity from a web application. These are the Page.User.Ident ity, System.Security .Pricipal.Windo wsIdentity.GetC urrent() and system.Threadin g.Thread.Curren tPrincipal.Iden tity. The code for the Page_Load event is displayed in Listing 1. The IIS Security Settings dialog can be seen in Figure 1. This displays the options available for configuring web security with IIS.
Listing 1.
private void Page_Load(objec t sender, System.EventArg s e)
{
lblUser.Text = Page.User.Ident ity.Name;
lblWindow.Text = System.Security .Principal.Wind owsIdentity.Get Current().Name;
lblThread.Text = System.Threadin g.Thread.Curren tPrincipal.Iden tity.Name;
} -
-
Originally posted by controlboxDoes anyone know a way to programatically determine the Windows Account IIS is using from inside an ASP or ASP.Net page?
request.serverV ariables("logon _user")
or
request.serverV ariables("auth_ user")
But I think those will be blank unless you require a logon, in which case IIS is using I_USER
JaredComment
Comment