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

Object class violation error



Hello all,

when I try to add an entry with ldap_add_s() to the LDAP database via
following code I get the error "Object class violation".
For a modification with ldap_modify_s() I worked in a completely analog
way and I had no problems.

LdapResultCode LdapInterface::createUserProfile(std::string* username,
std::string* theNAI, std::string* e164Number, std::string* sCSCFpref)
{
  std::string dn;
  LDAPMod *mods[6];

  if (ld != 0){
      dn = "comm=jorisf@here.com,ou=COMM_DATA,o=here.com,c=BE";

      char *helpStr;

      mods[0] = (LDAPMod *)ber_alloc();
      mods[0]->mod_op = 0;
      mods[0]->mod_type = new char[80];
      strcpy(mods[0]->mod_type, attribObjectClass.c_str());
      //attribObjectClass = "objectclass"
      helpStr = "comm";
      mods[0]->mod_values = &helpStr;
      mods[0]->mod_values[1] = NULL;

      mods[1] = (LDAPMod *)ber_alloc();
      mods[1]->mod_op = 0;
      mods[1]->mod_type = new char[80];
      strcpy(mods[1]->mod_type, attribUsername.c_str());
      //attribUsername = "cn"
      if ((username == 0) || (username->length() == 0))
        { helpStr = NULL; }
      else
	{ helpStr = (char *)username.c_str(); }
      mods[1]->mod_values = &helpStr;
      mods[1]->mod_values[1] = NULL;

      mods[2] = (LDAPMod *)ber_alloc();
      mods[2]->mod_op = 0;
      mods[2]->mod_type = new char[80];
      strcpy(mods[2]->mod_type, attribNAI.c_str());
      //attribNAI = "NAI"
      if ((theNAI == 0) || (theNAI->length() == 0))
	{ helpStr = NULL; }
      else
	{ helpStr = (char *)theNAI->c_str(); }
      mods[2]->mod_values = &helpStr;
      mods[2]->mod_values[1] = NULL;
    
      mods[3] = (LDAPMod *)ber_alloc();
      mods[3]->mod_op = 0;
      mods[3]->mod_type = new char[80];
      strcpy(mods[3]->mod_type, attribE164.c_str());
      //attribE164 = "e164"
      if ((e164Number == 0) || (e164Number->length() == 0))
 	{ helpStr = NULL; }
      else
	{ helpStr = (char *)e164Number->c_str(); }
      mods[3]->mod_values = &helpStr;
      mods[3]->mod_values[1] = NULL;
    
      mods[4] = (LDAPMod *)ber_alloc();
      mods[4]->mod_op = 0;
      mods[4]->mod_type = new char[80];
      strcpy(mods[4]->mod_type, attribSCSCFpref.c_str());
      //attribSCSCFpref="prefServingCSCF"
      if ((sCSCFpref == 0) || (sCSCFpref->length() == 0))
        { helpStr = NULL; }
      else
	{ helpStr = (char *)sCSCFpref->c_str(); }
      mods[4]->mod_values = &helpStr;
      mods[4]->mod_values[1] = NULL;

      mods[5] = NULL;

      int rc = ldap_add_s(ld, (char *)dn.c_str(), mods);

      if (rc == LDAP_SUCCESS)
      { 
        printf("LDAP add successful\n");
        return ldap_Successful;
      }
   }
}

Somebody who has any idea what can be wrong ?

Regards,
Frank
begin:vcard 
n:Joris;Frank
x-mozilla-html:FALSE
org:Alcatel Telecom Antwerp;VE13 - NGN Multimedia
adr:;;;;;;
version:2.1
email;internet:jorisf@se.bel.alcatel.be
title:Switching Engineer
note:Tel: +32-3-240 4666
x-mozilla-cpt:;-31744
fn:Frank Joris
end:vcard