Search code examples
c#.netvb.netadlds

Get all writeable properties of an ADLDS-Class


I'm developing an application which can deal with a MS-ADLDS-Service. Currently it is possible to create Directory-Entries and assign values to some properties. Not a realy exciting task until this:

Im my application it's possible (it should be) to configure which properties of a class (for instance: the CN=Person class) should be assigned with values which are evaluated at runtime in my application.

Long story short: I want to retrieve all (writeable) properties of a class. Without creating and saving a new CN=Person-Object before.

Currently i use my schemaBinding to get the Directory-classSchema-Entry of the Person-Class (CN=Person) from where i read some property-values (like "AllowedAttributesEffective", "mayContain", "AllowedAttributes") - i get the most properties by this way - but some Properties are missing! For instance the "telephoneNumber"-Property (attributeSchema: CN=Telephone-Number)

Does anybody know how to get these properties of a class? ADSI-Edit does this: when i create a new object with adsi-edit i can assign values to all possible properties before committing the new entry.

thanks a lot for any hint!

(.net code is welcome)


Solution

  • I have found the solution for my task!

    Some of these properties are "calculated" and not persistent at the directoryentry. So its meant to call the RefreshCache() Method and pass the needed property names as an string array.

    directoryEntry.RefreshCache(new string[] { "allowedAttributesEffective",
                                                "allowedAttributes",
                                                "systemMayContain",
                                                "systemMustContain" });
    

    After that call, the properties have values....

    if (directoryEntry.Properties["systemMayContain"]).Value != null)
       {
        /// Success
       }