有没有办法找出SharePoint webpart中当前的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的连接,而不在配置文件中指定任何先前的参数?
答案 0 :(得分:1)
您可以在SPWebApplication
上提取人员选择器设置:
SPWebApplication.PeoplePickerSettings.SearchActiveDirectoryDomains
如果没有指定域,则可以使用全局编录作为后备:
GlobalCatalog gc = Forest.GetCurrentForest().FindGlobalCatalog();
DirectoryEntry entry = new DirectoryEntry("GC://" + gc.Name));