获取 Sharepoint 中 WebPart 内的 Active Directory URL

发布于 2024-12-22 01:10:18 字数 545 浏览 2 评论 0原文

有没有办法找出 SharePoint Web 部件中当前 Active Directory 的 URL?

如果我有 URL,我可以使用此构造函数通过当前用户的凭据创建对 AD 的访问:

new DirectoryEntry(<URL>, null, null, AuthenticationTypes.Secure));

我可能会发现此 URL 属性隐藏在此处的某处吗?

        SPSite sc = new SPSite(SPContext.Current.Site.ID);
        ServerContext context = ServerContext.GetContext(sc);
        UserProfileManager profileManager = new UserProfileManager(context);
        ...

或者是否有任何其他动态方式使用当前用户(具有 AD 读取权限)创建与 AD 的连接,而无需在配置文件中指定任何先前参数?

is there a way to find out the current Active Directory's URL inside SharePoint webpart?

If I have the URL, I can use this constructor to create access to AD with current user's credentials:

new DirectoryEntry(<URL>, null, null, AuthenticationTypes.Secure));

Might I find this URL propertry hidden somewhere here?

        SPSite sc = new SPSite(SPContext.Current.Site.ID);
        ServerContext context = ServerContext.GetContext(sc);
        UserProfileManager profileManager = new UserProfileManager(context);
        ...

Or is there any other dynamic way to create connection to AD using current user (which has AD read rights) without specifying any prior parameters in configuration file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风为裳 2024-12-29 01:10:18

您可以在 SPWebApplication 上提取人员选取器设置:

SPWebApplication.PeoplePickerSettings.SearchActiveDirectoryDomains

如果没有指定域,您可以使用全局目录作为 倒退:

GlobalCatalog gc = Forest.GetCurrentForest().FindGlobalCatalog();
DirectoryEntry entry = new DirectoryEntry("GC://" + gc.Name));

You could extract the people picker settings on the SPWebApplication:

SPWebApplication.PeoplePickerSettings.SearchActiveDirectoryDomains

If there are no domains specified you could use the global catalog as fallback:

GlobalCatalog gc = Forest.GetCurrentForest().FindGlobalCatalog();
DirectoryEntry entry = new DirectoryEntry("GC://" + gc.Name));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文