我使用其API编写一个openLDAP客户端来添加基数dn。但是在程序运行时会发生错误:
tongue.png
我的代码如下:
ldap_add: Type or value exists (20)
additional info: attribute 'objectClass' provided more than once
我的代码出了什么问题?
答案 0 :(得分:0)
char *objVals1[] = {"organization",NULL};
char *objVals2[] = {"dcObject",NULL};
char *dcVals[] = {"jc",NULL};
char *oVals[] = {"jc Inc",NULL};
LDAPMod add1 = {LDAP_MOD_ADD,"objectClass",objVals1};
LDAPMod add2 = {LDAP_MOD_ADD,"objectClass",objVals2};
您将objectClass
添加为两个单独的属性,每个属性都有一个值。它是一个多值属性,与LDAP中的大多数属性一样,应该像这样添加:
char *objVals1[] = {"organization", "dcObject",NULL};
// ...
LDAPMod add1 = {LDAP_MOD_ADD,"objectClass",objVals1};