我的项目发布在服务器,想做一个功能,当客户端访问网站时可以获取到这个客户端的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用户名?
在网上找了很多方法都不行,如下:
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用户名?
解决方案 »
- C#winform-post请求
- 【求助】控件Disabled后如何重新启用
- 请教如何让datagridview中的 checkbox默认选中
- ComponentOne C1Chart 改变单个数据点的样式问题
- 请问这个是什么意思?[XmlElement]?
- 请问C# ASPNET 作了二年在北京上海深圳一个月能有多少啊???
- 想在VS2005中C#代码编辑器中超链接,但是
- CSDN有没有人解决:调用数据库更新的存储过程,程序运行无错,存储过程无错,但数据库记录不更新.
- 隐藏datagrid的某列
- 谁能帮我解释一下下面这段程序的含义呀!?
- 关于webbrowser显示的问题
- 关于list<String>.sort()方法的疑问
可以自己写个ActiveX让客户都装上去,如果有必要
System.Net.IPHostEntry ine = System.Net.Dns.GetHostByAddress(ip);
Page.Response.Write(ine.HostName);
這個不錯