From: Jie G. <J....@is...> - 2000-08-29 23:10:47
|
Hi All, I have been trying to use Net::LDAP within mod_perl, and have encountered the following: 1. Getting a message upon starting Apache: Constant subroutine cTAG redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine cTYPE redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine cVAR redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine cLOOP redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine cOPT redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine cCHILD redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opUNKNOWN redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opBOOLEAN redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opINTEGER redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opBITSTR redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opSTRING redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opNULL redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opOBJID redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opREAL redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opSEQUENCE redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opSET redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opUTIME redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opGTIME redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opUTF8 redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opANY redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. Constant subroutine opCHOICE redefined at /usr/local/lib/perl5/site_perl/5.005/Convert/ASN1.pm line 47. I know this is only used by Net::LDAP on this server. What was it that caused this? 2. Getting wrong returned results intermittently, or with a pattern (every a few clicks). Debugging shows that password is to sent every time: Here's the debugging output of a "bad" access: --------------------------------------------------------------------------- Net::LDAP=HASH(0x982aa4) sending: 30 3E 02 01 04 60 39 02 01 02 04 32 6C 6F 67 69 0>...`9....2logi 6E 6E 61 6D 65 3D 68 61 6E 64 79 6D 61 6E 2C 6F nname=handyman,o 75 3D 70 65 6F 70 6C 65 2C 64 63 3D 75 63 63 2C u=people,dc=ucc, 64 63 3D 75 73 79 64 2E 65 64 75 2E 61 75 80 00 dc=usyd.edu.au.. 0000 30 62: SEQUENCE { 0002 02 1: INTEGER = 4 0005 60 57: [APPLICATION 0] { 0007 02 1: INTEGER = 2 000A 04 50: STRING = 'loginname=handyman,ou=people,dc=ucc,dc=usyd.edu.au' 003E 80 0: [CONTEXT 0] 0040 : } 0040 : } Net::LDAP=HASH(0x982aa4) received: 30 0C 02 01 04 61 07 0A 01 00 04 00 04 00 __ __ 0....a........ 0000 30 12: SEQUENCE { 0002 02 1: INTEGER = 4 0005 61 7: [APPLICATION 1] { 0007 0A 1: ENUM = 0 000A 04 0: STRING = '' 000C 04 0: STRING = '' 000E : } 000E : } Net::LDAP=HASH(0x982aa4) sending: 30 53 02 01 05 6E 4E 04 30 6C 6F 67 69 6E 6E 61 0S...nN.0loginna 6D 65 3D 6A 69 65 67 61 6F 2C 6F 75 3D 70 65 6F me=jiegao,ou=peo 70 6C 65 2C 64 63 3D 75 63 63 2C 64 63 3D 75 73 ple,dc=ucc,dc=us 79 64 2E 65 64 75 2E 61 75 30 1A 04 07 63 6F 75 yd.edu.au0...cou 72 73 65 73 04 0F 32 30 30 30 3A 70 63 6F 6C 32 rses..2000:pcol2 30 30 31 3A 31 __ __ __ __ __ __ __ __ __ __ __ 001:1 0000 30 83: SEQUENCE { 0002 02 1: INTEGER = 5 0005 6E 78: [APPLICATION 14] { 0007 04 48: STRING = 'loginname=jiegao,ou=people,dc=ucc,dc=usyd.edu.au' 0039 30 26: SEQUENCE { 003B 04 7: STRING = 'courses' 0044 04 15: STRING = '2000:pcol2001:1' 0055 : } 0055 : } 0055 : } Net::LDAP=HASH(0x982aa4) received: 30 0C 02 01 05 6F 07 0A 01 32 04 00 04 00 __ __ 0....o...2.... 0000 30 12: SEQUENCE { 0002 02 1: INTEGER = 5 0005 6F 7: [APPLICATION 15] { 0007 0A 1: ENUM = 50 000A 04 0: STRING = '' 000C 04 0: STRING = '' 000E : } 000E : } status: The client does not have sufficient access to perform the requested operation --------------------------------------------------------------------------- With a "good" access, I would see the password there, and the compare operation would return ENUM = 6. Here's the subroutine that I use in a mod_perl handler: --------------------------------------------------------------------------- sub get_crs_enrol_status ($$$) { my ($self, $r, @crs_allowed) = @_; my $status = ''; my $debug = $r->dir_config("AuthCookieDebug") || 0; my $user = $r->connection->user; #$user = 'jcho1625'; my $ldap = Net::LDAP->new('directory.usyd.edu.au', debug => 255) or die "$@"; my $mesg = $ldap->bind( dn => 'loginname=handyman,ou=people,dc=ucc,dc=usyd.edu.au', password => 'test' ); #warn ldap_error_text($mesg->code) if $mesg->code; my $dn = "loginname=$user,ou=people,dc=ucc,dc=usyd.edu.au"; foreach my $i (@crs_allowed) { my $mesg_inner = $ldap->compare ( $dn, attr => 'courses', value => "$i" ); $status = ldap_error_text($mesg_inner->code) if $mesg_inner->code; if (defined $status && $status =~ /given is in/i) { print STDERR "status: $status\n"; $status = 'Yes'; print STDERR "$user is enrolled in $i\n" if $debug; last; } elsif (defined $status && $status =~ /not/) { print STDERR "status: $status\n"; $status = ''; print STDERR "$user is NOT enrolled in $i\n" if $debug; } } $mesg = $ldap->unbind; #warn ldap_error_text($mesg->code) if $mesg->code; if (defined $status && $status) { $status = ''; return 'Yes'; } else { return 'No'; } } --------------------------------------------------------------------------- I can't see anything wrong here, and there doesn't seem to be a closure problem in particular. Any help is appreciated. Jie |