I would like to modify the Active Directory schema. Does anyone know of effective sample code or instruction to accomplish this with .NET?
Basically, I need to do two things: 1. Create custom properties (or modify the existing custom properties already defined) on the ‘user’ schema and elsewhere in Active Directory. 2. Create new nodes with custom properties on the ‘user’ schema and elsewhere in Active Directory. However, I don’t want the property fields to accept bogus entries. I want to enforce that the property fields are used for a specific set of enumerated names and values. For example: DirectoryEntry deUserColorNode = new DirectoryEntry(“LDAP://cn=somewhere under user” + “. . . dc=whatever . . .”); // add “Sky Color = blue” should work OK deUserColorNode.Properties[“Sky Color”].Add(“blue”); // add “Eye Color = brown” should work OK deUserColorNode.Properties[“Eye Color”].Add(“brown”); deUserColorNode.CommitChanges(); // OK - We’re cool! // add “Sky Color = green” should throw an exception with // ex.message = green is not a valid color value for the // Sky Color attribute. deUserColorNode.Properties[“Sky Color”].Add(“blue”); // add “BoBo = Clown” should throw an exception with // ex.message = BoBo is not a valid color property // name and Clown is not a valid color value. deUserColorNode.Properties[“BoBo”].Add(“clown”) deUserColorNode.CommitChanges(); // should go BOOM! This is similar (I think) to Active Directory modifications made by Exchange 2000 (i.e., during setup/ForestPrep and setup/DomainPrep). Is there a ‘clean’ way to do this with .NET? Do I have to use interop to COM? I’ve found several good articles in MSDN; unfortunately, most of them seem to suffer from bad links, and none dealt clearly extending the schema with .NET. Any suggestions? Thanks, Ray You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.