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

Object Class violation



Hi,

I'm not yet familiar with LDAP and I have an "object class violation" when
I try to add a binary entry to ldap. Can someone help me on this ?

Here is the code :

LDAPMod *list_of_attrs[2];
LDAPMod attr1, attr2, attr3;
LDAPMessage *result;
int msgid, rc;

  char *tmp_data;
  FILE *fp;
  struct stat st;

  struct berval tmp_berval;
  struct berval *tmp_values[2];

  // Get information about the file, including its size.
  if ( stat( "authorityRevocationList", &st ) != 0 )
  {
    printf( "stat error\n" );
    return 1;
  }

  // Open the file and read it.
  if ( ( fp = fopen( "authorityRevocationList", "rb" ) ) == NULL )
  {
    printf( "fopen error\n" );
    return 1;
  }

  if ( ( ( tmp_data = ( char * )malloc( st.st_size ) ) == NULL ) ||
         ( fread ( tmp_data, st.st_size, 1, fp ) != 1 ) )
  {
    printf( "fread error" );
    return 1;
  }

  fclose( fp );

// Distinguished name of the entry that you want to add.
char *dn = "cn=Citizen CA/200503,ou=Bel ID,dc=sria,dc=be";

attr1.mod_type = "authorityRevocationList;binary";
attr1.mod_op = LDAP_MOD_REPLACE | LDAP_MOD_BVALUES;
tmp_berval.bv_len = st.st_size;
tmp_berval.bv_val = tmp_data;
tmp_values[0] = &tmp_berval;
tmp_values[1] = NULL;
attr1.mod_bvalues = tmp_values;

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

// Add the pointers to array
list_of_attrs[0] = &attr1;
//list_of_attrs[1] = &attr2;
list_of_attrs[1] = NULL;

      // Add Entry
      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;
      }
________________________________________________________________________________________________

I've create an other entry manually on the ldap server and when I list all
the attributes, I have this :

dn: cn=Citizen CA/200501,ou=Bel ID,dc=sria,dc=be
        attribute: cn
                value: Citizen CA/200501
        attribute: objectClass
                value: cRLDistributionPoint
                value: certificationAuthority
                value: top
        attribute: authorityRevocationList;binary
        *H÷     value: 0l0V0
        attribute: cACertificate;binary
        *H÷     value: 0Ü0Ä n#T©ËÕ½1,y[@qöÙ0
        attribute: certificateRevocationList;binary
        *H÷     value: 0®00

Does it mean that I have to create an attribute "objectClass" as I did in
comments ? (with this I have a "Naming violation" error)
I think my problem is because I've never defined the objectclass but I
don't know where to do that.

Any advice would be appreciate, thanks in advance.

Christophe