eiglesias has asked for the wisdom of the Perl Monks concerning the following question:
andmy $your_text = $incoming{'username'};
Not to mention the password part I haven't added yet and store them for use by the rest of the script. Thanks for you help, igledmy $your_text = $incoming{'campus'};
#!/iiidb/software/tpp/perl/bin/perl -w use Net::LDAP; use Net::LDAPS; use strict; use CGI qw(unescape); use CGI::Carp qw(fatalsToBrowser); # #--------------------------------------------------------------------- +-- # This perl script is provided as an example for libraries that want t +o # employ Innovative's "plugin" model for External Patron Verification. # # The example script queries multiple LDAP servers depending on the ty +pe # of user, e.g. staff/faculty vs. student; campus1 vs. campus2; etc. # # This script is not intended to be "standalone" but is instead called + by # the Innovative checkLDAP script. # # Innovative provides this example script as a courtesy to libraries t +hat # have multiple LDAP servers. The library is responsible for customiz +ing # this script with local values, enhanced functionality, etc. #--------------------------------------------------------------------- +-- # my $debug = "yes"; open (DEBUG, ">>/tmp/checkLDAP_dlevy.log") if ($debug eq "yes"); # # LDAP connection information is stored in arrays of size 2. # The script assumes that the first location (0) in the array # contains the connection information for the student LDAP server, # i.e. the input extpatserver = student, if extpatserver = staff the # script uses the connection information from the second location (1) # in the following arrays. # If there is no value in extpatserver, the script queryies the studen +t # LDAP server. # These arrays should be initialized here with the real values. # To customize this script for you system, configure the following # arrays: # # m_sLDAPServer : contains the host domain name of the LDAP servers. # # m_nPort : specifies the port used to connect to the LDAP server. # # m_bUseLDAPS : set to 1 if you use a secure connection i.e. port 636, + # set to 0 if you use a non-secure connection. # m_sBindBase : contains a string that defines which database to use # on the LDAP server on the first bind command; # if empty use anonymous bind. # # m_sBindPassword : contains the password of the administrator account + # you use to bind. Set the password unencrypted, # i.e. use the string you received from the LDAP # adminstartor as it is. # m_sBindUser : set the login of the administartor account, or an empt +y string # # m_bUseOneBind: set to 1 if you use user's credentials to bind. # # m_sSearchAttribute : contains the primary search attribute to be use +d # (university ID, for example) when searching for # a given patron on the LDAP server. # # m_sSearchBase : contains the search DN used to retrieve user records +. # # m_sIDAttribute : contains the attribute in the data returned by the +LDAP # server which is used as the patron search key on th +e # Millennium server. # sub from_form { my %incoming = &read_input; # Read information into associated # array %incoming. my $your_text = $incoming{'username'}; # Fetch the text from the array +. print $your_text; # Print the text. #inserting code to get Domain my $your_text = $incoming{'campus'}; print $your_text; } sub read_input { my @pairs; my $buffer; my $pair; my $name; my $value; my %FORM; # Read in text $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/; if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } # Split information into name/value pairs @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%(..)/pack("C", hex($1))/eg; $FORM{$name} = $value; } %FORM; } sub LDAP_CCSU { my @m_sLDAPServer = ("",""); my @m_nPort = ("636",""); my @m_bUseLDAPS = ("1",""); my @m_sBindBase = ("BIND_BASE= dn=,dc=",""); my @m_sBindPassword = ("",""); my @m_sBindUser = ("",""); my @m_bUseOneBind = ("1"); my @m_sSearchAttribute = ("",""); #This is proboably going to need some work my @m_sSearchBase = ("search_base =, DC=,DC=",""); my @m_sIDAttribute = ("",""); } my $m_bUseLDAPPassword = 1; my $m_bTryMillenniumAfterBadVerify = 0; my @m_nTimeOut = (3,3); my $m_sLDAPVersion = 3; # # Input variables are stored in the following variables # my $m_sUserName = ""; my $m_sUserId = ""; my $m_sPassword = ""; my $m_sServer= ""; my $m_hLDAP; my $m_whichServer = 0; #Identifies which server to query by index, eit +her 0 or 1 my $m_hSearchMessage; my $m_bVerbose = 0; #my $m_bVerbose = 1; my $m_nTimeOut = 3; my $m_sOriginalUserId; my $m_sResult = "Failed"; my $m_sLogMessage = ""; my $m_sIIIDB = "";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LDAP Script Question
by kennethk (Abbot) on Nov 09, 2010 at 16:18 UTC | |
by eiglesias (Initiate) on Nov 09, 2010 at 17:28 UTC | |
by eiglesias (Initiate) on Nov 11, 2010 at 15:49 UTC |