从asp.net获取AD用户objectGuid的身份验证
我在 ASP.NET 应用程序中使用 Windows 身份验证。 我想知道如何最好地从当前登录的用户获取 objectGuid?
问候,埃吉尔。
I am using windows authentication within an ASP.NET application. I am wondering how to best get the objectGuid from the currently logged in user?
Regards, Egil.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
建议的解决方案相当昂贵。 更好的解决方案是使用 SID 来查找帐户,而不是通过域和用户名进行搜索:
The suggest solutions are rather expensive. Rather than searching by domain and username, a better solution is to use the SID to lookup the account:
您可以使用 System.DirectoryServices 命名空间来执行此操作。
可能有更好的方法来做到这一点,但这可行!
You can do this with the System.DirectoryServices namespace.
There might be a better way to do this, but this works!
您需要使用 NativeGuid 属性。 C#代码:
You need to use NativeGuid property. C# code: