summaryrefslogtreecommitdiffstats
path: root/bin/gen-ldif
blob: 285b38b8d7697c63324a660091fb647907583ec0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash

[ ! -z "$2" ] && domain=$2 || domain="example.org"
[ ! -z "$3" ] && rootdn=$3 || rootdn="dc=example,dc=org"
[ ! -z "$4" ] && ou=$4 || ou="ou=People"

i=0
while [ $i -lt 0$1 ]; do

    givenname=`head -c 200 /dev/urandom | tr -dc A-Za-z | head -c5`
    surname=`head -c 200 /dev/urandom | tr -dc A-Za-z | head -c10`

    givenname="$(echo ${givenname:0:1} | tr '[:lower:]' '[:upper:]')$(echo ${givenname:1} | tr '[:upper:]' '[:lower:]')"
    surname="$(echo ${surname:0:1} | tr '[:lower:]' '[:upper:]')$(echo ${surname:1} | tr '[:upper:]' '[:lower:]')"

    uid="$(echo ${givenname:0:1}.${surname} | tr '[:upper:]' '[:lower:]')"

    userpassword="VerySecret"

    echo "dn: uid=$uid,${ou},${rootdn}"
    echo "uid: $uid"
    echo "givenName: $givenname"
    echo "objectClass: top"
    echo "objectClass: person"
    echo "objectClass: inetOrgPerson"
    echo "objectClass: organizationalPerson"
    echo "sn: $surname"
    echo "cn: $givenname $surname"
    echo "mail: $uid@${domain}"
    echo "userPassword: {SSHA}zJ3oU5kqtS3MxnLWmKpnE7+eGVbmQKmj"
    echo ""

    let i++
done