G
Guest
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
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