From: Yann R. <at...@at...> - 2000-06-13 17:42:09
|
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." -------------------------------------------------------------------- |
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." > -------------------------------------------------------------------- > |
From: Yann R. <at...@at...> - 2000-06-13 19:47:29
|
Graham Barr wrote: > > 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. > This is the second time I've had this problem in a day and can't seem to pick it up :) Obviously I'm passing an undef, its right there in front of me. I promise not to complain it doesn't work until I've undergone several hours of torment figuring out what is going wrong :) (I only played with this one for one hour going through every permutation of modify :)) > 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. ------------------------------------------------------ > > -- -------------------------------------------------------------------- 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." -------------------------------------------------------------------- |
From: Graham B. <gb...@po...> - 2000-06-13 20:25:33
|
On Tue, Jun 13, 2000 at 12:43:30PM -0700, Yann Ramin wrote: > Graham Barr wrote: > > > > 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. > > > > > This is the second time I've had this problem in a day and can't seem to > pick it up :) Obviously I'm passing an undef, its right there in front > of me. I promise not to complain it doesn't work until I've undergone > several hours of torment figuring out what is going wrong :) (I only > played with this one for one hour going through every permutation of > modify :)) Hey, don't worry about it. At least you are highlighting where we need to do some work :) But I do suggest you use Net::LDAP::Util a bit more for diagnostics. Graham. |
From: Jim H. <ha...@us...> - 2000-06-13 19:37:17
|
The problem with the returned error looking strange is with your printing $mesg->error instead of Net::LDAP::Util::ldap_error_text($mesg->code). --Jim Harle US Naval Academy On Tue, 13 Jun 2000, 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." > -------------------------------------------------------------------- > > |