jarich has asked for the wisdom of the Perl Monks concerning the following question:
Currently we require the students to submit their PIN with every change to their details and hope that that can be avoided with the portal. The first time that the student comes in from the portal they'll hit a basic auth page and submit their username and password. From then on the portal will submit their details to my site and no further PIN or password will be needed.
Unfortunately their username will not be their student number, so I need to make an LDAP query to our LDAP server to get their student number based on their username. This is easy, I'm using perl-ldap version 0.26. (I did try perldap but had too much trouble getting it to install on our alpha machine).
The machine that our (Forte) database (with all the student's course details etc) is on is different from where we host the student service. Access for information and updates for changes are made by web requests over SSL. This is easy, I'm using the libwww-perl libraries version 5.65.
My problem is that I can very easily get the student's student number from LDAP or I can very easily access Forte, but for some reason I can't do both. Simplified code is as follows:
If I comment out use LDAP; and set $using_portal to false, everything works as it should, the $ua->request($req) takes some time and returns with code 200 (and any data I want). If I leave $using_portal false, but uncomment use LDAP; then when I attempt to connect to the Forte database the $ua->request($req) line returns immediately with error code 500.### Forte.pm package Forte; use LWP::UserAgent; $ENV{HTTPS_VERSION} = '3'; $ENV{HTTPS_CERT_FILE} = "some.crt"; $ENV{HTTPS_KEY_FILE} = "some.key"; sub callforte { ... my $ua = new LWP::UserAgent; my $req = new HTTP::Request("POST", "$url"); ... my $res = $ua->request($req); ... } #------------------------------------------ ### LDAP.pm package LDAP; use Net::LDAPS; sub LDAP_connect { .... my $conn = new Net::LDAPS($LDAPhost, port=>$LDAPport, clientcert=>$cert, clientkey=>$key); .... } sub get_student_number { LDAP_connect(); ... my $entry = $conn->search(filter=>"(uid=$username)", base=>$base, attrs=>[qw/studentnumber/]); if($entry->code()) { html_error("Search for student ID for [$username] fail +ed:". $entry->code() . "\n"); return 0; } ... return $entry->{attrs}{studentnumber}[0]; } #------------------------------------------ #### application use Forte; use LDAP; # test for connection to db: $return = Forte::callforte($url, $input); ... if($using_portal) { # get student number $student_number = LDAP::get_student_number($username); }
If I leave use LDAP; in my application but instead comment out use Net::LDAPS; in my LDAP package it works fine again, although obviously I won't be able to connect to LDAP.
Where do I even start with trying to work out what is making these two modules not play well together?
The dependencies (that I know about) and the versions I have installed are as follows:
All suggestions are appreciated. And thanks for reading this way-too-long question. :)
jarich
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mixing modules, LWP::UserAgent and Net::LDAPS not playing well together.
by PodMaster (Abbot) on Jul 30, 2002 at 08:55 UTC | |
by jarich (Curate) on Jul 31, 2002 at 01:48 UTC | |
by PodMaster (Abbot) on Jul 31, 2002 at 07:03 UTC |