diff options
-rw-r--r-- | plugins/check_ldap.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index fc1d3c6c..a0b739cc 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c | |||
@@ -72,6 +72,7 @@ double crit_time = UNDEFINED; | |||
72 | struct timeval tv; | 72 | struct timeval tv; |
73 | int starttls = FALSE; | 73 | int starttls = FALSE; |
74 | int ssl_on_connect = FALSE; | 74 | int ssl_on_connect = FALSE; |
75 | int verbose = 0; | ||
75 | 76 | ||
76 | /* for ldap tls */ | 77 | /* for ldap tls */ |
77 | 78 | ||
@@ -126,7 +127,8 @@ main (int argc, char *argv[]) | |||
126 | } | 127 | } |
127 | #else | 128 | #else |
128 | if (!(ld = ldap_open (ld_host, ld_port))) { | 129 | if (!(ld = ldap_open (ld_host, ld_port))) { |
129 | /*ldap_perror(ld, "ldap_open"); */ | 130 | if (verbose) |
131 | ldap_perror(ld, "ldap_open"); | ||
130 | printf (_("Could not connect to the server at port %i\n"), ld_port); | 132 | printf (_("Could not connect to the server at port %i\n"), ld_port); |
131 | return STATE_CRITICAL; | 133 | return STATE_CRITICAL; |
132 | } | 134 | } |
@@ -149,7 +151,8 @@ main (int argc, char *argv[]) | |||
149 | 151 | ||
150 | if (ldap_set_option (ld, LDAP_OPT_X_TLS, &tls) != LDAP_SUCCESS) | 152 | if (ldap_set_option (ld, LDAP_OPT_X_TLS, &tls) != LDAP_SUCCESS) |
151 | { | 153 | { |
152 | /*ldap_perror(ld, "ldaps_option"); */ | 154 | if (verbose) |
155 | ldap_perror(ld, "ldaps_option"); | ||
153 | printf (_("Could not init TLS at port %i!\n"), ld_port); | 156 | printf (_("Could not init TLS at port %i!\n"), ld_port); |
154 | return STATE_CRITICAL; | 157 | return STATE_CRITICAL; |
155 | } | 158 | } |
@@ -172,7 +175,8 @@ main (int argc, char *argv[]) | |||
172 | /* call start_tls */ | 175 | /* call start_tls */ |
173 | if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) | 176 | if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) |
174 | { | 177 | { |
175 | /*ldap_perror(ld, "ldap_start_tls"); */ | 178 | if (verbose) |
179 | ldap_perror(ld, "ldap_start_tls"); | ||
176 | printf (_("Could not init startTLS at port %i!\n"), ld_port); | 180 | printf (_("Could not init startTLS at port %i!\n"), ld_port); |
177 | return STATE_CRITICAL; | 181 | return STATE_CRITICAL; |
178 | } | 182 | } |
@@ -185,7 +189,8 @@ main (int argc, char *argv[]) | |||
185 | /* bind to the ldap server */ | 189 | /* bind to the ldap server */ |
186 | if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != | 190 | if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != |
187 | LDAP_SUCCESS) { | 191 | LDAP_SUCCESS) { |
188 | /*ldap_perror(ld, "ldap_bind"); */ | 192 | if (verbose) |
193 | ldap_perror(ld, "ldap_bind"); | ||
189 | printf (_("Could not bind to the ldap-server\n")); | 194 | printf (_("Could not bind to the ldap-server\n")); |
190 | return STATE_CRITICAL; | 195 | return STATE_CRITICAL; |
191 | } | 196 | } |
@@ -193,7 +198,8 @@ main (int argc, char *argv[]) | |||
193 | /* do a search of all objectclasses in the base dn */ | 198 | /* do a search of all objectclasses in the base dn */ |
194 | if (ldap_search_s (ld, ld_base, LDAP_SCOPE_BASE, ld_attr, NULL, 0, &result) | 199 | if (ldap_search_s (ld, ld_base, LDAP_SCOPE_BASE, ld_attr, NULL, 0, &result) |
195 | != LDAP_SUCCESS) { | 200 | != LDAP_SUCCESS) { |
196 | /*ldap_perror(ld, "ldap_search"); */ | 201 | if (verbose) |
202 | ldap_perror(ld, "ldap_search"); | ||
197 | printf (_("Could not search/find objectclasses in %s\n"), ld_base); | 203 | printf (_("Could not search/find objectclasses in %s\n"), ld_base); |
198 | return STATE_CRITICAL; | 204 | return STATE_CRITICAL; |
199 | } | 205 | } |
@@ -256,6 +262,7 @@ process_arguments (int argc, char **argv) | |||
256 | {"port", required_argument, 0, 'p'}, | 262 | {"port", required_argument, 0, 'p'}, |
257 | {"warn", required_argument, 0, 'w'}, | 263 | {"warn", required_argument, 0, 'w'}, |
258 | {"crit", required_argument, 0, 'c'}, | 264 | {"crit", required_argument, 0, 'c'}, |
265 | {"verbose", no_argument, 0, 'v'}, | ||
259 | {0, 0, 0, 0} | 266 | {0, 0, 0, 0} |
260 | }; | 267 | }; |
261 | 268 | ||
@@ -268,7 +275,7 @@ process_arguments (int argc, char **argv) | |||
268 | } | 275 | } |
269 | 276 | ||
270 | while (1) { | 277 | while (1) { |
271 | c = getopt_long (argc, argv, "hV234TS6t:c:w:H:b:p:a:D:P:", longopts, &option); | 278 | c = getopt_long (argc, argv, "hvV234TS6t:c:w:H:b:p:a:D:P:", longopts, &option); |
272 | 279 | ||
273 | if (c == -1 || c == EOF) | 280 | if (c == -1 || c == EOF) |
274 | break; | 281 | break; |
@@ -321,6 +328,9 @@ process_arguments (int argc, char **argv) | |||
321 | case '4': | 328 | case '4': |
322 | address_family = AF_INET; | 329 | address_family = AF_INET; |
323 | break; | 330 | break; |
331 | case 'v': | ||
332 | verbose++; | ||
333 | break; | ||
324 | case 'T': | 334 | case 'T': |
325 | if (! ssl_on_connect) | 335 | if (! ssl_on_connect) |
326 | starttls = TRUE; | 336 | starttls = TRUE; |