我创建了一个具有子ADDomain2的ParentDomain ADDomain1。在ADDomain2中,我创建了一个Group'Common Users',我有来自ADDomain1和ADDomain2的用户,但是当我在ADDomain2中搜索ADDomain1用户时,它不会返回任何结果。这是一个代码
DirectorySearcher directorySearcher = new DirectorySearcher();
DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://ADDomain2","UserName","Password");
directoryEntry.Path = "LDAP://ADDOMAIN2/DC=ADDOMAIN2,DC=ADDOMAIN1,DC=WAVEDOMAIN";
directorySearcher.SearchRoot = directoryEntry;
directorySearcher.FindOne();
directorySearcher.PageSize = 1000;
directorySearcher.Filter = "(&(objectCategory=person)(name=ADDOMAIN1User))";
SearchResultCollection results = directorySearcher.FindAll();
但是当我搜索ADDOMAIN2用户时,它会返回结果。
任何想法?
感谢名单
答案 0 :(得分:0)
我不知道DirectoryEntry,它是否与UserPrincipal一起使用? AD2是全球目录吗?
样品:
using System.DirectoryServices.AccountManagement;
var ctx = new PrincipalContext(ContextType.Domain, "ADDOMAIN2");
var usr = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, "whatever");
// you can also find the GroupPrincipal and get its members