summaryrefslogtreecommitdiffstats
path: root/web/attachments/68846-check_ldap.c.diff
blob: 3d47577e26be3fdb942a4e6363c0ed2da262fcde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--- 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 <warn> the STATE_WARNING will be returned\n"
 		 "\t-c [--crit] ... time in secs. - if the exceeds <crit> the STATE_CRITICAL will be returned\n"
 		 "\n", DEFAULT_PORT);
@@ -261,6 +269,7 @@
 {
 	printf
 		("Usage: %s -H <host> -b <base_dn> [-p <port>] [-a <attr>] [-D <binddn>]\n"
-		 "         [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n"
+		 "         [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout] "
+                 "[-R <protocol number>]\n"
 		 "(Note: all times are in seconds.)\n", progname);
 }