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

Last change on this file was 740, checked in by Silvan Scherrer, 13 years ago

Samba Server: update vendor to 3.6.0

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