小编cci*_*ikk的帖子

如果OU包含3000个用户,如何使用DirectorySearcher查找所有用户?

我用这个代码:

DirectoryEntry objEntry;
DirectorySearcher objSearchEntry;
SearchResultCollection objSearchResult;
string strFilter = "(&(objectCategory=User))";
objEntry = new DirectoryEntry(conOUPath, conUser, conPwd, AuthenticationTypes.Secure);
objEntry.RefreshCache();
objSearchEntry = new DirectorySearcher(objEntry);
objSearchEntry.Filter=strFilter;
objSearchEntry.SearchScope=SearchScope.Subtree;
objSearchEntry.CacheResults=false;
objSearchResult=objSearchEntry.FindAll();
Run Code Online (Sandbox Code Playgroud)

每次只返回1000个用户,但该OU中有3000个用户.

我怎样才能找到所有这些?

c# directoryservices active-directory

8
推荐指数
2
解决办法
1万
查看次数

如何使用objectGUID获取DirectoryEntry?

我知道,我们可以像这样得到一个DirectoryEntry:

string conPath = "LDAP://10.0.0.6/DC=wds,DC=gaga,DC=com";
string conUser = "administrator";
string conPwd = "Iampassword";
DirectoryEntry de = new DirectoryEntry(conPath, conUser, conPwd, AuthenticationTypes.Secure);
Run Code Online (Sandbox Code Playgroud)

我们可以像这样更改用户的密码:

DirectorySearcher deSearch = new DirectorySearcher();
deSearch.SearchRoot = de;
deSearch.Filter = String.Format("sAMAccountName={0}", "xumai");
SearchResultCollection results = deSearch.FindAll();
foreach (SearchResult objResult in results)
{
    DirectoryEntry obj = objResult.GetDirectoryEntry();
    obj.Invoke("setPassword", new object[] { "Welcome99" });
    obj.CommitChanges();
}
Run Code Online (Sandbox Code Playgroud)

如果使用

string x = obj.Guid.ToString();;
Run Code Online (Sandbox Code Playgroud)

我们可以得到用户的objectGUID"0b118130-2a6f-48d0-9b66-c12a0c71d892"

我怎么能改变它是密码基础这个objectGUID?

如何搜索用户群这个objectGUID表单"LDAP://10.0.0.6/DC=wds,DC=gaga,DC=com"?

是否有任何方式过滤它?etc strFilter ="(&(objectGUID = 0b118130-2a6f-48d0-9b66-c12a0c71d892))";

希望得到你的帮助

谢谢.

c# directoryservices guid active-directory directoryentry

3
推荐指数
1
解决办法
9987
查看次数