summaryrefslogtreecommitdiff
path: root/populate-ldap/99-cleanup-users-and-groups.sh
blob: 435e4e4f57a3813139b18bfa5c5e2d2f8c3eab2d (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
#!/bin/bash

 . ./settings.sh

(
    ldapsearch \
        -x \
        -h ${ldap_host} \
        -D "${ldap_binddn}" \
        -w "${ldap_bindpw}" \
        -b "${rootdn}" \
        -s sub \
        "(&(objectclass=inetorgperson)(!(uid=hosted-kolab-service))(!(uid=kolab-service))(!(uid=cyrus-admin)))" \
        -LLL \
        dn | \
        grep ^dn | \
        sed -e 's/dn: //g'
) | ldapdelete -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c

(
    ldapsearch \
        -x \
        -h ${ldap_host} \
        -D "${ldap_binddn}" \
        -w "${ldap_bindpw}" \
        -b "${rootdn}" \
        "(|(objectclass=groupofuniquenames)(objectclass=groupofurls))" \
        -LLL \
        dn | \
        grep ^dn | \
        sed -e 's/dn: //g'
) | ldapdelete -x -h ${ldap_host} -D "${ldap_binddn}" -w "${ldap_bindpw}" -c