Skip to content

Instantly share code, notes, and snippets.

@angelmmg90
Last active September 21, 2017 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelmmg90/75f8c41863363c5f3bcf4b1f1cc5af3c to your computer and use it in GitHub Desktop.
Save angelmmg90/75f8c41863363c5f3bcf4b1f1cc5af3c to your computer and use it in GitHub Desktop.
To bulk add users in LDAP to simulate a production environment.
USERNAME="dummyuserldap"
DIRSRV="127.0.0.1"
PORT="10389"
ROOTDN="uid=admin,ou=system"
PASSWD="secret"
LDIF="/home/vagrant/ldif-gen/bulkuser.ldif"
for i in $(seq 20000 40000); do
echo "dn: uid=$USERNAME$i,ou=users,dc=example,dc=com" > $LDIF
echo "cn: Bulk User$i" >> $LDIF
echo "uid: $USERNAME$i" >> $LDIF
echo "objectClass: top" >> $LDIF
echo "objectClass: person" >> $LDIF
echo "objectClass: inetOrgPerson" >> $LDIF
echo "objectClass: organizationalPerson" >> $LDIF
echo "sn: $USERNAME$i" >> $LDIF
echo "userPassword: $PASSWD$i" >> $LDIF
echo -e "\n" >> $LDIF
/usr/bin/ldapmodify -x -h $DIRSRV -p $PORT -D "$ROOTDN" -w $PASSWD -a -f $LDIF
done
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment