utils: Fix Coverity ID 240113
[Samba.git] / examples / ad-bench / time_ldap.sh
blob4af6ef1592c12999461d52a7d5fd3e19eac1cf0a
1 #!/bin/bash
3 ITERATIONS=100
5 source $(dirname $0)/utils.sh
7 PRINCIPAL=$(get_principal $1)
8 PASSWORD=$(get_password $1)
9 REALM=$(get_realm $1)
10 NT_DOM=$(get_nt_dom $1)
11 SERVER=$2
13 search_users()
15 ${NET} ads search '(objectCategory=user)' sAMAccountName -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
16 RET=$?
17 if [ $RET -ne 0 ]; then
18 echo "${NET} returned error: $RET"
19 exit 1
23 search_groups()
25 ${NET} ads search '(objectCategory=group)' sAMAccountName -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
26 if [ $RET -ne 0 ]; then
27 echo "${NET} returned error: $RET"
28 exit 1
32 search_computers()
34 ${NET} ads search '(objectCategory=computer)' sAMAccountName -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
35 if [ $RET -ne 0 ]; then
36 echo "${NET} returned error: $RET"
37 exit 1
41 search_wildcard()
43 ${NET} ads search '(objectCategory=*)' sAMAccountName -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
44 if [ $RET -ne 0 ]; then
45 echo "${NET} returned error: $RET"
46 exit 1
50 search_unindexed()
52 ${NET} ads search '(description=Built-in account for adminstering the computer/domain)' sAMAccountName -k --configfile=$CONFIG_FILE -S ${SERVER} >/dev/null
53 if [ $RET -ne 0 ]; then
54 echo "${NET} returned error: $RET"
55 exit 1
59 set_up()
61 set_krb_env
62 setup_kinit
63 call_kinit "${PRINCIPAL}" "${PASSWORD}"
64 write_configfile "${REALM}" "${NT_DOM}"
67 tear_down()
69 ${KDESTROY}
70 restore_krb_env
73 set_up
75 echo -e "\tSEARCH INDEXED $2"
77 START_TIME=$(start_timer)
79 echo -en "\t"
80 for i in $(${SEQ} 1 $ITERATIONS); do
81 search_users
82 search_groups
83 search_computers
84 echo -n "."
85 done
86 echo "done"
88 STOP_TIME=$(stop_timer)
90 TOTAL_TIME=$(total_time $START_TIME $STOP_TIME)
92 echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"
94 LOGINS_PER_MINUTE=$(iterations_per_minute $START_TIME $STOP_TIME $ITERATIONS)
96 echo -e "\t\titerations/min:\t\t$LOGINS_PER_MINUTE"
98 ########################
100 echo -e "\tSEARCH WILDCARD $2"
102 START_TIME=$(start_timer)
104 echo -en "\t"
105 for i in $(${SEQ} 1 $ITERATIONS); do
106 search_wildcard
107 echo -n "."
108 done
109 echo "done"
111 STOP_TIME=$(stop_timer)
113 TOTAL_TIME=$(total_time $START_TIME $STOP_TIME)
115 echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"
117 LOGINS_PER_MINUTE=$(iterations_per_minute $START_TIME $STOP_TIME $ITERATIONS)
119 echo -e "\t\titerations/min:\t\t$LOGINS_PER_MINUTE"
121 ########################
123 echo -e "\tSEARCH UNINDEXED $2"
125 START_TIME=$(start_timer)
127 echo -en "\t"
128 for i in $(${SEQ} 1 $ITERATIONS); do
129 search_unindexed
130 echo -n "."
131 done
132 echo "done"
134 STOP_TIME=$(stop_timer)
136 TOTAL_TIME=$(total_time $START_TIME $STOP_TIME)
138 echo -e "\t\ttotal time:\t\t${TOTAL_TIME}s"
140 LOGINS_PER_MINUTE=$(iterations_per_minute $START_TIME $STOP_TIME $ITERATIONS)
142 echo -e "\t\titerations/min:\t\t$LOGINS_PER_MINUTE"
144 tear_down