[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: Get Max uidNumber ...

A few things:
1. Most ldapsearch clients do not provide a -S flag. Is that "sort"? A
more portable solution might be to pipe through the sort command. If it
works, great.
2. Many bashes don't support arrays. You need to make sure you use bash
2.0 or higer or else it won't work. Since bash2 has other issue, many
systems don't come with that installed.
3. There is a handy utility called "digest" that I use w/ shell scripts
to make MD5, SHA, crypt, etc. hashes. It was written by Andre Opperman
and comes with his qmail patches on www.nrg4u.com.

	-----Original Message----- 
	From: C.Lee Taylor 
	Sent: Fri 10/26/2001 8:09 AM 
	To: openldap-software@OpenLDAP.org 
	Subject: Get Max uidNumber ...

	Greetings ...
	        I search the archives and found that there was a few
ideas how to do
	this, so I thought that I would though out my idea and see you
guys bash
	it ... no pun intended ... I know this would be slow if one was
tring to
	bring in more than a few users, but then I use it just to add a
	users at a time ... I also believe this would not be a good idea
to have
	more than one user adding in users, because the uidNumber could
go up
	while we import the next user.
	        Take look and tell me what you think ...
	ldapsecret="-w topsecret"
	ldapDN="dc=foobar, dc=com"
	function getMaxUid ()
	     for i in $(ldapsearch -x -LLL $ldapsecret -D "cn=Manager,
	"(uidNumber=*)" uidNumber -S uidNumber | grep uidNumber | tail
-n1 );
	        do \
	            let n+=1
	     if [ "${ldaparry[0]}" == "uidNumber:" ]; then
	        echo $((${ldaparry[1]}+1))
	        return 0
	        return -1
	function adduser ()
	     echo "dn: uid=tempacc,ou=People,$ldapDN"
	     echo "uid: tempacc"
	     echo "cn: tempacc"
	     echo "sn: surname"
	     echo "objectClass: person"
	     echo "objectClass: organizationalPerson"
	     echo "objectClass: inetOrgPerson"
	     echo "objectClass: account"openldap-software@OpenLDAP.org
	     echo "objectClass: posixAccount"
	     echo "objectClass: top"
	     echo "objectClass: shadowAccount"
	     echo "userPassword:: e2NyeXB0fVNBMDFWamZva2VwUi4="
	     echo "shadowLastChange: 11159"
	     echo "shadowMax: 99999"
	     echo "shadowWarning: 7"
	     echo "gidNumber: 100"
	     echo "homeDirectory: /home/users/tempacc"
	     (($uidNumber > 0))
	     if [ $? ]; then
	        echo "uidNumber: $uidNumber"
	        return 0
	        return -1
	adduser | ldapadd -x $ldapsecret -D "cn=Manager, $ldapDN
	exit 0