怎样获取客户端Windows用户名?
我的项目发布在服务器,想做一个功能,当客户端访问网站时可以获取到这个客户端的Windows登陆用户名,
在网上找了很多方法都不行,如下:
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;
这两种去不到值,Web.config也配置了如下:
<authentication mode="Windows"/>
<identity impersonate="true"/>
3.string userName = Environment.UserName;
4.WindowsIdentity identity = WindowsIdentity.GetCurrent();
string userName = identity.Name;
3和4只是获取本地用户(服务器)
5.Page.Request.UserHostAddress;
Page.Request.UserHostName
这两种只是获取客户端IP地址
谁知道怎样获取客户端Windows用户名?