久久久久久久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 的方法調用)
主站蜘蛛池模板: 国产第二页 | 欧美午夜一区 | 男女网站免费观看 | 午夜精品久久久久久久久久久久 | 亚洲高清视频一区二区 | 午夜免费福利电影 | 中文字幕不卡在线观看 | 日韩 欧美 综合 | 欧美一区二区三区在线观看视频 | 一区二区三区在线 | 欧 | 在线天堂免费中文字幕视频 | 天天色综 | 国产91丝袜在线播放 | 蜜桃一区二区三区在线 | 日韩精品在线免费观看视频 | 免费成人高清在线视频 | 精品国产91久久久久久 | 九色av| 观看av | 精久久久 | 日韩最新网站 | 2022精品国偷自产免费观看 | 亚洲三区在线观看 | 狠狠干综合视频 | 国产在线一区二区 | 日本午夜一区二区三区 | 第四色播日韩第一页 | 久久国产精彩视频 | 999观看免费高清www | 亚洲 自拍 另类 欧美 丝袜 | 成人免费观看男女羞羞视频 | a毛片 | 欧美性久久久 | 欧美精品国产一区二区 | 亚洲精品高清视频 | 国产美女一区二区 | 久久久久国产一区二区三区四区 | 日批日韩在线观看 | 国产一区欧美 | 国产精品精品视频 | 国内精品一区二区 |