Wrox Programmer Forums
All Other Wrox Books Do you have a question about a Wrox book that isn't listed anywhere on p2p.wrox.com or where the forum is locked? Here's a forum to post questions about any other Wrox book so that other readers or one of the authors can help you with your questions. IF YOU ARE LOOKING FOR CODE DO NOT ASK "Where can I find the code for this book?" That question is answered here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the All Other Wrox Books section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 23rd, 2003, 08:53 AM
Registered User
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ldap_Object class violation

in <<Professional linux programming>>,I ran into a prolem when build the program which gived by the book in chapter 7.6.1:#include<stdio.h>


int main()
LDAP *ld;
int res;

int authmethod = LDAP_AUTH_SIMPLE;
char *ldap_host = "localhost";
char *user_dn ="cn=root,o=hfut,c=edu.cn";
char *user_pw ="123456!";

char *new_dn ="cn=Jenny Stones,ou=People,o=hfut,c=edu.cn";

char *cn_vals[]={"Jenny Stones", NULL};
char *sn_vals[]={"Stones", NULL};
char *givenname_vals[] = {"Jenny", NULL};
char *uid_vals[] = {"stonesj", NULL};
char *title_vals[] = {"Programmer", NULL};
char *objectClass_vals[] = {"top","person", NULL};
char *ou_vals[] = {"Development","People", NULL};

LDAPMod cn_attribute,sn_attribute,givenname_attribute,uid_ attribute,
                    title_attribute,objectClass_attribute,ou_attribute ;

LDAPMod *mods;

cn_attribute.mod_op = LDAP_MOD_ADD;
cn_attribute.mod_type = "cn";
cn_attribute.mod_values = cn_vals;

sn_attribute.mod_op = LDAP_MOD_ADD;
sn_attribute.mod_type = "sn";
sn_attribute.mod_values = sn_vals;

givenname_attribute.mod_op = LDAP_MOD_ADD;
givenname_attribute.mod_type = "givenname";
givenname_attribute.mod_values = givenname_vals;

uid_attribute.mod_op = LDAP_MOD_ADD;
uid_attribute.mod_type = "uid";
uid_attribute.mod_values = uid_vals;

title_attribute.mod_op = LDAP_MOD_ADD;
title_attribute.mod_type = "title";
title_attribute.mod_values = title_vals;

objectClass_attribute.mod_op = LDAP_MOD_ADD;
objectClass_attribute.mod_type= "objectClass";
objectClass_attribute.mod_values = objectClass_vals;

ou_attribute.mod_op = LDAP_MOD_ADD;
ou_attribute.mod_type = "ou";
ou_attribute.mod_values = ou_vals;

mods[0] = &cn_attribute;
mods[1] = &sn_attribute;
mods[2] = &givenname_attribute;
mods[3] = &uid_attribute;
mods[4] = &title_attribute;
mods[5] = &objectClass_attribute;
mods[6] = &ou_attribute;
mods[7] = NULL;

if((ld = ldap_init(ldap_host,LDAP_PORT)) == NULL)
     perror("Failure of ldap_init");
if(ldap_bind_s(ld,user_dn,user_pw,authmethod) != LDAP_SUCCESS)
     ldap_perror(ld,"Failure of ldap_bind");

if(ldap_add_s(ld,new_dn,mods)!= LDAP_SUCCESS){
     ldap_perror(ld,"Failure of ldap_bind");
res = ldap_unbind_s(ld);
if(res != 0)
fprintf(stderr,"ldap_unbind_s failed: %s\n",ldap_err2string(res));

and the problem is :
Failure of ldap_bind: Object class violation
    additional info: entry has no objectClass attribute
    [[email protected] li]# ./ldap_add_one
    Failure of ldap_bind: Object class violation
    additional info: attribute 'givenName' not allowed
could you help me?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Concurrency Violation Exception Olorin ADO.NET 10 October 4th, 2007 12:21 PM
Concurrency Violation Problem - Please HELP! Aaron Edwards ASP.NET 2.0 Basics 0 March 25th, 2007 08:17 PM
Access Violation ? T-5 Beginning PHP 1 July 24th, 2004 09:29 PM
primary key violation muralikeane Classic ASP Databases 8 May 21st, 2004 09:24 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.