通过域登录的代码:

<1>

System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;

string strName = p.Identity.Name;

<2>

string strName = HttpContext.Current.User.Identity.Name.ToString();

<3>

string strName = Request.ServerVariables["AUTH_USER"]; //Finding with name

string strName = Request.ServerVariables[5]; //Finding with index

你可能感兴趣的:(代码)