funcs 694 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. . .env
  3. user_exists() {
  4. res=$(ldapsearch -x -LLL -b $PEOPLEDN -D $BINDDN -w $BINDPW "(&(uid=$1)(objectClass=inetOrgPerson))" | grep uid: | cut -f2 -d' ')
  5. [ -n "$res" ]
  6. }
  7. group_exists() {
  8. res=$(ldapsearch -x -LLL -b $GROUPSDN -D $BINDDN -w $BINDPW "(&(cn=$1)(objectClass=groupOfNames))" | grep cn: | cut -f2 -d' ')
  9. [ -n "$res" ]
  10. }
  11. is_posix() {
  12. res=$(ldapsearch -x -LLL -b $PEOPLEDN -D $BINDDN -w $BINDPW "(&(uid=$1)(objectClass=posixAccount))" | grep uid: | cut -f2 -d' ')
  13. [ -n "$res" ]
  14. }
  15. get_posix_number() {
  16. echo $(( $(ldapsearch -x -LLL -b $PEOPLEDN -D $BINDDN -w $BINDPW "(objectClass=posixAccount)" | grep 'uidNumber: 2' | cut -d' ' -f2 | sort -u | tail -n 1) +1))
  17. }