none
The server is unwilling to process the request. (Exception from HRESULT: 0x80072035)

    Question

  • Hi All,

    I am trying the sample code given at

    namespace ADAM_Examples
    {
        class ExtendSchemaContact
        {
            /// <summary>
            /// Extend AD LDS Schema with Contact Class
            ///  and Additional-Information Attribute.
            /// </summary>
            [STAThread]
            static void Main()
            {
                // Writeable attribute.
                const int DS_INSTANCETYPE_NC_IS_WRITEABLE = 4;

                DirectoryEntry objRoot;         // Root of AD LDS instance.
                DirectoryEntry objSchema;       // Schema partiton.
                string strSchemaNamingContext;  // Schema DN.

                // Get schema path.
                try
                {
                    objRoot = new DirectoryEntry(
                        "LDAP://localhost:389/RootDSE");
                    strSchemaNamingContext = objRoot.Properties[
                        "schemaNamingContext"].Value.ToString();
                    objSchema = new DirectoryEntry(String.Concat(
                        "LDAP://localhost:389/", strSchemaNamingContext));

                    Console.WriteLine("Schema path: {0}", objSchema.Path);
                    Console.WriteLine();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error:   Schema bind failed.");
                    Console.WriteLine("         {0}", e.Message);
                    return;
                }

                // Declarations for new attribute.
                // Attribute name.
                const string strAttributeName = "Additional-Information123";
                // New attribute.
                DirectoryEntry objNewAttribute;
                // Attribute CN.
                string strCNAttributeName;

                // Create new attribute.
                try
                {
                    strCNAttributeName = String.Concat("CN=",
                        strAttributeName);
                    objNewAttribute = objSchema.Children.Add(
                        strCNAttributeName, "attributeSchema");
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error:   Attribute create failed.");
                    Console.WriteLine("         {0}", e.Message);
                    return;
                }

                // Set selected values for attribute.
                try
                {
                    objNewAttribute.Properties[
                        "instanceType"].Add(DS_INSTANCETYPE_NC_IS_WRITEABLE);
                    objNewAttribute.Properties[
                        "attributeID"].Add("1.2.840.113556.1.4.265");
                    objNewAttribute.Properties[
                        "attributeSyntax"].Add("2.5.5.12");
                    objNewAttribute.Properties[
                        "isSingleValued"].Add(true);
                    objNewAttribute.Properties["rangeUpper"].Add(32768);
                    objNewAttribute.Properties[
                        "showInAdvancedViewOnly"].Add(true);
                    objNewAttribute.Properties[
                        "adminDisplayName"].Add(strAttributeName);
                    objNewAttribute.Properties[
                        "adminDescription"].Add(strAttributeName);
                    objNewAttribute.Properties["oMSyntax"].Add(64);
                    objNewAttribute.Properties["searchFlags"].Add(0);
                    objNewAttribute.Properties[
                        "lDAPDisplayName"].Add("notes");
                    objNewAttribute.Properties["name"].Add(strAttributeName);
                    objNewAttribute.Properties["systemOnly"].Add(false);
                    objNewAttribute.Properties["systemFlags"].Add(16);
                    objNewAttribute.Properties["objectCategory"].Add(
                        String.Concat("CN=Attribute-Schema,",
                        strSchemaNamingContext));
                    objNewAttribute.CommitChanges();  -> Exception comes up

                    Console.WriteLine(
                        "Success: Created attributeSchema class object:");
                    Console.WriteLine("         {0}", objNewAttribute.Name);
                }
                catch (Exception e)
                {
                    Console.WriteLine(
                        "Error:   Setting attribute properties failed.");
                    Console.WriteLine("         {0}", e.Message);
                    return;
                }

    }

    }

    to Add the Classes/Schema to AD using LDAP.

    I am using Windows Server 2008 Std. as OS.

    while executing the code of .NET. I am getting the exception as

    The server is unwilling to process the request. (Exception from HRESULT: 0x80072035)

    Can anyone help me!

    Thanks.

    Friday, May 28, 2010 6:28 AM

Answers