Skip to content

Instantly share code, notes, and snippets.

@jmkim
Created January 6, 2025 04:32
Show Gist options
  • Save jmkim/6dca7b94be55ebcf6c19669e399e5b3a to your computer and use it in GitHub Desktop.
Save jmkim/6dca7b94be55ebcf6c19669e399e5b3a to your computer and use it in GitHub Desktop.
LDAP shell modifier
#!/bin/bash
TITLE="LDAP shell modifier"
DESCRIPTION="LDAP shell modifier"
VERSION="1.0"
AUTHOR="Jongmin Kim <[email protected]>"
LICENSE="Expat"
EXECUTABLE="$0"
ADMIN_DN='uid=jmkim,cn=users,dc=doubleo,dc=co,dc=kr'
USER_DN="uid=$1,cn=users,dc=doubleo,dc=co,dc=kr"
USER_SHELL="$2"
LDIF_TEXT="dn: $USER_DN
changetype: modify
replace: loginShell
loginShell: $USER_SHELL"
if [[ "$#" -ne 2 ]]; then
echo "Usage: $EXECUTABLE [uid] [shell]"
exit 1
fi
echo "--"
echo "$LDIF_TEXT"
echo "--"
ldapmodify -D "$ADMIN_DN" -W <<EOM
$LDIF_TEXT
EOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment