From: Graham B. <gb...@po...> - 2000-06-13 19:37:13
|
83 is an LDAP_ENCODING_ERROR object is the name of the element in the ASN packet that is currently being encoded and causing the problem. The "object" is the dn, which by looking at your code is undef, which is your problem. I think you want $entry, but you could just pass $entr as modify will accept an ::Entry object for the dn. Graham. PS: Yes there are still places where error reporting needs to be improved. But if you ever get LDAP_ENCODING_ERROR then it is worth double-checking the args passed. On Tue, Jun 13, 2000 at 10:38:48AM -0700, Yann Ramin wrote: > Hi, > Ok, I'm back and have a perplexing question to answer. The code below > is supposed to add a user to a group, but dies in a funny error. I have > the program output: > > # ./X11UInfo > Entry: cn=Student, ou=System Groups, ou=Groups, dc=montereyhigh, dc=com > User: cn=He He, dc=montereyhigh,dc=com > 83 object at /usr/lib/perl5/site_perl/5.6.0/Convert/ASN1/_encode.pm line > 47. > > > > And code: > > sub add_user_to_group { > my ($self, $user, $group) = @_; > > if ($self->user_in_group($user, $group) != 1) { > # Already there my friend :) > return 1; > } > > my $mesg = $self->{LDAP}->search ( # perform a search > base => "ou=Groups, ".$self->{ldap_config_base}, > filter => "(&(cn=".$group.")(objectclass=groupofNames))" > ); > my @entries = $mesg->entries; > my $entr = @entries[0]; > my $entry = $entr->dn; > > print "Entry: $entry\nUser: $user\n"; > my $mesg = $self->{LDAP}->modify($dn, > changes => [ > add => [ member => $user > ] > ] > ); > if ($mesg->code) { > print $mesg->code." ".$mesg->error; > return 1; > } > return 0; > > > } > > > > -- > > -------------------------------------------------------------------- > Yann Ramin at...@at... > Atrus Trivalie Productions www.redshift.com/~yramin > Monterey High IT www.montereyhigh.com > ICQ 46805627 > AIM oddatrus > Marina, CA > > "All cats die. Socrates is dead. Therefore Socrates is a cat." > - The Logician > > # fortune > "To be responsive at this time, though I will simply say, and therefore > this is a repeat of what I said previously, that which I am unable to > offer in response is based on information available to make no such > statement." > -------------------------------------------------------------------- > |