Search Filter Syntax

 https://docs.microsoft.com/zh-cn/windows/win32/adsi/search-filter-syntax?redirectedfrom=MSDN

https://blog.csdn.net/bytxl/article/details/11556195

 

 // Create a new DirectorySearcher that starts at the root.
    // You can start it anywhere you want though
    //     by providing a value in the DirectoryEntry constructor.
    DirectorySearcher searcher = new DirectorySearcher(new DirectoryEntry());
 
// Set the scope to Subtree in order to search all children.
searcher.SearchScope = SearchScope.Subtree;
 
// Set the filter to only look for Organizational Units//     that have the name you are looking for.
searcher.Filter = "(&(objectClass=organizationalUnit)(name=" + ouName + "))";
 
// If you are looking for only one result then do the following two things.SearchResult results = searcher.FindOne();
this.Properties = results.GetDirectoryEntry();
posted @ 2021-02-22 10:05  启明星工作室  阅读(138)  评论(0编辑  收藏  举报