Active Directory Attribute List Using c#

后端 未结 6 1595
青春惊慌失措
青春惊慌失措 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条回答
  •  萌比男神i
    2021-01-14 14:53

    If you're on .NET 3.5 and up, you need to check out the classes in System.DirectoryServices.ActiveDirectory for this. You need to look at classes like ActiveDirectorySchema and ActiveDirectorySchemaClass.

    You can get hold of the current AD schema by using:

    ActiveDirectorySchema currSchema = ActiveDirectorySchema.GetCurrentSchema();
    

    When you have the current schema, you can inspect the various class definitions, e.g.:

    ActiveDirectorySchemaClass userSchema = currSchema.FindClass("person");
    

    Once you have that object, you can inspect and enumerate its properties, things like:

    • MandatoryProperties
    • OptionalProperties

    and so on to get an insight into the AD schema.

提交回复
热议问题