r21736: Fix the smbclient test to do something more interesting with the last
[ira/wip.git] / testprogs / blackbox / test_ldb.sh
1 #!/bin/sh
2
3 p=$1
4 SERVER=$2
5 shift 2
6 options="$*"
7
8 check() {
9         name="$1"
10         shift
11         cmdline="$*"
12         echo "test: $name"
13         $cmdline
14         status=$?
15         if [ x$status = x0 ]; then
16                 echo "success: $name"
17         else
18                 echo "failure: $name"
19                 failed=`expr $failed + 1`
20         fi
21         return $status
22 }
23
24 check "RootDSE" bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1`
25
26 echo "Getting defaultNamingContext"
27 BASEDN=`bin/ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'`
28 echo "BASEDN is $BASEDN"
29
30 check "Listing Users" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=user)' sAMAccountName || failed=`expr $failed + 1`
31
32 check "Listing Groups" bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER '(objectclass=group)' sAMAccountName || failed=`expr $failed + 1`
33
34 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`
35 echo "Found $nentries entries"
36 if [ $nentries -lt 10 ]; then
37 echo "Should have found at least 10 entries"
38 failed=`expr $failed + 1`
39 fi
40
41 echo "Check rootDSE for Controls"
42 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER -s base -b "" '(objectclass=*)' | grep -i supportedControl | wc -l`
43 if [ $nentries -lt 4 ]; then
44 echo "Should have found at least 4 entries"
45 failed=`expr $failed + 1`
46 fi
47
48 echo "Test Paged Results Control"
49 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=paged_results:1:5 '(objectclass=user)' | grep sAMAccountName | wc -l`
50 if [ $nentries -lt 1 ]; then
51 echo "Paged Results Control test returned 0 items"
52 failed=`expr $failed + 1`
53 fi
54
55 echo "Test Server Sort Control"
56 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=server_sort:1:0:sAMAccountName '(objectclass=user)' | grep sAMAccountName | wc -l`
57 if [ $nentries -lt 1 ]; then
58 echo "Server Sort Control test returned 0 items"
59 failed=`expr $failed + 1`
60 fi
61
62 echo "Test Extended DN Control"
63 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=extended_dn:1:0 '(objectclass=user)' | grep sAMAccountName | wc -l`
64 if [ $nentries -lt 1 ]; then
65 echo "Extended DN Control test returned 0 items"
66 failed=`expr $failed + 1`
67 fi
68
69 echo "Test Attribute Scope Query Control"
70 nentries=`bin/ldbsearch $options $CONFIGURATION -H $p://$SERVER --controls=asq:1:member -s base -b "CN=Administrators,CN=Builtin,$BASEDN" | grep sAMAccountName | wc -l`
71 if [ $nentries -lt 1 ]; then
72 echo "Attribute Scope Query test returned 0 items"
73 failed=`expr $failed + 1`
74 fi
75 exit $failed