Hello, I've been asked to write a script that queries several LDAP servers in sequence. It starts with an HTML form that passes the variables to a longish PERL script that I have to customize. The part I need help with is figuring out how the credentials are passed to the script. This is an example script from a vendor so some of the intricacies are lost on me. The "fill in the blanks" part is not an issue. I just don't get how to store the values in
my $your_text = $incoming{'username'};
and
my $your_text = $incoming{'campus'};
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, igled
#!/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 = "";

In reply to LDAP Script Question by eiglesias

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.