System.DirectoryEntry - Adding new objects
I have recently been playing around with Apaches Directory Service, creating custom schema types and the like but came across a problem.
In VB.Net if I tried to add a new child to a directory entry, of a custom schema type (in this case in inherited from the person class) it would throw an exception when I tried to commit changes. On closer inspection I noticed that instead of creating an object of my custom schema class, it was trying to create an object of the person class, and the error being thrown by the LDAP server was because some of the properties I was trying to set did not exist for the Person class.
I managed to get around this by adding a property ‘objectClass’ and setting the value to the type of my custom schema class. This means that when I call commit changes, the LDAP server can validate it against that class.
AddUpdateProperty(newUser, "objectClass", "myUserClass") AddUpdateProperty(newUser, "mail", user.Email) AddUpdateProperty(newUser, "uid", user.ID)
Technorati Tags: LDAP, vb.net, directoryentry