ASP.NET 从 AD 获取有关用户的数据
需要识别内网站点上的用户,windows用户名就是目标。它将被附加到最终发送到 SQL Server 的参数中。
我可以获得 HttpContext.Current.Request.ServerVariables("LOCAL_ADDR") 192.168.112.81
我们这里有一个混合地址包,其中 33% 是固定的,其余的是分配的。
是否有办法识别 AD 中分配给 IP 的用户?如果是这样,您有链接或示例吗?
TIA。
Need to identify user on intranet site, windows user name is the goal. That will be appended to params going to SQL Server in the end.
I can get HttpContext.Current.Request.ServerVariables("LOCAL_ADDR") 192.168.112.81
We have a mixed bag of addresses here, in that 33% are fixed and the rest are allocated.
Is there a recourse to identify the user assigned to an IP within AD? If so do you have a link or an example?
TIA.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在页面内,可以通过以下方式找到用户名:
或
在服务调用中
它将以域为前缀。
Within a page, the username can be found with:
or
or in a service call
It will be prefixed by the domain.
IP 不是分配给用户的,而是分配给机器的。不止一个用户可以使用一台机器,所以你的方法没有意义。
而是在您的网站上配置Windows 身份验证,然后您可以使用User MVC 控制器中的属性或 <一个href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.user.aspx" rel="nofollow">User Web 表单页面中的属性。这两个属性都会返回一个 IPrincipal依次具有 Identity 属性,哪个是一个 IIdentity 实例。身份的 name 属性将为您提供用户的帐户名。
IPs are not assigned to users, they are assigned to machines. More than one user can use a machine, so your approach makes no sense.
Instead configure Windows Authentication on your site and then you can use the User property within an MVC controller or the User property in a webforms page. Both these properties return an IPrincipal which in turn has an Identity property, which is an IIdentity instance. The name property of the identity will give you the user's account name.