Project

General

Profile

« Previous | Next » 

Revision 8821

Added by Jing Tao over 10 years ago

For the existing uidnumber, we decrease the size of vector for sorting.

View differences:

ldapweb.cgi
1638 1638
                        } else {
1639 1639
                            debug("Remove the attribute successfully and write a new increased value back");
1640 1640
                            if($existingHighUid) {
1641
                            	debug("exiting high uid exists =======================================");
1641 1642
                            	if($uidNumber <= $existingHighUid ) {
1642 1643
                            		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 1644
                            		$uidNumber = $existingHighUid +1;
......
1667 1668
   
1668 1669
    my $high;
1669 1670
    my $ldap;
1671
    my $storedUidNumber;
1670 1672
    
1671 1673
    
1672 1674
    #if main ldap server is down, a html file containing warning message will be returned
......
1675 1677
        $ldap->start_tls( verify => 'require',
1676 1678
                      cafile => $ldapServerCACertFile);
1677 1679
        my $bindresult = $ldap->bind( version => 3, dn => $ldapUsername, password => $ldapPassword);
1680
        my $mesg = $ldap->search(base  => $dn_store_next_uid, filter => '(objectClass=*)');
1681
         if ($mesg->count() > 0) {
1682
                debug("Find the cn - $dn_store_next_uid");
1683
                my  $entry = $mesg->pop_entry;
1684
                $storedUidNumber = $entry->get_value($attribute_name_store_next_uid);
1685
        }
1678 1686
        my $uids = $ldap->search(
1679 1687
                        base => "dc=ecoinformatics,dc=org",
1680 1688
                        scope => "sub",
......
1685 1693
  	    my @uids;
1686 1694
        if ($uids->count > 0) {
1687 1695
                foreach my $uid ($uids->all_entries) {
1688
                        push @uids, $uid->get_value('uidNumber');
1696
                		if($storedUidNumber) {
1697
                			if( $uid->get_value('uidNumber') >= $storedUidNumber) {
1698
                				push @uids, $uid->get_value('uidNumber');
1699
                			}
1700
                		} else {
1701
                        	push @uids, $uid->get_value('uidNumber');
1702
                        }
1689 1703
                }
1690 1704
        }       
1691 1705
        
1692
        @uids = sort { $b <=> $a } @uids;
1693
        $high = $uids[0];   
1706
        if(@uids) {
1707
        	@uids = sort { $b <=> $a } @uids;
1708
        	$high = $uids[0];   
1709
        }    
1694 1710
        debug("the highest exiting uidnumber is $high");
1695 1711
        $ldap->unbind;   # take down session
1696 1712
    }

Also available in: Unified diff