问题描述
我有一个在内部网络上运行的ASP.net应用程序(好吧,它实际上在Sharepoint 2007上运行).
I have an ASP.net Application that runs on the internal network (well, actually it's running on Sharepoint 2007).
我只是想知道:
我可以以某种方式检索客户端使用的PC的名称吗?如果有帮助,我将可以访问Active Directory.问题是,人们使用多台PC.因此,我不能使用任何手动/静态映射.
Can I somehow retrieve the name of the PC the Client is using? I would have access to Active Directory if that helps. The thing is, people use multiple PCs. So, I cannot use any manual/static mapping.
如果可能的话,我不想使用任何客户端(阅读:JavaScript)代码,但是如果不能在服务器端完成,JavaScript也可以. ActiveX绝对没有问题.
If possible, I do not want to use any client-side (read: JavaScript) code, but if it cannot be done server-side, JavaScript would be OK as well. ActiveX is absolutely out of question.
推荐答案
System.Web.HttpRequest.UserHostname ,如仅返回IP:-(
System.Web.HttpRequest.UserHostname as suggested in this answer just returns the IP :-(
但是我才发现这个:
System.Net.Dns.GetHostEntry(Page.Request.UserHostAddress).HostName
只有在实际有DNS服务器来解析名称的情况下,该方法才有效(我的网络就是这种情况.)
That only works if there is actually a DNS Server to resolve the name, which is the case for my network.
这篇关于检索客户端的PC名称? (Windows身份验证)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!