How to get attribute type from Active Directory

  • Thread starter Thread starter shashank kadge
  • Start date Start date
S

shashank kadge

hello experts,
I want to get attribute type (whether single value or multivalue) from
AD forest/domain.
Does any1 know how to get that.
Or at least how to get AD schema using C#.

Any help/links wud be appreciated.

thanks,
shashank kadge
 
shashank kadge said:
hello experts,
I want to get attribute type (whether single value or multivalue) from
AD forest/domain.
Does any1 know how to get that.
Or at least how to get AD schema using C#.

Any help/links wud be appreciated.

thanks,
shashank kadge


Search MSDN for System.DirectoryServices.ActiveDirectory and ADSI.
Following is a small snip to illustrate the process...
....
// property to look at
string cn = "cn";
// bind to the directory server (bind to the DC) with appropriate credentials.
DirectoryContext dc = new DirectoryContext(DirectoryContextType.DirectoryServer,
"somedomainsDC", "domaindmin", "hisPwd");
// Get the schema from the context you are binding with.
ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(dc);
// find the property (attribute in LDAP parlance).
ActiveDirectorySchemaProperty prop = schema.FindProperty(cn);
// show some of it's properties
Console.WriteLine("{0} - {1} - {2}", prop.Name, prop.Syntax, prop.IsSingleValued);

Willy.
 
Back
Top