Project

General

Profile

« Previous | Next » 

Revision 8819

Added by Jing Tao almost 10 years ago

Add the code to check if the existing highest uidNumber really exists.

View differences:

ldapweb.cgi
1637 1637
                            #can't remove the attribute with the specified value - that means somebody modify the value in another route, so try it again
1638 1638
                        } else {
1639 1639
                            debug("Remove the attribute successfully and write a new increased value back");
1640
                            if($uidNumber <= $existingHighUid ) {
1641
                            	debug("The stored uidNumber $uidNumber is less than the used uidNumber $existingHighUid, so we will use the new number which is $existingHighUid+1");
1642
                            	$uidNumber = $existingHighUid +1;
1643
                            } 
1640
                            if($existingHighUid) {
1641
                            	if($uidNumber <= $existingHighUid ) {
1642
                            		debug("The stored uidNumber $uidNumber is less than or equals the used uidNumber $existingHighUid, so we will use the new number which is $existingHighUid+1");
1643
                            		$uidNumber = $existingHighUid +1;
1644
                            	} 
1645
                            }                  
1644 1646
                            my $newValue = $uidNumber +1;
1645 1647
                            $delMesg = $ldap->modify($dn_store_next_uid, add => {$attribute_name_store_next_uid => $newValue});
1646 1648
                            $realUidNumber = $uidNumber;
......
1665 1667
   
1666 1668
    my $high;
1667 1669
    my $ldap;
1668
    debug("ldap server: $ldapurl");
1669 1670
    
1671
    
1670 1672
    #if main ldap server is down, a html file containing warning message will be returned
1671 1673
    $ldap = Net::LDAP->new($ldapurl, timeout => $timeout) or handleLDAPBindFailure($ldapurl);
1672
    debug("after creating a ldap server");
1673 1674
    if ($ldap) {
1674
    	debug("before staring the tls");
1675 1675
        $ldap->start_tls( verify => 'require',
1676 1676
                      cafile => $ldapServerCACertFile);
1677
        debug("after staring the tls");
1678 1677
        my $bindresult = $ldap->bind( version => 3, dn => $ldapUsername, password => $ldapPassword);
1679
        debug("after binding ....");
1680 1678
        my $uids = $ldap->search(
1681 1679
                        base => "dc=ecoinformatics,dc=org",
1682 1680
                        scope => "sub",
1683 1681
                        filter => "uidNumber=*", 
1684 1682
                        attrs   => [ 'uidNumber' ],
1685 1683
                        );
1686
       debug("after searching.... $uids");
1687 1684
       return unless $uids->count;
1688
       debug("before sorting the returned uidNumber");
1689 1685
  	    my @uids;
1690 1686
        if ($uids->count > 0) {
1691 1687
                foreach my $uid ($uids->all_entries) {

Also available in: Unified diff