Project

General

Profile

« Previous | Next » 

Revision 4866

Added by walbridge over 15 years ago

- fix error reporting for failed password reset request
- automatically generate necessary LDAP parameters from our defaults,
included in auth.base and unaffiliated properties. This won't work for
skins such as UCNRS with a different base, which still need to be
included explicitly within metacat.properties.

View differences:

src/perl/ldapweb.cgi
162 162
    push(@orgList, $oKey);
163 163
}
164 164

  
165
my $authBase = $properties->getProperty("auth.base");
165 166
my $ldapConfig;
166 167
foreach my $o (@orgList) {
167 168
    foreach my $d (@orgData) {
168 169
        $ldapConfig->{$o}{$d} = $properties->getProperty("organization.$d.$o");
169 170
    }
170
    # also include DN, which is just org + base
171
    if ($ldapConfig->{$o}{'org'}) {
172
        $ldapConfig->{$o}{'dn'} = $ldapConfig->{$o}{'org'} . "," . $ldapConfig->{$o}{'base'};
171

  
172
    # set default base
173
    if (!$ldapConfig->{$o}{'base'}) {
174
        $ldapConfig->{$o}{'base'} = $authBase;
175
    }
176

  
177
    # include filter information. By default, our filters are 'o=$name', e.g. 'o=NAPIER'
178
    # these can be overridden by specifying them in metacat.properties. Non-default configs
179
    # such as UCNRS must specify all LDAP properties.
180
    if ($ldapConfig->{$o}{'base'} eq $authBase) {
181
        my $filter = "o=$o";
182
        if (!$ldapConfig->{$o}{'org'}) {
183
            $ldapConfig->{$o}{'org'} = $filter;
184
        }
185
        if (!$ldapConfig->{$o}{'filter'}) {
186
            $ldapConfig->{$o}{'filter'} = $filter;
187
        }
188
        # also include DN, which is just org + base
189
        if ($ldapConfig->{$o}{'org'}) {
190
            $ldapConfig->{$o}{'dn'} = $ldapConfig->{$o}{'org'} . "," . $ldapConfig->{$o}{'base'};
191
        }
173 192
    } else {
174 193
        $ldapConfig->{$o}{'dn'} = $ldapConfig->{$o}{'base'};
175 194
    }
176 195

  
177
    # include filter information. By default, our filters are 'o=$name', e.g. 'o=NAPIER'
178
    # these can be overridden by specifying them in metacat.properties.
179
    if (!$ldapConfig->{$o}{'filter'}) {
180
        $ldapConfig->{$o}{'filter'} = "o=$o";
196
    if (!$ldapConfig->{$o}{'user'}) {
197
        $ldapConfig->{$o}{'user'} = $ldapConfig->{'unaffiliated'}{'user'};
181 198
    }
199

  
200
    if (!$ldapConfig->{$o}{'password'}) {
201
        $ldapConfig->{$o}{'password'} = $ldapConfig->{'unaffiliated'}{'password'};
202
    }
182 203
}
183 204

  
184 205
#--------------------------------------------------------------------------80c->
......
445 466
    # We have all of the info we need, so try to change the password
446 467
    my $o = $query->param('o');
447 468
    my $dn = "uid=" . $query->param('uid') . "," . $ldapConfig->{$o}{'dn'};
469
    debug("handleResetPassword: dn: $dn");
448 470
    if ($query->param('o') =~ "LTER") {
449 471
        fullTemplate( ['registerLter'] );
450 472
        exit();
......
539 561
    	# Find the user here and change their entry
540 562
    	my $newpass = createSeededPassHash($userPass);
541 563
    	my $modifications = { userPassword => $newpass };
564
        debug("changePass: setting password for $userDN to $newpass");
542 565
    	my $result = $ldap->modify( $userDN, replace => { %$modifications });
543 566
    
544 567
    	if ($result->code()) {
545
        	my $errorMessage = "There was an error changing the password." .
568
            debug("changePass: error changing password: " . $result->error);
569
        	$errorMessage = "There was an error changing the password:" .
546 570
                           "<br />\n" . $result->error;
547 571
    	} 
548 572
    	$ldap->unbind;   # take down session

Also available in: Unified diff