Created
December 6, 2013 11:15
-
-
Save Finkregh/7822145 to your computer and use it in GitHub Desktop.
add groups from Active Directory / ldap to prosody
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#/usr/local/bin/create-prosody-groups.sh | |
tmpfile=/tmp/sharedgroups.txt | |
for org in group1 group2 ; do echo "[${org}]" ; ldapsearch -x -h ldap.corp.org -D "ldap-bind-user" -w "ldap-bind-pw" -LLL -b "ou=${org},dc=corp,dc=org" "(&(objectClass=user)(mail=*))" | grep -E "^cn: |sAMAccountName: "; done > ${tmpfile} | |
while read line ; do | |
if echo ${line} | grep -qE "^\[" ; then | |
echo "" | |
echo $line | |
else | |
if echo ${line} | grep -qE "^cn" ; then | |
fullname=$(echo ${line} | cut -d ' ' -f 2-) | |
elif echo ${line} | grep -qE "^sAMAccountName" ; then | |
uid=$(echo ${line} | cut -d ' ' -f 2 | tr '[:upper:]' '[:lower:]') | |
echo "${uid}@xmpp.corp.org=${fullname}" | |
fi | |
fi | |
done < ${tmpfile} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 0 * * * root /usr/local/bin/create-prosody-groups.sh > /var/lib/prosody/sharedgroups.txt ; chown prosody.prosody /var/lib/prosody/sharedgroups.txt ; service prosody reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment