此代码获取我们组织中 AD 用户的属性,特别是网站运行的用户,一个服务帐户(因此无论哪个用户运行网站,结果都是相同的):
DirectoryEntry entry = UserPrincipal.Current.GetUnderlyingObject() as DirectoryEntry;
if (entry != null)
{
foreach (string name in entry.Properties.PropertyNames)
{
Response.Write(entry.Properties[name].Value.ToString() + "</br>");
}
}
但是,我需要的是为运行网络浏览器的用户获取这些属性。我认为我可以从 HttpContext 中获取这些信息,但无法通过这种方式找到该主体或 GetUnderlyingObject() 方法。
如何为登录到 Windows 计算机并运行 Web 浏览器的用户获取相同的 AD 属性列表?
最佳答案
string user = HttpContext.Current.User.Identity.Name.ToString();
如果您需要对这些信息执行更多操作而不是打印它,您应该能够通过谷歌搜索找到有关在网络表单中使用 AD 的更多信息:)
https://stackoverflow.com/questions/62644675/
相关文章:
amazon-web-services - server.servlet.context-path
amazon-web-services - AWS Lambda 上的 Apollo graphql
c - 尝试在 bmp 文件中画线时如何在 C 中实现 Bresenham 的线算法?
java - 在 springboot 中创建名为 'org.springframework.boo
python - 在不阻塞其他任务的情况下限制 celery 任务的速率
c# - EF 核心错误 : "Comparison on entity type is not s
reactjs - 如何使用 react-email-editor 加载 HTML 模板而不是 js
c# - 是否可以从 .NET Core 中间件检索 Controller 的操作结果?