openldap/ldapuseradd.sh

raw link view readme
1 #!/bin/bash
2 #+
3 #+ copyright (c) david betz
4 #++ might suck, but it seems to work
5 #+
6
7 max_uid=$(getent passwd | cut -d: -f3 | sort -n | tail -n1)
8 new_uid=$(($max_uid + 1))
9 sed "/userPassword:/d;/^ /d;s/David Betz/John Doe/;s/davidbetz/$1/g;s/uidNumber: 4000/uidNumber: $new_uid/g" ~/user_template.ldif
10
11 #usage:
12 # ~/ldapuseradd.sh user02 "John Doe" > ~/user02.ldif
13 # ldapadd -x -D "cn=Admin,dc=example,dc=net" -f ~/user02.ldif -w mypassword
14