--- check_ldap.c.orig 2003-01-28 22:16:15.000000000 -0800 +++ check_ldap.c 2003-11-27 01:31:26.810335706 -0800 @@ -50,6 +50,7 @@ unsigned int ld_port = DEFAULT_PORT; int warn_time = UNDEFINED; int crit_time = UNDEFINED; +int protocol_version = 2; int main (int argc, char *argv[]) @@ -58,7 +59,7 @@ LDAP *ld; LDAPMessage *result; - int t_diff; + int t_diff,rc; time_t time0, time1; if (process_arguments (argc, argv) == ERROR) @@ -79,6 +80,8 @@ printf ("Could not connect to the server at port %i\n", ld_port); return STATE_CRITICAL; } + rc = protocol_version; + ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &rc); /* bind to the ldap server */ if (ldap_bind_s (ld, ld_binddn, ld_passwd, LDAP_AUTH_SIMPLE) != @@ -145,6 +148,7 @@ {"port", required_argument, 0, 'p'}, {"warn", required_argument, 0, 'w'}, {"crit", required_argument, 0, 'c'}, + {"protocol", required_argument, 0, 'R'}, {0, 0, 0, 0} }; #endif @@ -159,9 +163,9 @@ while (1) { #ifdef HAVE_GETOPT_H - c = getopt_long (argc, argv, "hVt:c:w:H:b:p:a:D:P:", longopts, &option_index); + c = getopt_long (argc, argv, "hVt:c:w:H:b:p:a:D:P:R:", longopts, &option_index); #else - c = getopt (argc, argv, "+?hVt:c:w:H:b:p:a:D:P:"); + c = getopt (argc, argv, "+?hVt:c:w:H:b:p:a:D:P:R:"); #endif if (c == -1 || c == EOF) @@ -203,6 +207,9 @@ case 'c': crit_time = atoi (optarg); break; + case 'R': + protocol_version = atoi (optarg); + break; default: usage ("check_ldap: could not parse arguments\n"); break; @@ -250,6 +257,7 @@ "\t-D [--bind] ... ldap bind DN (if required)\n" "\t-P [--pass] ... ldap password (if required)\n" "\t-p [--port] ... ldap port (default: %d)\n" + "\t-R [--protocol] ... ldap protocol version (default: 2)\n" "\t-w [--warn] ... time in secs. - if the exceeds the STATE_WARNING will be returned\n" "\t-c [--crit] ... time in secs. - if the exceeds the STATE_CRITICAL will be returned\n" "\n", DEFAULT_PORT); @@ -261,6 +269,7 @@ { printf ("Usage: %s -H -b [-p ] [-a ] [-D ]\n" - " [-P ] [-w ] [-c ] [-t timeout]\n" + " [-P ] [-w ] [-c ] [-t timeout] " + "[-R ]\n" "(Note: all times are in seconds.)\n", progname); }