From: Daan K. <da...@nw...> - 2001-01-27 20:22:12
|
-----Original Message----- From: per...@li... [mailto:per...@li...]On Behalf Of per...@li... Sent: Saturday, January 27, 2001 2:04 PM To: per...@li... Subject: perl-ldap-dev digest, Vol 1 #199 - 5 msgs Send perl-ldap-dev mailing list submissions to per...@li... To subscribe or unsubscribe via the World Wide Web, visit http://lists.sourceforge.net/lists/listinfo/perl-ldap-dev or, via email, send a message with subject or body 'help' to per...@li... You can reach the person managing the list at per...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of perl-ldap-dev digest..." Today's Topics: 1. Re: Trouble adding jpeg image to Netscape 4.1 directory server via ldap (Ken DeLay) 2. Authentication problem (Rob Hawkes) 3. Help newbie (Guruprasad S) 4. Re: Authentication problem (Jim Harle) 5. Re: Authentication problem (Rob Hawkes) --__--__-- Message: 1 Date: Fri, 26 Jan 2001 13:09:18 -0700 To: Chris Ridd <chr...@me...>, Ken DeLay <ken...@sy...>, per...@li... From: Ken DeLay <ken...@sy...> Subject: Re: Trouble adding jpeg image to Netscape 4.1 directory server via ldap Thanks for the reply Chris. I have been working with both the Mozilla and perl-ldap code. My code was from an attempt to use the Mozilla code and so it was not appropriate to post here. I used your suggestion and rewrote the script to use the perl-ldap implementation and the jpeg photo went in just fine. Again, thanks for the help. Is it true the Mozilla LDAP library for perl is not being maintained anymore? Ken At 08:38 AM 01/26/2001 +0000, Chris Ridd wrote: >You *should* just be able to read the JPEG in and add it as a value to a >jpegPhoto attribute. > > > >You appear to be using the Mozilla LDAP library for perl called perldap >(which uses native libraries and is not pure perl), which apparently isn't >being maintained any more. This mailing list is for the native perl LDAP >library, called perl-ldap. > >So there might be a problem with the way the Mozilla LDAP code handles >values which aren't text and which aren't BER. This kind of stuff is no >problem in perl-ldap :-) > --__--__-- Message: 2 To: per...@li..., gb...@po... Subject: Authentication problem Reply-To: rob...@mo... Date: Sat, 27 Jan 2001 06:01:17 +0000 From: Rob Hawkes <ha...@wa...> It seems to be impossible to use the non-anonymous bind to do user authentication. No matter what kind of bogus password I send along with the DN, I get a successful bind. I have tried using lots of $ldap->unbind calls, getting a brand new connection, everything I can think of. What am I missing? Thank you. Rob Hawkes Motorola, Inc. ------------------------------------------------------------------------ #! /usr/local/bin/perl # Test driver. ldapAuth('rvpl50', 'xxx'); ######################################################################## # # l d a p A u t h # ######################################################################## sub ldapAuth { my($userid,$password) = @_; use strict; use Net::LDAP; my($ldap,$mesg); my $server = "directory.mot.com"; # First do an anonymous bind with $userid and retrieve the DN. $ldap = Net::LDAP->new($server); if (! $ldap) { print "DEBUG: failed to connect to $server\n"; return 0; } $ldap->bind; my $mesg = $ldap->search base => "o=Motorola,c=US", filter => "uid=$userid" ); if ($mesg->code) { print $mesg->error; return 0; } else { # Try with all entries to bind with the supplied password. foreach my $entry ($mesg->all_entries) { my $dn = $entry->dn; print "DEBUG: try to bind with DN= $dn, password= $password\n"; $ldap->unbind; if ($ldap = Net::LDAP->new('directory.mot.com')) { $ldap->bind( $dn, password => $password ); print "\n", $mesg->code, " ", $mesg->error, "\n"; if ($mesg->code) { # Bind failed. return 0; } else { # Bind succeeded. $mesg = $ldap->search base => "o=Motorola,c=US", filter => "uid=$userid" ); foreach my $entry ($mesg->all_entries) { $entry->dump; } $ldap->unbind; return 1; } } else { # Could not get a new connection. return 0; } } } } --__--__-- Message: 3 Date: Sat, 27 Jan 2001 01:44:55 -0700 From: "Guruprasad S" <sgu...@no...> To: <per...@li...> Subject: Help newbie Hi, I am running Perl5.6.0 on NT. Whenever I build with USE_MULTI uncommented = and USE_ITHREAD commented, I can access the directory. But when I = uncomment UCS_ITHREAD as well, my script fails by saying=20 decode error at c:/perl/site/5.6.0/lib/Convert/ASN1/_decode.pm line 136. 84 decode error at c:/perl/site/5.6.0/lib/Convert/ASN1/_decode.pm line 136. ...propagated at ldap1.pl line 12. Can any of you help me out. My script looks like this: use Net::LDAP; $ldap =3D Net::LDAP->new('blr-nb7.blr.novell.com') or die "$@"; $mesg =3D $ldap->bind or die "Failed to bind\n"; if ($mesg->code) { print $mesg->error, $mesg->code,"\n"; die; } $mesg =3D $ldap->search( # perform a search base =3D> "o=3Dnovell", filter =3D> "sn=3D*", ) or die "Failed to search\n"; if ($mesg->code) { print $mesg->error, $mesg->code,"\n"; die; } Thanks Guru --__--__-- Message: 4 Date: Sat, 27 Jan 2001 11:14:34 -0500 From: Jim Harle <ha...@us...> To: rob...@mo... CC: per...@li..., gb...@po... Subject: Re: Authentication problem Rob, These 2 consecutive lines are at issue: if ($ldap = Net::LDAP->new('directory.mot.com')) { $ldap->bind( $dn, password => $password ); The first is unnecessary, but doen't hurt, other than performance. The second needs to be preceded by $mesg = Your line does the bind, but doesn't store the result anywhere. --Jim Harle Rob Hawkes wrote: > It seems to be impossible to use the non-anonymous bind to do user > authentication. No matter what kind of bogus password I send along > with the DN, I get a successful bind. I have tried using lots of > $ldap->unbind calls, getting a brand new connection, everything I can > think of. What am I missing? Thank you. > > Rob Hawkes > Motorola, Inc. > > ------------------------------------------------------------------------ > > #! /usr/local/bin/perl > > # Test driver. > > ldapAuth('rvpl50', 'xxx'); > > ######################################################################## > # > # l d a p A u t h > # > ######################################################################## > > sub ldapAuth { > my($userid,$password) = @_; > > use strict; > use Net::LDAP; > > my($ldap,$mesg); > my $server = "directory.mot.com"; > > # First do an anonymous bind with $userid and retrieve the DN. > $ldap = Net::LDAP->new($server); > if (! $ldap) { > print "DEBUG: failed to connect to $server\n"; > return 0; > } > > $ldap->bind; > my $mesg = $ldap->search ( > base => "o=Motorola,c=US", > filter => "uid=$userid" > ); > if ($mesg->code) { > print $mesg->error; > return 0; > } > else { > # Try with all entries to bind with the supplied password. > foreach my $entry ($mesg->all_entries) { > my $dn = $entry->dn; > print "DEBUG: try to bind with DN= $dn, password= $password\n"; > $ldap->unbind; > > if ($ldap = Net::LDAP->new('directory.mot.com')) { > $ldap->bind( $dn, password => $password ); > > print "\n", $mesg->code, " ", $mesg->error, "\n"; > > if ($mesg->code) { > # Bind failed. > return 0; > } > else { > # Bind succeeded. > $mesg = $ldap->search ( > base => "o=Motorola,c=US", > filter => "uid=$userid" > ); > > foreach my $entry ($mesg->all_entries) { > $entry->dump; > } > > $ldap->unbind; > return 1; > } > } > else { > # Could not get a new connection. > return 0; > } > } > } > } --__--__-- Message: 5 Date: Sat, 27 Jan 2001 09:40:03 -0700 From: Rob Hawkes <rob...@mo...> Organization: Motorola, Inc. To: Jim Harle <ha...@us...> CC: per...@li..., gb...@po... Subject: Re: Authentication problem Jim, Thank you for responding. I found the problem early this morning and have been feeling like a bozo ever since. Guess I should have slept on it before bothering the list. Thanks again. Rob Jim Harle wrote: > > Rob, > These 2 consecutive lines are at issue: > > if ($ldap = Net::LDAP->new('directory.mot.com')) { > $ldap->bind( $dn, password => $password ); > > The first is unnecessary, but doen't hurt, other than performance. The second needs to be > preceded by > $mesg = > Your line does the bind, but doesn't store the result anywhere. > > --Jim Harle > > Rob Hawkes wrote: > > > It seems to be impossible to use the non-anonymous bind to do user > > authentication. No matter what kind of bogus password I send along > > with the DN, I get a successful bind. I have tried using lots of > > $ldap->unbind calls, getting a brand new connection, everything I can > > think of. What am I missing? Thank you. > > > > Rob Hawkes > > Motorola, Inc. > > > > ------------------------------------------------------------------------ > > > > #! /usr/local/bin/perl > > > > # Test driver. > > > > ldapAuth('rvpl50', 'xxx'); > > > > ######################################################################## > > # > > # l d a p A u t h > > # > > ######################################################################## > > > > sub ldapAuth { > > my($userid,$password) = @_; > > > > use strict; > > use Net::LDAP; > > > > my($ldap,$mesg); > > my $server = "directory.mot.com"; > > > > # First do an anonymous bind with $userid and retrieve the DN. > > $ldap = Net::LDAP->new($server); > > if (! $ldap) { > > print "DEBUG: failed to connect to $server\n"; > > return 0; > > } > > > > $ldap->bind; > > my $mesg = $ldap->search ( > > base => "o=Motorola,c=US", > > filter => "uid=$userid" > > ); > > if ($mesg->code) { > > print $mesg->error; > > return 0; > > } > > else { > > # Try with all entries to bind with the supplied password. > > foreach my $entry ($mesg->all_entries) { > > my $dn = $entry->dn; > > print "DEBUG: try to bind with DN= $dn, password= $password\n"; > > $ldap->unbind; > > > > if ($ldap = Net::LDAP->new('directory.mot.com')) { > > $ldap->bind( $dn, password => $password ); > > > > print "\n", $mesg->code, " ", $mesg->error, "\n"; > > > > if ($mesg->code) { > > # Bind failed. > > return 0; > > } > > else { > > # Bind succeeded. > > $mesg = $ldap->search ( > > base => "o=Motorola,c=US", > > filter => "uid=$userid" > > ); > > > > foreach my $entry ($mesg->all_entries) { > > $entry->dump; > > } > > > > $ldap->unbind; > > return 1; > > } > > } > > else { > > # Could not get a new connection. > > return 0; > > } > > } > > } > > } --__--__-- _______________________________________________ perl-ldap-dev mailing list per...@li... http://lists.sourceforge.net/lists/listinfo/perl-ldap-dev End of perl-ldap-dev Digest |