[Date Prev][Date Next] [Chronological] [Thread] [Top]

Need help on a syntax error



Hello,

I'm trying to add a new entry to a ldap server with the c api. I have some
difficulties because the error messages I've got are not so clear.
With the code that follows I have an "Invalid Syntax" and I'm not able to
find the error.

Can someone help me on this please ?

LDAPMod *list_of_attrs[6];
LDAPMod attr1, attr2, attr3, attr4, attr5;
LDAPMessage *result;
int msgid, rc;

  FILE *fp;
  struct stat st;

  char *arl_data, *crl_data, *cac_data;
  struct berval arl_berval,crl_berval,cac_berval;
  struct berval *arl_values[2],*crl_values[2],*cac_values[2];

// Distinguished name of the entry
char *dn = "cn=Citizen CA/200503,ou=Belgium eID,dc=steria,dc=be";

attr1.mod_type = "objectClass";
attr1.mod_op = LDAP_MOD_REPLACE;
char *objectClass_values[] = { "top", "certificationAuthority",
"cRLDistributionPoint", NULL };
attr1.mod_values = objectClass_values;

attr2.mod_type = "cn";
attr2.mod_op = LDAP_MOD_REPLACE;
char *cn_values[] = { "Citizen CA/200503", NULL };
attr2.mod_values = cn_values;

attr3.mod_type = "authorityRevocationList;binary";
attr3.mod_op = LDAP_MOD_REPLACE | LDAP_MOD_BVALUES;
arl_berval.bv_len = st.st_size;
arl_berval.bv_val = arl_data; // arl_data is filled but I didn't put the
code in this example
arl_values[0] = &arl_berval;
arl_values[1] = NULL;
attr3.mod_bvalues = arl_values;

attr4.mod_type = "cACertificate;binary";
attr4.mod_op = LDAP_MOD_REPLACE | LDAP_MOD_BVALUES;
cac_berval.bv_len = st.st_size;
cac_berval.bv_val = cac_data; // cac_data is filled but I didn't put the
code in this example
cac_values[0] = &cac_berval;
cac_values[1] = NULL;
attr4.mod_bvalues = cac_values;

attr5.mod_type = "certificateRevocationList;binary";
attr5.mod_op = LDAP_MOD_REPLACE | LDAP_MOD_BVALUES;
crl_berval.bv_len = st.st_size;
crl_berval.bv_val = crl_data; // crl_data is filled but I didn't put the
code in this example
crl_values[0] = &crl_berval;
crl_values[1] = NULL;
attr5.mod_bvalues = crl_values;

// Add the pointers to these LDAPMod structures to an array
list_of_attrs[0] = &attr1;
list_of_attrs[1] = &attr2;
list_of_attrs[2] = &attr3;
list_of_attrs[3] = &attr4;
list_of_attrs[4] = &attr5;
list_of_attrs[5] = NULL;


      if((ulRet = ldap_add_s( m_LDAP, dn, list_of_attrs)) != LDAP_SUCCESS)
      {
       printf("ldap_add_s <%s>\n", ldap_err2string( ulRet));
       ldap_unbind( m_LDAP);
       return 1;
      }

Any advice would be appreciate, thanks in advance.

Christophe Senzot