5 Usage: test_ldb.sh PROTOCOL SERVER [OPTIONS]
17 .
`dirname $0`/subunit.sh
26 if [ x
$status = x0
]; then
30 failed
=`expr $failed + 1`
35 export PATH
="$BINDIR:$PATH"
37 ldbsearch
="$VALGRIND ldbsearch"
39 check
"RootDSE" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY
=x dnsHostName highestCommittedUSN || failed
=`expr $failed + 1`
40 check
"RootDSE (full)" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base
'(objectClass=*)' || failed
=`expr $failed + 1`
41 check
"RootDSE (extended)" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base
'(objectClass=*)' --extended-dn || failed
=`expr $failed + 1`
43 echo "Getting defaultNamingContext"
44 BASEDN
=`$ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'`
45 echo "BASEDN is $BASEDN"
47 check
"Listing Users" $ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed
=`expr $failed + 1`
49 check
"Listing Users (sorted)" $ldbsearch -S $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed
=`expr $failed + 1`
51 check
"Listing Groups" $ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed
=`expr $failed + 1`
53 nentries
=`$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`
54 echo "Found $nentries entries"
55 if [ $nentries -lt 10 ]; then
56 echo "Should have found at least 10 entries"
57 failed
=`expr $failed + 1`
60 echo "Check rootDSE for Controls"
61 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l`
62 if [ $nentries -lt 4 ]; then
63 echo "Should have found at least 4 entries"
64 failed
=`expr $failed + 1`
67 echo "Test Paged Results Control"
68 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l`
69 if [ $nentries -lt 1 ]; then
70 echo "Paged Results Control test returned 0 items"
71 failed
=`expr $failed + 1`
74 echo "Test Server Sort Control"
75 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l`
76 if [ $nentries -lt 1 ]; then
77 echo "Server Sort Control test returned 0 items"
78 failed
=`expr $failed + 1`
81 echo "Test Extended DN Control"
82 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1 '(objectclass=user)' | grep sAMAccountName | wc -l`
83 if [ $nentries -lt 1 ]; then
84 echo "Extended DN Control test returned 0 items"
85 failed
=`expr $failed + 1`
87 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l`
88 if [ $nentries -lt 1 ]; then
89 echo "Extended DN Control test returned 0 items"
90 failed
=`expr $failed + 1`
92 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:1 '(objectclass=user)' | grep sAMAccountName | wc -l`
93 if [ $nentries -lt 1 ]; then
94 echo "Extended DN Control test returned 0 items"
95 failed
=`expr $failed + 1`
98 echo "Test Domain scope Control"
99 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=domain_scope:1 '(objectclass=user)' | grep sAMAccountName | wc -l`
100 if [ $nentries -lt 1 ]; then
101 echo "Extended Domain scope Control test returned 0 items"
102 failed
=`expr $failed + 1`
105 echo "Test Attribute Scope Query Control"
106 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l`
107 if [ $nentries -lt 1 ]; then
108 echo "Attribute Scope Query test returned 0 items"
109 failed
=`expr $failed + 1`
112 echo "Test Search Options Control"
113 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2 '(objectclass=crossRef)' | grep crossRef | wc -l`
114 if [ $nentries -lt 1 ]; then
115 echo "Search Options Control Query test returned 0 items"
116 failed
=`expr $failed + 1`
119 echo "Test Search Options Control with Domain Scope Control"
120 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2,domain_scope:1 '(objectclass=crossRef)' | grep crossRef | wc -l`
121 if [ $nentries -lt 1 ]; then
122 echo "Search Options Control Query test returned 0 items"
123 failed
=`expr $failed + 1`
126 wellknown_object_test
()
132 basedns
="<WKGUID=${guid},${BASEDN}> <wkGuId=${guid},${BASEDN}>"
133 for dn
in ${basedns}; do
134 echo "Test ${dn} => ${object}"
135 r
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=*)' -b "${dn}" | grep 'dn: '`
136 n
=`echo "${r}" | grep 'dn: ' | wc -l`
137 c
=`echo "${r}" | grep "${object}" | wc -l`
139 if [ $n -lt 1 ]; then
140 echo "Object not found by WKGUID"
141 failed
=`expr $failed + 1`
144 if [ $c -lt 1 ]; then
145 echo "Wrong object found by WKGUID: [${r}]"
146 failed
=`expr $failed + 1`
154 wellknown_object_test
22B70C67D56E4EFB91E9300FCA3DC1AA ForeignSecurityPrincipals
156 if [ x
"$st" != x
"0" ]; then
157 failed
=`expr $failed + $st`
159 wellknown_object_test
2FBAC1870ADE11D297C400C04FD8D5CD Infrastructure
161 if [ x
"$st" != x
"0" ]; then
162 failed
=`expr $failed + $st`
164 wellknown_object_test AB1D30F3768811D1ADED00C04FD8D5CD System
166 if [ x
"$st" != x
"0" ]; then
167 failed
=`expr $failed + $st`
169 wellknown_object_test A361B2FFFFD211D1AA4B00C04FD7D83A Domain Controllers
171 if [ x
"$st" != x
"0" ]; then
172 failed
=`expr $failed + $st`
174 wellknown_object_test AA312825768811D1ADED00C04FD8D5CD Computers
176 if [ x
"$st" != x
"0" ]; then
177 failed
=`expr $failed + $st`
179 wellknown_object_test A9D1CA15768811D1ADED00C04FD8D5CD Users
181 if [ x
"$st" != x
"0" ]; then
182 failed
=`expr $failed + $st`
185 echo "Getting HEX GUID/SID of $BASEDN"
186 HEXDN
=`$ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:0 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-`
187 HEXGUID
=`echo "$HEXDN" | cut -d ';' -f1`
188 echo "HEXGUID[$HEXGUID]"
190 echo "Getting STR GUID/SID of $BASEDN"
191 STRDN
=`$ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:1 distinguishedName | grep 'distinguishedName: ' | cut -d ' ' -f2-`
193 STRGUID
=`echo "$STRDN" | cut -d ';' -f1`
194 echo "STRGUID[$STRGUID]"
196 echo "Getting STR GUID/SID of $BASEDN"
197 STRDN
=`$ldbsearch $CONFIGURATION $options -b "$BASEDN" -H $p://$SERVER -s base "(objectClass=*)" --controls=extended_dn:1:1 | grep 'dn: ' | cut -d ' ' -f2-`
199 STRSID
=`echo "$STRDN" | cut -d ';' -f2`
200 echo "STRSID[$STRSID]"
202 SPECIALDNS
="$HEXGUID $STRGUID $STRSID"
203 for SPDN
in $SPECIALDNS; do
204 echo "Search for $SPDN"
205 nentries
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "$SPDN" '(objectClass=*)' | grep "dn: $BASEDN" | wc -l`
206 if [ $nentries -lt 1 ]; then
207 echo "Special search returned 0 items"
208 failed
=`expr $failed + 1`
212 echo "Search using OIDs instead of names"
213 nentries1
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=user)' name | grep "^name: " | wc -l`
214 nentries2
=`$ldbsearch $options $CONFIGURATION -H $p://$SERVER '(2.5.4.0=1.2.840.113556.1.5.9)' name | grep "^name: " | wc -l`
215 if [ $nentries1 -lt 1 ]; then
216 echo "Error: Searching user via (objectClass=user): '$nentries1' < 1"
217 failed
=`expr $failed + 1`
219 if [ $nentries2 -lt 1 ]; then
220 echo "Error: Searching user via (2.5.4.0=1.2.840.113556.1.5.9) '$nentries2' < 1"
221 failed
=`expr $failed + 1`
223 if [ x
"$nentries1" != x
"$nentries2" ]; then
224 echo "Error: Searching user with OIDS[$nentries1] doesn't return the same as STRINGS[$nentries2]"
225 failed
=`expr $failed + 1`