File newFile = new File('modify-script.ldif')
String username = ''
String toAdd = ""
def stuCount = 80000
def admCount = 2000
def teachCount = 18000
StringBuilder sb = new StringBuilder()
def ous = [ 'ou1', 'ou2' ]
for ( ouname in ous ) {
for ( i in 1..stuCount ) {
username = "user_${epname}_${i}"
toAdd = """
dn: uid=${username},ou=people,ou=${ouname},dc=yourdc,dc=com
changetype: modify
add: userPassword
userPassword: {SSHA}zW7Q/yQQ8IKZiX8ANJIGugi0deNebN1o
"""
sb.append( toAdd )
}
sb.append( "\n\n" )
newFile << sb.toString()
}
This will produce a file (modify-script.ldif) with a bunch of entries like these:
dn: uid=user_ou1_1,ou=people,ou=ou1,dc=yourdc,dc=com
changetype: modify
add: userPassword
userPassword: {SSHA}zW7Q/yQQ8IKZiX8ANJIGugi0deNebN1o
dn: uid=user_ou1_2,ou=people,ou=ou1,dc=yourdc,dc=com
changetype: modify
add: userPassword
userPassword: {SSHA}zW7Q/yQQ8IKZiX8ANJIGugi0deNebN1o
...
Now you can simply run the ldapmodify command to update the users:
ldapmodify -x -D "cn=admin,dc=yourdc,dc=com" -w yourpass -f modify-script.ldif
I've been able to use derivatives of this script for a few different tasks. Hope it helps someone else.