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

查找屬于兩個 Active Directory 組的用戶

Finding users that are members of two active directory groups(查找屬于兩個 Active Directory 組的用戶)
本文介紹了查找屬于兩個 Active Directory 組的用戶的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我需要找到屬于兩個組(GroupA 和 GroupB)的所有用戶.我還需要考慮嵌套組.這樣做的最佳方法是什么?

I need to find all users that are members of two groups (GroupA and GroupB). I also need to take into account nested groups. What is the best way to do this?

我知道使用 memberOf 進行 ldap 搜索不會考慮嵌套組.我還可以專門定位這兩個組,獲取成員列表,并遍歷它們,匹配屬于兩個列表的成員,但組的成員集合也不考慮嵌套組.是否有任何方法適用于嵌套組,或者我是否需要編寫自己的遞歸邏輯?

I know that doing an ldap search using memberOf does not take into account nested groups. I could also locate the two groups specifically, get a list of members, and iterate through them, matching up ones that are members of both lists, but the members collection of a group doesn't take into account nested groups either. Are there any methods that do work with nested groups, or do I need to write my own recursive logic?

編輯嵌套組:如果我有一個名為 GroupA 的安全組.GroupA 可以擁有用戶或其他組的成員.如果 GroupB 是 GroupA 的成員,那么它就是我所說的嵌套組".

Edit Nested group: If I have a security group called GroupA. GroupA can have members which are either users or other groups. GroupB is what I am calling a 'nested group' if it is a member of GroupA.

推薦答案

這里有一些在 ActiveDirectory 2003 ans 2008 R2 中工作的東西.我使用 Microsoft LDAP_MATCHING_RULE_IN_CHAIN 來:

Here is something working in an ActiveDirectory 2003 ans 2008 R2. I use Microsoft LDAP_MATCHING_RULE_IN_CHAIN to :

1) 遞歸搜索(但在一個查詢中)第一組中的所有用戶(小心它返回來自安全和分發(fā)組的用戶)

1) Search recursively (but in one query) all the users from the first group (be careful it return users from security and distributions group)

2) 對于第一個查詢中的每個用戶,我再次遞歸搜索(但在一個查詢中)該用戶是否屬于第二個組.

2) For each user from the first query, I again search recursively (but in one query) if the user belongs to the second group.

static void Main(string[] args)
{
  //Connection to Active Directory
  string sFromWhere = "LDAP://SRVENTR2:389/dc=societe,dc=fr";
  DirectoryEntry deBase = new DirectoryEntry(sFromWhere, "societe\administrateur", "test.2011");

  // To find all the users member of groups "Grp1"  :
  // Set the base to the groups container DN; for example root DN (dc=societe,dc=fr) 
  // Set the scope to subtree
  // Use the following filter :
  // (member:1.2.840.113556.1.4.1941:=CN=Grp1,OU=MonOu,DC=X)
  //
  DirectorySearcher dsLookFor = new DirectorySearcher(deBase);
  dsLookFor.Filter = "(&(memberof:1.2.840.113556.1.4.1941:=CN=Grp1,OU=MonOu,DC=societe,DC=fr)(objectCategory=user))";
  dsLookFor.SearchScope = SearchScope.Subtree;
  dsLookFor.PropertiesToLoad.Add("cn");

  SearchResultCollection srcUsers = dsLookFor.FindAll();

  // Just to know if user is present in an other group
  foreach (SearchResult srcUser in srcUsers)
  {
    Console.WriteLine("{0}", srcUser.Path);

    // To check if a user "user1" is a member of group "group1".
    // Set the base to the user DN (cn=user1, cn=users, dc=x)
    // Set the scope to base
    // Use the following filter :
    // (memberof:1.2.840.113556.1.4.1941:=(cn=Group1,OU=groupsOU,DC=x))
    DirectoryEntry deBaseUsr = new DirectoryEntry(srcUser.Path, "societe\administrateur", "test.2011");
    DirectorySearcher dsVerify = new DirectorySearcher(deBaseUsr);
    dsVerify.Filter = "(memberof:1.2.840.113556.1.4.1941:=CN=Grp3,OU=MonOu,DC=societe,DC=fr)";
    dsVerify.SearchScope = SearchScope.Base;
    dsVerify.PropertiesToLoad.Add("cn");

    SearchResult srcTheUser = dsVerify.FindOne();

    if (srcTheUser != null)
    {
      Console.WriteLine("Bingo {0}", srcTheUser.Path);
    }
  }
  Console.ReadLine();
}

這篇關于查找屬于兩個 Active Directory 組的用戶的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關文檔推薦

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 的方法調(diào)用)
主站蜘蛛池模板: a级黄色毛片免费播放视频 国产精品视频在线观看 | 激情国产视频 | 色在线免费视频 | 人人做人人澡人人爽欧美 | 岛国av免费在线观看 | 欧美在线a | 国产精品永久久久久久久www | 久草中文在线 | 小草久久久久久久久爱六 | 亚洲精品久久久久久下一站 | 中文字幕在线视频网站 | 中文字幕高清 | 亚洲成av人片在线观看无码 | 亚洲一区二区在线视频 | 五月婷婷激情网 | 国产精品亚洲第一区在线暖暖韩国 | 色橹橹欧美在线观看视频高清 | 成人精品久久 | 成人三级视频 | 亚洲成人精品免费 | 精品久久一区二区 | 国产一级淫片a直接免费看 免费a网站 | 久在线视频播放免费视频 | 日韩高清黄色 | 亚洲精品在线免费 | 欧美黑人体内she精在线观看 | 日韩一区在线播放 | 欧美一级片在线观看 | 九九九久久国产免费 | 日本精品视频在线 | 欧美v日韩v| 欧美激情第一区 | 欧美激情久久久 | 九九视频网 | 91高清视频在线观看 | www.五月天婷婷 | 亚洲高清在线 | 欧美黄在线观看 | 91精品国产高清一区二区三区 | 91久久伊人 | 亚洲一区二区三区视频 |