1
votes

I am trying to add value to attribute for user in LDAP. I have user "uid=testUser,ou=Local,ou=Type1,ou=People,dc=mnopid,dc=com"

For that user I have schema under "objectClass:inetOrgPerson" and attribute name is "mailid"

I have created LDAPMod structure. I am using ldap_add_ext API to add the attribute.

My code is in c language.

My code for addition part is (this is not complete code)

         #define CHANGE_DN = "uid=testUser,ou=Local,ou=Type1,ou=People,dc=mnopid,dc=com";

         LDAPMod *mods[2] ;
         LDAPMod modsattr ;
         int rc,msgid;

         char *mail[] = { "[email protected]",NULL };

         modsattr.mod_op = LDAP_MOD_ADD;
         modsattr.mod_type = "mailid";
         modsattr.mod_values = mail;

         mods[0]=&modsattr;
         mods[1]=NULL;

         rc = ldap_add_ext( ld, CHANGE_DN, mods, NULL, NULL ,&msgid );

All required data are properly defined.There are no compilation errors.

When I run the code I am getting error as "Object Class violation (65)

Please help.

1
the = in #define CHANGE_DN will certainly not help. I even wonder how that code compiles. If this is not the cause of your misfortunes, the error code you get means the request does not match your schema. Most likely a typo or a name confusion in your CHANGE_DN string. IIRC you should be able to get extended error informations to get a better idea of the cause of the violation (right now I can't remember how, but check the API just in case). Anyway, you have my sympathy for coping with this eyesore of a protocol. - kuroi neko
@kuroineko This 'eyesore of a protocol' is nevertheless extremely important in the world of IT, and your unsolicited opinion of it is entirely superfluous here. - user207421
@EJP oh, sorry, no offense was meant. I had to cope with it a few times and it left me painful memories. I never doubted its usefullness, though. - kuroi neko
@kuroi neko :- It was typo . there is no "=" while defining. - user3013022

1 Answers

1
votes

'inetOrgPerson' doesn't have a 'mailid' attribute. If you want to add arbitrary attributes you need to add the 'extensibleObject' class to the object's classes, which you can only do at creation time. Otherwise you need to use an attribute hat is actually allowed by the schema.