Active Directory Attribute List Using c#

后端 未结 6 1588
青春惊慌失措
青春惊慌失措 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条回答
  •  [愿得一人]
    2021-01-14 14:56

    Expanding on marc_s's answer here. Here is a complete code example that prints the common name and the actual attribute name.

    ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurrentSchema();
    ActiveDirectorySchemaClass person = schema.FindClass("user");
    foreach( ActiveDirectorySchemaProperty property in person.GetAllProperties() )
    {
        Console.WriteLine("{0} = {1}", property.CommonName, property.Name);
    }
    

    Example output.

    Common-Name = cn
    Instance-Type = instanceType
    NT-Security-Descriptor = nTSecurityDescriptor
    Object-Category = objectCategory
    Object-Class = objectClass
    Object-Sid = objectSid
    SAM-Account-Name = sAMAccountName
    Account-Expires = accountExpires
    ...
    

提交回复
热议问题