source: vendor/current/testprogs/blackbox/test_ldb.sh

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 8.4 KB
Line 
1#!/bin/sh
2
3if [ $# -lt 2 ]; then
4cat <<EOF
5Usage: test_ldb.sh PROTOCOL SERVER [OPTIONS]
6EOF
7exit 1;
8fi
9
10
11p=$1
12SERVER=$2
13PREFIX=$3
14shift 2
15options="$*"
16
17. `dirname $0`/subunit.sh
18
19check() {
20 name="$1"
21 shift
22 cmdline="$*"
23 echo "test: $name"
24 $cmdline
25 status=$?
26 if [ x$status = x0 ]; then
27 echo "success: $name"
28 else
29 echo "failure: $name"
30 failed=`expr $failed + 1`
31 fi
32 return $status
33}
34
35export PATH="$BINDIR:$PATH"
36
37ldbsearch="$VALGRIND ldbsearch"
38
39check "RootDSE" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1`
40check "RootDSE (full)" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base '(objectClass=*)' || failed=`expr $failed + 1`
41check "RootDSE (extended)" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base '(objectClass=*)' --extended-dn || failed=`expr $failed + 1`
42if [ x$p = x"ldaps" ]; then
43 testit_expect_failure "RootDSE over SSLv3 should fail" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN --option='tlspriority=NONE:+VERS-SSL3.0:+MAC-ALL:+CIPHER-ALL:+RSA:+SIGN-ALL:+COMP-NULL' && failed=`expr $failed + 1`
44fi
45
46echo "Getting defaultNamingContext"
47BASEDN=`$ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'`
48echo "BASEDN is $BASEDN"
49
50check "Listing Users" $ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1`
51
52check "Listing Users (sorted)" $ldbsearch -S $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1`
53
54check "Listing Groups" $ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1`
55
56nentries=`$ldbsearch $options -H $p://$SERVER $CONFIGURATION '(|(|(&(!(groupType:1.2.840.113556.1.4.803:=1))(groupType:1.2.840.113556.1.4.803:=2147483648)(groupType:1.2.840.113556.1.4.804:=10))(samAccountType=805306368))(samAccountType=805306369))' sAMAccountName | grep sAMAccountName | wc -l`
57echo "Found $nentries entries"
58if [ $nentries -lt 10 ]; then
59echo "Should have found at least 10 entries"
60failed=`expr $failed + 1`
61fi
62
63echo "Check rootDSE for Controls"
64nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l`
65if [ $nentries -lt 4 ]; then
66echo "Should have found at least 4 entries"
67failed=`expr $failed + 1`
68fi
69
70echo "Test Paged Results Control"
71nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l`
72if [ $nentries -lt 1 ]; then
73echo "Paged Results Control test returned 0 items"
74failed=`expr $failed + 1`
75fi
76
77echo "Test Server Sort Control"
78nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l`
79if [ $nentries -lt 1 ]; then
80echo "Server Sort Control test returned 0 items"
81failed=`expr $failed + 1`
82fi
83
84echo "Test Extended DN Control"
85nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1 '(objectclass=user)' | grep sAMAccountName | wc -l`
86if [ $nentries -lt 1 ]; then
87echo "Extended DN Control test returned 0 items"
88failed=`expr $failed + 1`
89fi
90nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l`
91if [ $nentries -lt 1 ]; then
92echo "Extended DN Control test returned 0 items"
93failed=`expr $failed + 1`
94fi
95nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:1 '(objectclass=user)' | grep sAMAccountName | wc -l`
96if [ $nentries -lt 1 ]; then
97echo "Extended DN Control test returned 0 items"
98failed=`expr $failed + 1`
99fi
100
101echo "Test Domain scope Control"
102nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=domain_scope:1 '(objectclass=user)' | grep sAMAccountName | wc -l`
103if [ $nentries -lt 1 ]; then
104echo "Extended Domain scope Control test returned 0 items"
105failed=`expr $failed + 1`
106fi
107
108echo "Test Attribute Scope Query Control"
109nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l`
110if [ $nentries -lt 1 ]; then
111echo "Attribute Scope Query test returned 0 items"
112failed=`expr $failed + 1`
113fi
114
115echo "Test Search Options Control"
116nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2 '(objectclass=crossRef)' | grep crossRef | wc -l`
117if [ $nentries -lt 1 ]; then
118echo "Search Options Control Query test returned 0 items"
119failed=`expr $failed + 1`
120fi
121
122echo "Test Search Options Control with Domain Scope Control"
123nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2,domain_scope:1 '(objectclass=crossRef)' | grep crossRef | wc -l`
124if [ $nentries -lt 1 ]; then
125echo "Search Options Control Query test returned 0 items"
126failed=`expr $failed + 1`
127fi
128
129wellknown_object_test()
130(
131 guid=$1
132 object=$2
133 failed=0
134
135 basedns="<WKGUID=${guid},${BASEDN}> <wkGuId=${guid},${BASEDN}>"
136 for dn in ${basedns}; do
137 echo "Test ${dn} => ${object}"
138 r=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=*)' -b "${dn}" | grep 'dn: '`
139 n=`echo "${r}" | grep 'dn: ' | wc -l`
140 c=`echo "${r}" | grep "${object}" | wc -l`
141
142 if [ $n -lt 1 ]; then
143 echo "Object not found by WKGUID"
144 failed=`expr $failed + 1`
145 continue
146 fi
147 if [ $c -lt 1 ]; then
148 echo "Wrong object found by WKGUID: [${r}]"
149 failed=`expr $failed + 1`
150 continue
151 fi
152 done
153
154 return $failed
155)
156
157wellknown_object_test 22B70C67D56E4EFB91E9300FCA3DC1AA ForeignSecurityPrincipals
158st=$?
159if [ x"$st" != x"0" ]; then
160 failed=`expr $failed + $st`
161fi
162wellknown_object_test 2FBAC1870ADE11D297C400C04FD8D5CD Infrastructure
163st=$?
164if [ x"$st" != x"0" ]; then
165 failed=`expr $failed + $st`
166fi
167wellknown_object_test AB1D30F3768811D1ADED00C04FD8D5CD System
168st=$?
169if [ x"$st" != x"0" ]; then
170 failed=`expr $failed + $st`
171fi
172wellknown_object_test A361B2FFFFD211D1AA4B00C04FD7D83A Domain Controllers
173st=$?
174if [ x"$st" != x"0" ]; then
175 failed=`expr $failed + $st`
176fi
177wellknown_object_test AA312825768811D1ADED00C04FD8D5CD Computers
178st=$?
179if [ x"$st" != x"0" ]; then
180 failed=`expr $failed + $st`
181fi
182wellknown_object_test A9D1CA15768811D1ADED00C04FD8D5CD Users
183st=$?
184if [ x"$st" != x"0" ]; then
185 failed=`expr $failed + $st`
186fi
187
188echo "Getting HEX GUID/SID of $BASEDN"
189HEXDN=`$ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:0 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-`
190HEXGUID=`echo "$HEXDN" | cut -d ';' -f1`
191echo "HEXGUID[$HEXGUID]"
192
193echo "Getting STR GUID/SID of $BASEDN"
194STRDN=`$ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:1 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-`
195echo "STRDN: $STRDN"
196STRGUID=`echo "$STRDN" | cut -d ';' -f1`
197echo "STRGUID[$STRGUID]"
198
199echo "Getting STR GUID/SID of $BASEDN"
200STRDN=`$ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:1 | grep 'dn: ' | cut -d ' ' -f2-`
201echo "STRDN: $STRDN"
202STRSID=`echo "$STRDN" | cut -d ';' -f2`
203echo "STRSID[$STRSID]"
204
205SPECIALDNS="$HEXGUID $STRGUID $STRSID"
206for SPDN in $SPECIALDNS; do
207 echo "Search for $SPDN"
208 nentries=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "$SPDN" '(objectClass=*)' | grep "dn: $BASEDN" | wc -l`
209 if [ $nentries -lt 1 ]; then
210 echo "Special search returned 0 items"
211 failed=`expr $failed + 1`
212 fi
213done
214
215echo "Search using OIDs instead of names"
216nentries1=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=user)' name | grep "^name: " | wc -l`
217nentries2=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER '(2.5.4.0=1.2.840.113556.1.5.9)' name | grep "^name: " | wc -l`
218if [ $nentries1 -lt 1 ]; then
219 echo "Error: Searching user via (objectClass=user): '$nentries1' < 1"
220 failed=`expr $failed + 1`
221fi
222if [ $nentries2 -lt 1 ]; then
223 echo "Error: Searching user via (2.5.4.0=1.2.840.113556.1.5.9) '$nentries2' < 1"
224 failed=`expr $failed + 1`
225fi
226if [ x"$nentries1" != x"$nentries2" ]; then
227 echo "Error: Searching user with OIDS[$nentries1] doesn't return the same as STRINGS[$nentries2]"
228 failed=`expr $failed + 1`
229fi
230
231exit $failed
Note: See TracBrowser for help on using the repository browser.