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 check "RootDSE" bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1`
37 echo "Getting defaultNamingContext"
38 BASEDN=`bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'`
39 echo "BASEDN is $BASEDN"
41 check "Listing Users" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1`
43 check "Listing Users (sorted)" bin/ldbsearch -S $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1`
45 check "Listing Groups" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1`
47 nentries=`bin/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`
48 echo "Found $nentries entries"
49 if [ $nentries -lt 10 ]; then
50 echo "Should have found at least 10 entries"
51 failed=`expr $failed + 1`
54 echo "Check rootDSE for Controls"
55 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l`
56 if [ $nentries -lt 4 ]; then
57 echo "Should have found at least 4 entries"
58 failed=`expr $failed + 1`
61 echo "Test Paged Results Control"
62 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l`
63 if [ $nentries -lt 1 ]; then
64 echo "Paged Results Control test returned 0 items"
65 failed=`expr $failed + 1`
68 echo "Test Server Sort Control"
69 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l`
70 if [ $nentries -lt 1 ]; then
71 echo "Server Sort Control test returned 0 items"
72 failed=`expr $failed + 1`
75 echo "Test Extended DN Control"
76 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1 '(objectclass=user)' | grep sAMAccountName | wc -l`
77 if [ $nentries -lt 1 ]; then
78 echo "Extended DN Control test returned 0 items"
79 failed=`expr $failed + 1`
81 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l`
82 if [ $nentries -lt 1 ]; then
83 echo "Extended DN Control test returned 0 items"
84 failed=`expr $failed + 1`
86 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:1 '(objectclass=user)' | grep sAMAccountName | wc -l`
87 if [ $nentries -lt 1 ]; then
88 echo "Extended DN Control test returned 0 items"
89 failed=`expr $failed + 1`
92 echo "Test Domain scope Control"
93 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=domain_scope:1 '(objectclass=user)' | grep sAMAccountName | wc -l`
94 if [ $nentries -lt 1 ]; then
95 echo "Extended Domain scope Control test returned 0 items"
96 failed=`expr $failed + 1`
99 echo "Test Attribute Scope Query Control"
100 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l`
101 if [ $nentries -lt 1 ]; then
102 echo "Attribute Scope Query test returned 0 items"
103 failed=`expr $failed + 1`
106 echo "Test Search Options Control"
107 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2 '(objectclass=crossRef)' | grep crossRef | wc -l`
108 if [ $nentries -lt 1 ]; then
109 echo "Search Options Control Query test returned 0 items"
110 failed=`expr $failed + 1`
113 echo "Test Search Options Control with Domain Scope Control"
114 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=search_options:1:2,domain_scope:1 '(objectclass=crossRef)' | grep crossRef | wc -l`
115 if [ $nentries -lt 1 ]; then
116 echo "Search Options Control Query test returned 0 items"
117 failed=`expr $failed + 1`
120 function wellkown_object_test() {
130 basedns="<WKGUID=${guid},${BASEDN}> <wkGuId=${guid},${BASEDN}>"
131 for dn in ${basedns}; do
132 echo "Test ${dn} => ${object}"
133 r=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectClass=*)' -b "${dn}" | grep 'dn: '`
134 n=`echo "${r}" | grep 'dn: ' | wc -l`
135 c=`echo "${r}" | grep "${object}" | wc -l`
137 if [ $n -lt 1 ]; then
138 echo "Object not found by WKGUID"
139 failed=`expr $failed + 1`
142 if [ $c -lt 1 ]; then
143 echo "Wrong object found by WKGUID: [${r}]"
144 failed=`expr $failed + 1`
152 wellkown_object_test 22B70C67D56E4EFB91E9300FCA3DC1AA ForeignSecurityPrincipals
154 if [ x"$st" != x"0" ]; then
155 failed=`expr $failed + $st`
157 wellkown_object_test 2FBAC1870ADE11D297C400C04FD8D5CD Infrastructure
159 if [ x"$st" != x"0" ]; then
160 failed=`expr $failed + $st`
162 wellkown_object_test AB1D30F3768811D1ADED00C04FD8D5CD System
164 if [ x"$st" != x"0" ]; then
165 failed=`expr $failed + $st`
167 wellkown_object_test A361B2FFFFD211D1AA4B00C04FD7D83A Domain Controllers
169 if [ x"$st" != x"0" ]; then
170 failed=`expr $failed + $st`
172 wellkown_object_test AA312825768811D1ADED00C04FD8D5CD Computers
174 if [ x"$st" != x"0" ]; then
175 failed=`expr $failed + $st`
177 wellkown_object_test A9D1CA15768811D1ADED00C04FD8D5CD Users
179 if [ x"$st" != x"0" ]; then
180 failed=`expr $failed + $st`