aboutsummaryrefslogtreecommitdiff
path: root/modules/private/gitolite/gitolite_ldap_groups.sh
blob: 3d7117e728f0ca80201c3a5492f390043602f8c0 (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.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"