summaryrefslogtreecommitdiffstats
path: root/contrib/utils/ldap_groups.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:17:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:17:27 +0000
commitaae1a14ea756102251351d96e2567b4986d30e2b (patch)
treea1af617672e26aee4c1031a3aa83e8ff08f6a0a5 /contrib/utils/ldap_groups.sh
parentInitial commit. (diff)
downloadgitolite3-aae1a14ea756102251351d96e2567b4986d30e2b.tar.xz
gitolite3-aae1a14ea756102251351d96e2567b4986d30e2b.zip
Adding upstream version 3.6.12.upstream/3.6.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib/utils/ldap_groups.sh')
-rwxr-xr-xcontrib/utils/ldap_groups.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/contrib/utils/ldap_groups.sh b/contrib/utils/ldap_groups.sh
new file mode 100755
index 0000000..01bf5ee
--- /dev/null
+++ b/contrib/utils/ldap_groups.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# author: damien.nozay@gmail.com
+
+# Given a username,
+# Provides a space-separated list of groups that the user is a member of.
+#
+# see http://gitolite.com/gitolite/conf.html#ldap
+# GROUPLIST_PGM => /path/to/ldap_groups.sh
+
+ldap_groups() {
+ username=$1;
+ # this relies on openldap / pam_ldap to be configured properly on your
+ # system. my system allows anonymous search.
+ echo $(
+ ldapsearch -x -LLL "(&(objectClass=posixGroup)(memberUid=${username}))" cn \
+ | grep "^cn" \
+ | cut -d' ' -f2
+ );
+}
+
+ldap_groups $@