summaryrefslogtreecommitdiff
path: root/hosted-kolab/09-add-doe-at-mgmt-domain-admin.sh
blob: 298d77642ae9c626e184e1634c81cf602facf72e (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
42
43
44
45
46
47
48
49
50
51
#!/bin/bash

. ./settings.sh

(
    echo "dn: uid=doe@${domain},ou=People,${rootdn}"
    echo "objectClass: top"
    echo "objectClass: inetorgperson"
    echo "objectClass: kolabinetorgperson"
    echo "objectClass: organizationalperson"
    echo "objectClass: person"
    echo "givenName: John"
    echo "sn: Doe"
    echo "cn: John Doe"
    echo "mail: doe@${domain}"
    echo "uid: doe@${domain}"
    echo "nsroledn: cn=admin-user,${rootdn}"
    echo "userPassword: ${default_user_password}"
    echo ""
) | ldapadd -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}"

num_domains=$(
    ldapsearch -x -h localhost \
        -D "uid=doe@${domain},ou=People,${rootdn}" \
        -w "${default_user_password}" \
        -b "${domain_base_dn}" \
        -s sub \
        -LLL "(&(objectclass=domainrelatedobject)(associateddomain=${domain}))" dn | \
            grep ^dn | \
            wc -l
    )

if [ ${num_domains} -ne 1 ]; then
    echo "ERROR: Expected 1 domain, got ${num_domains} domains"
fi

num_domains=$(
    ldapsearch -x -h localhost \
        -D "uid=doe@${domain},ou=People,${rootdn}" \
        -w "${default_user_password}" \
        -b "${domain_base_dn}" \
        -s sub \
        -LLL '(objectclass=domainrelatedobject)' dn | \
            grep ^dn | \
            wc -l
    )

if [ ${num_domains} -lt 3 ]; then
    echo "ERROR: Expected more than 3 domains, got ${num_domains} domain(s)"
fi