3
source @datadir@/@package_name@/data/DSSharedLib
5
libpath_add "@libdir@/@package_name@/"
6
libpath_add "@ldapsdk_libdir@"
8
libpath_add "@nss_libdir@"
10
export LD_LIBRARY_PATH
11
SHLIB_PATH=$LD_LIBRARY_PATH
13
PATH=$PATH:@ldaptool_bindir@:@ldaptool_bindir@:/usr/bin/:/usr/lib64/mozldap
19
echo "Usage: monitor [ -Z serverID ] [ -D rootdn ] [ -w password ] [ -b basedn ] [-P protocol] [-h]"
21
echo " -Z serverID - Server instance identifier"
22
echo " -D rootdn - Directory Manager DN"
23
echo " -w passwd - Directory Manager password"
24
echo " -P protocol - STARTTLS, LDAPS, LDAPI, LDAP"
25
echo " -h - Display usage"
28
while getopts "Z:b:hP:D:w:" flag
43
initfile=$(get_init_file "@initconfigdir@" $servid)
47
echo "You must supply a valid server instance identifier. Use -Z to specify instance name"
48
echo "Available instances: $initfile"
59
process_dse $CONFIG_DIR $$
60
file="/tmp/DSSharedLib.$$"
61
port=$(grep -i 'nsslapd-port' $file | awk '{print $2}' )
62
host=$(grep -i 'nsslapd-localhost' $file | awk '{print $2}' )
63
security=$(grep -i 'nsslapd-security' $file | awk '{print $2}' )
64
secure_port=$(grep -i 'nsslapd-secureport' $file | awk '{print $2}' )
65
ldapi=$(grep -i 'nsslapd-ldapilisten' $file | awk '{print $2}' )
66
ldapiURL=$(grep -i 'nsslapd-ldapifilepath' $file | awk '{print $2}' )
67
certdir=$(grep -i 'nsslapd-certdir' $file | awk '{print $2}' )
68
autobind=$(grep -i 'nsslapd-ldapiautobind' $file | awk '{print $2}' )
69
if [ "$rootdn" == "" ]; then
70
value=$(grep -i 'nsslapd-rootdn' $file)
71
rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'`
75
if [ "$passwd" != "" ]; then
79
if [ "$ldapiURL" != "" ]
81
ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'`
82
ldapiURL="ldapi://"$ldapiURL
85
client_type=`ldapsearch -V 2>&1`;
86
echo "$client_type" | grep -q "OpenLDAP"
90
export LDAPTLS_CACERTDIR=$certdir
93
if [ -z $security ]; then
96
revised_protocol=$(check_protocol $protocol $security $ldapi $openldap)
97
if [ "$revised_protocol" != "$protocol" ]; then
98
echo Protocol $protocol requested, but this protocol is not supported
101
protocol=$revised_protocol
106
if [ "$security" == "on" ]; then
107
if [ "$protocol" == "STARTTLS" ] || [ "$protocol" == "" ]; then
108
if [ "$error" == "yes" ]; then
109
echo "Using the next most secure protocol(STARTTLS)"
111
if [ "$openldap" == "yes" ]; then
112
ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
114
ldapsearch -ZZZ -P $certdir -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
123
if [ "$security" == "on" ]; then
124
if [ "$protocol" == "LDAPS" ] || [ "$protocol" == "" ]; then
125
if [ "$error" == "yes" ]; then
126
echo "Using the next most secure protocol(LDAPS)"
128
if [ "$openldap" == "yes" ]; then
129
ldapsearch -x -LLL -H "ldaps://$host:$secure_port" -b "$MDN" -s base $dn $passwd "objectClass=*"
131
ldapsearch -Z -P $certdir -p $secure_port -b "$MDN" -s base $dn $passwd "objectClass=*"
140
if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then
141
if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then
142
if [ "$(id -u)" == "0" ] && [ "$autobind" == "on" ]; then
143
if [ "$error" == "yes" ]; then
144
echo "Using the next most secure protocol(LDAPI/AUTOBIND)"
146
ldapsearch -LLL -H "$ldapiURL" -b "$MDN" -s base -Y EXTERNAL "objectClass=*" 2>/dev/null
148
if [ "$error" == "yes" ]; then
149
echo "Using the next most secure protocol(LDAPI)"
151
ldapsearch -x -LLL -H "$ldapiURL" -b "$MDN" -s base $dn $passwd "objectClass=*"
160
if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then
161
if [ "$error" == "yes" ]; then
162
echo "Using the next most secure protocol(LDAP)"
164
if [ "$openldap" == "yes" ]; then
165
ldapsearch -x -LLL -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
167
ldapsearch -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"