in reply to Re: LDAP Script Question
in thread LDAP Script Question

Thank you. It is my lack of perl skills that is to blame. I will try rewriting it with CGI param.

Replies are listed 'Best First'.
Re^3: LDAP Script Question
by eiglesias (Initiate) on Nov 11, 2010 at 15:49 UTC
    Thanks to kennethk I rewrote the script using CGI params. It is much cleaner now but I am struggling with how to call the subroutines. Can someone tell me if I am doing this correctly? Thanks, EI
    #!/iiidb/software/tpp/perl/bin/perl -wT use Net::LDAP; use Net::LDAPS; use strict; use CGI qw(unescape); use CGI::Carp qw(fatalsToBrowser); #This subroutine gets the data from the form sub from_form { my $data = param('username'); my $password = param('password'); my $campus = param('campus'); } #This checks the domain. Still need to get it to invoke the right ser +ver. sub domain { if ($campus = param('campus') =~ m/ccsu/) { return &LDAP_CCSU } elsif ($campus = param('campus') =~ m/ecsu/) { return &LDAP_ECSU } elsif ($campus = param('campus') =~ m/wcsu/) { return &LDAP_WCSU } elsif ($campus = param('campus') =~ m/southernct/) { return &LDAP_SCSU } else { print "Not a valid domain \n."; } } sub LDAP_CCSU { my @m_sLDAPServer = ("",""); my @m_nPort = ("",""); my @m_bUseLDAPS = ("1",""); my @m_sBindBase = ("BIND_BASE= ",""); my @m_sBindPassword = ("",""); my @m_sBindUser = ("",""); my @m_bUseOneBind = ("1"); my @m_sSearchAttribute = ("",""); my @m_sSearchBase = ("",""); my @m_sIDAttribute = ("",""); } sub LDAP_ECSU { my @m_sLDAPServer = ("",""); my @m_nPort = ("",""); my @m_bUseLDAPS = ("1",""); my @m_sBindBase = ("BIND_BASE= ",""); my @m_sBindPassword = ("",""); my @m_sBindUser = ("",""); my @m_bUseOneBind = ("1"); my @m_sSearchAttribute = ("",""); my @m_sSearchBase = ("",""); my @m_sIDAttribute = ("",""); } sub LDAP_SCSU { my @m_sLDAPServer = ("",""); my @m_nPort = ("",""); my @m_bUseLDAPS = ("1",""); my @m_sBindBase = ("BIND_BASE= ",""); my @m_sBindPassword = ("",""); my @m_sBindUser = ("",""); my @m_bUseOneBind = ("1"); my @m_sSearchAttribute = ("",""); my @m_sSearchBase = ("",""); my @m_sIDAttribute = ("",""); } sub LDAP_WCSU { my @m_sLDAPServer = ("",""); my @m_nPort = ("",""); my @m_bUseLDAPS = ("1",""); my @m_sBindBase = ("BIND_BASE= ",""); my @m_sBindPassword = ("",""); my @m_sBindUser = ("",""); my @m_bUseOneBind = ("1"); my @m_sSearchAttribute = ("",""); my @m_sSearchBase = ("",""); 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 = "$username$campus"; my $m_sUserId = "$password"; 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 = "";