is it possible to get clients windows username in asp.net hosted in remote server without using activex object ?
i have used following code
Response.Write("HttpContext.Current.Request.LogonUserIdentity.Name " & HttpContext.Current.Request.LogonUserIdentity.Name)
Response.Write("<br/>")
Response.Write("HttpContext.Current.Request.IsAuthenticated " & HttpContext.Current.Request.IsAuthenticated)
Response.Write("<br/>")
Response.Write("HttpContext.Current.User.Identity.Name " & HttpContext.Current.User.Identity.Name)
Response.Write("<br/>")
Response.Write("System.Environment.UserName " & System.Environment.UserName)
Response.Write("<br/>")
Response.Write("Security.Principal.WindowsIdentity.GetCurrent().Name() " & System.Security.Principal.WindowsIdentity.GetCurrent().Name())
Response.Write("<br/>")
but it is always giving me server user name not the clients username .
You can try to use ServerVariables
string Hostname=Request.ServerVariables["REMOTE_HOST"];
string Username=Request.ServerVariables["REMOTE_USER"];
this line will work if you are using "Windows Authentication"
Response.Write("HttpContext.Current.User.Identity.Name " & HttpContext.Current.User.Identity.Name)
ref: MSDN
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.