久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 DirectoryServices.AccountManagement 從 OU 獲取組

Get Groups From OU using DirectoryServices.AccountManagement(使用 DirectoryServices.AccountManagement 從 OU 獲取組)
本文介紹了使用 DirectoryServices.AccountManagement 從 OU 獲取組的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想使用 AccountManagement 列出組織單位中的所有組.

I'd like to use AccountManagement to list all the groups in an Organizational Unit.

以下代碼段適用于 DirectoryServices,但我必須在結果中使用 DirectoryEntry 路徑實例化 GroupPrincipal(這感覺像是一個骯臟的修復).

The following snippet works with DirectoryServices but I would have to instanciate GroupPrincipal with the DirectoryEntry path in the result (which feels like a dirty fix).

DirectoryEntry root = new DirectoryEntry("LDAP://OU=Marketing,OU=Operations,OU=Applications,DC=mycompany,DC=local")
        DirectorySearcher ds = new DirectorySearcher(root);
        ds.Filter = "(objectCategory=group)";
        SearchResultCollection results = ds.FindAll();

有人有想法嗎?

謝謝!

推薦答案

您可以將 PrincipalContext 設置為要開始搜索的 OU 并使用 PrincipalSearcher-System.DirectoryService.AccountManagement 中的類來完成你需要的,像這樣:

You can set the PrincipalContext to the OU where you want to start the search and use the PrincipalSearcher-class in System.DirectoryService.AccountManagement to accomplish what you need, like this:

PrincipalContext yourOU = new PrincipalContext(ContextType.Domain, "mycompany.local", "OU=Marketing,OU=Operations,OU=Applications,DC=mycompany,DC=local");
GroupPrincipal findAllGroups = new GroupPrincipal(yourOU, "*");
PrincipalSearcher ps = new PrincipalSearcher(findAllGroups);
foreach(var group in ps.FindAll())
{
  Console.WriteLine(group.DistinguishedName);
}
Console.ReadLine();

這篇關于使用 DirectoryServices.AccountManagement 從 OU 獲取組的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Why shouldn#39;t I always use nullable types in C#(為什么我不應該總是在 C# 中使用可空類型)
C# HasValue vs !=null(C# HasValue vs !=null)
C# ADO.NET: nulls and DbNull -- is there more efficient syntax?(C# ADO.NET:空值和 DbNull —— 有沒有更高效的語法?)
How to set null value to int in c#?(如何在c#中將空值設置為int?)
How to handle nulls in LINQ when using Min or Max?(使用 Min 或 Max 時如何處理 LINQ 中的空值?)
Method call if not null in C#(在 C# 中如果不為 null 的方法調用)
主站蜘蛛池模板: 亚洲三级免费看 | 中文欧美日韩 | 亚洲网视频 | 国产精品一区网站 | 久久久久久久久久久久久9999 | 亚洲欧美日韩电影 | 天天干天天玩天天操 | 久久性色 | 亚洲国产精品99久久久久久久久 | 亚洲精品aⅴ| 欧美性极品xxxx做受 | 麻豆久久久久久久 | 成人av一区 | 午夜一区| 国产一区二区在线免费观看 | 欧美中文字幕 | 欧美日韩久久 | 精品久久久精品 | av网站在线播放 | 国产在线观看 | 成人免费在线视频 | 黑人精品 | 毛片一区 | 亚洲一区二区三区免费观看 | 亚洲网站在线观看 | 国产良家自拍 | 国产乱码高清区二区三区在线 | 四虎影院欧美 | 亚洲欧美第一视频 | 成人在线一区二区 | 亚洲国产成人精品女人久久久 | 国产在线高清 | 国产成人精品一区二区 | 国产日韩精品视频 | 亚洲精品久久久久久久久久久久久 | 欧美激情综合网 | 国产福利在线播放麻豆 | 日本福利视频免费观看 | 亚洲精品2区 | 久久九九99| 成人av电影免费在线观看 |