aboutsummaryrefslogtreecommitdiff
path: root/systems/eldiron/gitolite/gitolite_ldap_groups.sh
blob: ffa2dab308de09c7d8d6b8e6d9f4f98d0813b44f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env bash

uid_param="$1"
ldap_host="ldap://ldap.immae.eu"
ldap_binddn="cn=gitolite,ou=services,dc=immae,dc=eu"
ldap_bindpw="$(cat $LDAP_PASS_PATH)"
ldap_searchbase="dc=immae,dc=eu"
ldap_scope="subtree"

ldap_options="-H ${ldap_host} -ZZ -x -D ${ldap_binddn} -w ${ldap_bindpw} -b ${ldap_searchbase} -s ${ldap_scope}"

ldap_filter="(&(memberOf=cn=groups,cn=gitolite,ou=services,dc=immae,dc=eu)(|(member=uid=${uid_param},ou=users,dc=immae,dc=eu)(member=uid=${uid_param},ou=group_users,dc=immae,dc=eu)))"
ldap_result=$(ldapsearch ${ldap_options} -LLL "${ldap_filter}" cn | grep 'cn:' | cut -d' ' -f2)

echo "$ldap_result"