I highly recommend having your schema updates in LDIF files and have admins
execute the LDIF file versus writing code to insert schema mods. When I was an
ops guys I refused to run schema updates from vendors that way. If they didn't
have an LDIF file their app was thrown out.
Also your code is difficult to read, most likely if you used an LDIF file the
issue would be visible quite quickly.
joe
--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net
Muhammad Ali khan wrote:
> The Code is Given Below
>
> ULONG uErr = ldap_bind_s(psLdap ,NULL,NULL,LDAP_AUTH_NEGOTIATE);
>
> if( uErr == LDAP_SUCCESS )
> {
> int nVersion = LDAP_VERSION3;
> ldap_set_option( psLdap, LDAP_OPT_VERSION, &nVersion );
>
>
> int nChaseReferrals = 0;
> ldap_set_option( psLdap, LDAP_OPT_REFERRALS, &nChaseReferrals );
>
> // DN of new container
> char szNewDN[ 1024 ] ="Schema",CN=Configuration,DC=server,DC=COM";
> char* Object[] = { "classSchema",
> NULL };
> LDAPMod sAddObjectClass =
> {
> LDAP_MOD_ADD,
> "objectClass",
> Object
> };
>
> char* apszCNVals[] =
> {
> "ALIDATABANK1", // a single value for the cn attribute
> NULL
> };
>
> LDAPMod sAddCN =
> {
> LDAP_MOD_ADD, // the operation
> "cn", // the name of the attribute
> apszCNVals
> };
>
> char* LDAPName[] =
> {
> "alidatabank1",
> NULL
> };
>
> LDAPMod sAddLDAPName=
> {
> LDAP_MOD_ADD, // the operation
> "lDAPDisplayName", // the name of the attribute
> LDAPName
> };
> char* GovernsID[] =
> {
> "1.3.4.3.7.7.1564.4.2.1.9.2.38" , NULL
> };
>
> LDAPMod sAddGovernsID =
> {
> LDAP_MOD_ADD, // the operation
> "governsID", // the name of the attribute
> GovernsID
> };
>
> char* SubClassOf[] =
> {
> "top" , // a single value for the cn attribute
> NULL
> };
>
> LDAPMod sAddSubClassOf=
> {
> LDAP_MOD_ADD, // the operation
> "subClassOf", // the name of the attribute
> SubClassOf
> };
>
> // list of attributes to add
> LDAPMod* asAttrsToAdd[] =
> {
> &sAddObjectClass,
> &sAddCN,
> &sAddLDAPName,
> &sAddGovernsID,
> &sAddSubClassOf,
> NULL
> };
>
> uErr = ldap_add_s( psLdap, szNewDN, asAttrsToAdd );
>
>
>
> I wrote the following code but it gives me LDAP Error = 65 (Object Class
> Violation)
> Can you send me the sample code to create Active Directory Schema through
> LDAP
> or point out mistake in the above provided code