Couple things I see.
 
LDAP_ADD_S (all of the LDAP calls) return a ULONG, not an INT. (assuming microsoft header library, other OS/Libs mileage may vary)
 
What is the value of location? I assume "test"? You shouldn't have different values for the name of the OU and the cn of the OU. This can cause quite a bit of confusion as many equate cn and name in the Microsoft world.
 
cnmod.mod_type should be set to "cn", not "ou". This is almost certainly generating your x22.
 
objectclass values should be ok with just organizationalUnit, shouldn't need to specify top as well.
 
For consistency your ocmod.mod_op should be set to LDAP_MOD_ADD instead of 0.
 
  joe
 
 
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Harpreet_Kapoor
Sent: Friday, August 13, 2004 3:34 AM
To: [EMAIL PROTECTED]
Subject: [ActiveDir] Creating an OU in ADAM

Hi guys,

 

I am trying to create an OU named “test” in ADAM under the root dc=abcd,dc=com.

For this ,I wrote the following code :

 

    LDAPMod cnmod, ocmod;

    LDAPMod *mods[3];

    char *cnvals[2], *ocvals[3];

 

    cnvals[0] = location;

    cnvals[1] = NULL;

    cnmod.mod_op = LDAP_MOD_ADD;

    cnmod.mod_type = "ou";

    cnmod.mod_values = cnvals;

    ocvals[0]="organizationalUnit";

    ocvals[1]="top";

    ocvals[2]=NULL;

    ocmod.mod_op = 0;

    ocmod.mod_type = "objectclass";

    ocmod.mod_values = ocvals;

    mods[0] = &cnmod;

    mods[1] = &ocmod;

    mods[2] = NULL;

 

    char *entry = "ou=test,dc=abcd,dc=com";

 

    int error = ldap_add_s(ld, entry, mods );

 

The error code returned is 34 or 0x22 which means that the “distinguished name has an invalid syntax”.

Do I not need to give in “entry” the string containing the entry to add?

What is wrong with this code ?

 

Thanks,

Harry

Reply via email to