Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Wrox Announcements and Feedback > All Other Wrox Books
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 23rd, 2003, 08:53 AM
Registered User
 
Join Date: Dec 2003
Location: , , .
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>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>

#include<lber.h>
#include<ldap.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");
     exit(EXIT_FAILURE);
    }
if(ldap_bind_s(ld,user_dn,user_pw,authmethod) != LDAP_SUCCESS)
    {
     ldap_perror(ld,"Failure of ldap_bind");
     exit(EXIT_FAILURE);
    }

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

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.