aboutsummaryrefslogblamecommitdiff
path: root/nixops/modules/gitolite/gitolite_ldap_groups.sh
blob: 7db0da4093a701435cc9d83269e6f6e035247c53 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                    
                                                                                                                




                                                                                                                                                                                       
#!/usr/bin/env bash

uid_param="$1"
ldap_host="ldap.immae.eu"
ldap_binddn="cn=gitolite,ou=services,dc=immae,dc=eu"
ldap_bindpw="$LDAP_PASS"
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"