PC Review


Reply
Thread Tools Rate Thread

Adding Class in Active Directory Schema through LDAP

 
 
=?Utf-8?B?TXVoYW1tYWQgQWxpIGtoYW4=?=
Guest
Posts: n/a
 
      21st Mar 2005
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
 
Reply With Quote
 
 
 
 
Joe Richards [MVP]
Guest
Posts: n/a
 
      26th Mar 2005
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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a user to an LDAP Active Directory Group? Error A referral wasreturned from the server jc Microsoft C# .NET 0 16th May 2008 02:45 PM
[Active Directory] On what ground does LDAP connect to Active Directory RTT Microsoft VB .NET 0 12th Apr 2005 04:20 PM
How to extend Active Directory Schema through LDAP APi =?Utf-8?B?TXVoYW1tYWQgQWxpIGtoYW4=?= Microsoft Windows 2000 Active Directory 1 23rd Mar 2005 08:25 AM
how to extend Active directory Schema through LDAP API =?Utf-8?B?TXVoYW1tYWQgQWxpIGtoYW4=?= Microsoft Windows 2000 Active Directory 1 19th Mar 2005 07:44 AM
Moving From Novell LDAP (NLDAP) To Active Directory LDAP =?Utf-8?B?U3RlcGhlbiBNb29yZQ==?= Microsoft Windows 2000 Active Directory 1 27th Apr 2004 12:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:29 AM.