Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

Regarding Schema Extending using S.DS.AD

Last post 06-27-2008, 1:42 AM by joe. 1 replies.
Sort Posts: Previous Next
  •  06-25-2008, 8:38 AM 4030

    Regarding Schema Extending using S.DS.AD

    Dear Joe,

       I want to add one or two attributes in the user object. So I read "Introduction to S.DS.AD" arcticle by Ethan Wilansky from msdn "http://msdn.microsoft.com/en-us/library/bb267453(printer).aspx#sdsadintro_topic3_manageschema". There i found the examples to extend the schema . But it does not extend schema and it throws error "The Current Security context is not associated with an active directory or domain forest" .

    Here is the code please help me to do this.

    static string ExtendingSchema()

    {

    DirectoryContext domainContext;

    ActiveDirectorySchemaProperty biometricAttribute;

    string result = "";

    domainContext = new DirectoryContext(DirectoryContextType.Domain );

    try

    {

    Domain dc = Domain.GetDomain(domainContext);

    biometricAttribute = new ActiveDirectorySchemaProperty(domainContext, "techconetBiometric");

    biometricAttribute.CommonName = "Techconet-Biometric";

    biometricAttribute.Oid = "1.2.840.113556.1.4.7000.233.28688.28684.8.145234.1728134.2034934.1932637.1";

    biometricAttribute.IsSingleValued = true;

    biometricAttribute.IsIndexed = true;

    biometricAttribute.IsInGlobalCatalog = true;

    biometricAttribute.SchemaGuid = new Guid();

    biometricAttribute.Syntax = ActiveDirectorySyntax.CaseExactString;

    biometricAttribute.Save();

    result = "true";

    Console.WriteLine("Extending Attribute : "+result );

    }

    catch (Exception ex)

    {

    result = "The Attribute was not created : " + ex.Message;

    Console.WriteLine("The Attribute was not created : " + ex.Message );

    }

    if (result == "true")

    {

    try

    {

    ActiveDirectorySchemaClass adSchemaClass = ActiveDirectorySchemaClass.FindByName(domainContext, "User");

    adSchemaClass.OptionalProperties.Add(ActiveDirectorySchemaProperty.FindByName(domainContext, "techconetBiometric"));

    result = "";

    adSchemaClass.Save();

    result = "true";

    Console.WriteLine("Adding Attribute to user class : " + result);

    }

    catch(Exception ex)

    {

    result = "The Attribute was not add to USER class : " + ex.Message ;

    Console.WriteLine("The Attribute was not add to USER class : " + ex.Message );

    }

    }

    return result;

    }

    Thanks With Regards,

    DeviMurugan

  •  06-27-2008, 1:42 AM 4054 in reply to 4030

    Re: Regarding Schema Extending using S.DS.AD

    Did you call RefreshSchema after you were done?

    Generally, I don't recommend using code to extend the schema (alway use LDIF files for repeatability and transparency since admins will usually want to know what you are doing), but you can do this in code if you really need to.

View as RSS news feed in XML