Skip to content

Instantly share code, notes, and snippets.

@balazs-endresz
Created March 1, 2016 13:16
Show Gist options
  • Save balazs-endresz/6ab65dce1fa30cf489bb to your computer and use it in GitHub Desktop.
Save balazs-endresz/6ab65dce1fa30cf489bb to your computer and use it in GitHub Desktop.
Add new objectClass to existing ldap user
#! /bin/sh
ldapsearch -x -h localhost -b dc=example,dc=org,dc=uk \
'(&(objectClass=existingObjectClass)(!(objectclass=newObjectClass)))' dn \
|awk '/^dn: / { print $2 }' \
| (
while read line; do
printf 'dn: %s\nchangetype: modify\nadd: objectClass\nobjectClass: newObjectClass\n\n' "$line"
done
) \
| ldapmodify -Wxhlocalhost -Dcn=admin,dc=example,dc=org,dc=uk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment