Active Directory Attribute List Using c#

后端 未结 6 1598
青春惊慌失措
青春惊慌失措 2021-01-14 14:30

How i get the list of active directory user attributes(not of particular user i.e.all attributes) e.g.cn,mail etc. using c#?

6条回答
  •  Happy的楠姐
    2021-01-14 15:07

    You could use WMI:

     ObjectGetOptions objectGetOptions = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
     ManagementClass managementClass = new ManagementClass("root\\directory\\LDAP", "ads_user", objectGetOptions);
    
     foreach (PropertyData dataObject in managementClass.Properties)
     {
        Console.WriteLine(dataObject.Name);
     }
    

提交回复
热议问题