summaryrefslogtreecommitdiff
path: root/ucs-3.x/16-create-user-jane-doe.sh
blob: afee2cb359f1f03617d8917bc337c3f8f23f2401 (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
35
36
37
38
39
40
41
#!/bin/bash

eval "$(ucr shell)"

if [ "${server_role}" != "domaincontroller_master" ]; then
    echo "SKIPPED - This system is not a master domain controller."
    exit 0
fi

imap_server=$(ldapsearch -x -H ldap://${ldap_server_name}:${ldap_server_port} -D "${ldap_hostdn}" -y /etc/machine.secret -LLL "(univentionService=IMAP)" cn | grep ^cn | awk '{print $2}' | head -n 1)

if [ -z "${imap_server}" ]; then
    echo "FAIL: No server found with role IMAP"
    exit 1
fi

univention-directory-manager users/user create \
    --set password=Welcome2KolabSystems \
    --set "username=doe2" \
    --set "lastname=Doe" \
    --set "e-mail=doe2@${domainname}" \
    --set "mailPrimaryAddress=doe2@${domainname}" \
    --set "mailHomeServer=${imap_server}.${domainname}" \
    --position "cn=users,${ldap_base}" \
    >/dev/null 2>&1

retval_add=$?
retval_search=$(ldapsearch -x -H ldap://${ldap_server_name}:${ldap_server_port} -b "${ldap_base}" -LLL -D "${ldap_hostdn}" -y /etc/machine.secret "(uid=doe2)" entrydn univentionMailHomeServer | grep -i ^entrydn | wc -l)

if [ $retval_add -ne 0 ]; then
    if [ $retval_search -eq 0 ]; then
        echo "FAIL: User Jane Doe <doe2@example.org> not created"
        exit 1
    else
        echo "OK: User Jane Doe <doe2@example.org> exists"
        exit 0
    fi
else
    echo "OK: User Jane Doe <doe2@example.org> created"
    exit 0
fi