| 1234567891011121314151617181920212223242526272829303132333435 |
- #!/bin/bash
- . .env
- user_exists() {
- res=$(ldapsearch -x -LLL -b $PEOPLEDN -D $BINDDN -w $BINDPW "(&(uid=$1)(objectClass=inetOrgPerson))" | grep uid: | cut -f2 -d' ')
- [ -n "$res" ]
- }
- group_exists() {
- res=$(ldapsearch -x -LLL -b $GROUPSDN -D $BINDDN -w $BINDPW "(cn=$1)" | grep cn: | cut -f2 -d' ')
- [ -n "$res" ]
- }
- user_is_posix() {
- res=$(ldapsearch -x -LLL -b $PEOPLEDN -D $BINDDN -w $BINDPW "(&(uid=$1)(objectClass=posixAccount))" | grep uid: | cut -f2 -d' ')
- [ -n "$res" ]
- }
- group_is_posix() {
- res=$(ldapsearch -x -LLL -b $GROUPSDN -D $BINDDN -w $BINDPW "(&(cn=$1)(objectClass=posixGroup))" | grep cn: | cut -f2 -d' ')
- [ -n "$res" ]
- }
- get_posixGroups () {
- ldapsearch -x -LLL -b $GROUPSDN -D $BINDDN -w $BINDPW "(&(memberUid=$1)(objectClass=posixGroup))" | grep cn: | cut -f2 -d' '
- }
- # get the list of currently used uid numbers and add 1 to get the next one
- # uids between 2000 and 2999 are used for users. If the need to manage
- # more than 1000 users arise, consider using something else than a few bash scripts
- # to manage your directory.
- get_posix_number() {
- echo $(( $(ldapsearch -x -LLL -b $PEOPLEDN -D $BINDDN -w $BINDPW "(objectClass=posixAccount)" | grep 'uidNumber: 2' | cut -d' ' -f2 | sort -u | tail -n 1) +1))
- }
|