Project

General

Profile

« Previous | Next » 

Revision 2000

Removed unneeded Net::LDAP dependency. Now all authentication occurs
indirectly through Metacat.

View differences:

src/perl/register-dataset.cgi
33 33
use XML::LibXML;
34 34
use XML::LibXSLT;
35 35
use Template;
36
use Net::LDAP;
37 36
use Net::SMTP;
38 37
use CGI qw/:standard :html3/;
39 38
use strict;
......
670 669
    push(@invalidParams, "Data medium is missing.")
671 670
    unless (hasContent($FORM::dataMedium) || $FORM::dataMedium =~ /elect/);
672 671
    
673
    #if ($chkUser) {
674
        #my $errorUserPass = validateUserPass();
675
        #if ($errorUserPass ne "") {
676
            #push(@invalidParams, $errorUserPass);
677
        #}
678
    #}
679

  
680 672
    return \@invalidParams;
681 673
}
682 674

  
683 675
################################################################################
684 676
# 
685
# Validate the parameters username and password.
686
#
687
################################################################################
688
sub validateUserPass {
689
    my $userDN = $FORM::username;
690
    my $userOrg = $FORM::organization;
691
    my $userPass = $FORM::password;
692
    my $dname = "uid=$userDN,o=$userOrg,dc=ecoinformatics,dc=org";
693

  
694
    my $errorMessage = "";
695
    my $ldap = Net::LDAP->new($ldapUrl) or die "$@";
696
    my $bindresult = $ldap->bind( version => 3, dn => $dname, 
697
                                  password => $userPass );
698
    if ($bindresult->code) {
699
        $errorMessage = "Failed to log into metacat. Please check the username, organization and password entered";
700
        return $errorMessage;
701
    }
702
    return $errorMessage;
703
}
704

  
705

  
706
################################################################################
707
# 
708 677
# utility function to determine if a paramter is defined and not an empty string
709 678
#
710 679
################################################################################

Also available in: Unified diff