]> git.sur5r.net Git - openldap/blob - doc/man/man3/ldap_get_option.3
first round of fixes; add TCP keepalive stuff.
[openldap] / doc / man / man3 / ldap_get_option.3
1 .TH LDAP_GET_OPTION 3 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .\" Copyright 1998-2009 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
5 .SH NAME
6 ldap_get_option, ldap_set_option \- LDAP option handling routines
7 .SH LIBRARY
8 OpenLDAP LDAP (libldap, \-lldap)
9 .SH SYNOPSIS
10 .nf
11 .B #include <ldap.h>
12 .LP
13 .BI "int ldap_get_option(LDAP *" ld ", int " option ", void *" outvalue ");"
14 .LP
15 .BI "int ldap_set_option(LDAP *" ld ", int " option ", const void *" invalue ");"
16 .SH DESCRIPTION
17 .LP
18 These routines provide access to options stored either in a LDAP handle
19 or as global options, where applicable.
20 They make use of a neutral interface, where the type of the value
21 either retrieved by 
22 .BR ldap_get_option (3)
23 or set by
24 .BR ldap_set_option (3)
25 is cast to 
26 .BR "void *" .
27 The actual type is determined based on the value of the
28 .B option
29 argument.
30 Global options are set/retrieved by passing a NULL LDAP handle.
31 .TP
32 .B LDAP_OPT_API_FEATURE_INFO
33 Fills-in a 
34 .BR "LDAPAPIFeatureInfo" ;
35 .BR outvalue 
36 must be a 
37 .BR "LDAPAPIFeatureInfo *" ,
38 pointing to an already allocated struct.
39 This is a read-only option.
40 .TP
41 .B LDAP_OPT_API_INFO
42 Fills-in a 
43 .BR "struct ldapapiinfo" ;
44 .BR outvalue 
45 must be a 
46 .BR "struct ldapapiinfo *" ,
47 pointing to an already allocated struct.
48 This is a read-only option.
49 .TP
50 .B LDAP_OPT_CLIENT_CONTROLS
51 Sets/gets the client-side controls to be used for all operations.
52 This is now deprecated as modern LDAP C API provides replacements
53 for all main operations which accepts client-side controls as
54 explicit arguments; see for example
55 .BR ldap_search_ext (3),
56 .BR ldap_add_ext (3),
57 .BR ldap_modify_ext (3)
58 and so on.
59 .BR outvalue
60 must be 
61 .BR "LDAPControl ***" ,
62 and the caller is responsible of freeing the returned controls, if any,
63 by calling 
64 .BR ldap_controls_free (3),
65 while
66 .BR invalue
67 must be 
68 .BR "LDAPControl **" ;
69 the library duplicates the controls passed via
70 .BR invalue .
71 .TP
72 .B LDAP_OPT_CONNECT_ASYNC
73 Sets/gets the status of the asynchronous connect flag.
74 The value should either be
75 .BR LDAP_OPT_OFF
76 or
77 .BR LDAP_OPT_ON .
78 When set, the library will call
79 .BR connect (2)
80 and return, without waiting for response.
81 This leaves the handler in a connecting state.
82 Subsequent calls to library routines will poll for completion
83 of the connect before performing further operations.
84 As a consequence, library calls that need to establish a connection
85 with a DSA do not block even for the network timeout
86 (option
87 .BR LDAP_OPT_NETWORK_TIMEOUT ).
88 This option is OpenLDAP specific.
89 .TP
90 .B LDAP_OPT_CONNECT_CB
91 This option allows to set a connect callback.
92 The 
93 .B invalue
94 must be a pointer to a
95 .IR "struct ldap_conncb" .
96 Callbacks are executed in last in-first served order.
97 Hanlder-specific callbacks are executed first, followed by global ones.
98 Right before freeing the callback structure, the
99 .I lc_del
100 callback handler is passed a 
101 .B NULL
102 .IR Sockbuf .
103 Calling
104 .BR ldap_get_option (3)
105 for this option removes the callback whose pointer matches
106 .BR outvalue .
107 This option is OpenLDAP specific.
108 .TP
109 .B LDAP_OPT_DEBUG_LEVEL
110 Sets/gets the debug level of the client library.
111 Both
112 .BR outvalue
113 and
114 .BR invalue
115 must be a 
116 .BR "int *" .
117 This option is OpenLDAP specific.
118 .TP
119 .B LDAP_OPT_DEFBASE
120 Sets/gets a string containing the DN to be used as default base
121 for search operations.
122 .BR outvalue
123 must be a
124 .BR "char **" ,
125 and the caller is responsible of freeing the returned string by calling
126 .BR ldap_memfree (3),
127 while
128 .BR invalue
129 must be a 
130 .BR "char *" ;
131 the library duplicates the corresponding string.
132 This option is OpenLDAP specific.
133 .TP
134 .B LDAP_OPT_DEREF
135 Sets/gets the value that defines when alias dereferencing must occur.
136 .BR outvalue 
137 and 
138 .BR invalue
139 must be
140 .BR "int *" ,
141 and they cannot be NULL.
142 The value of 
143 .BR *invalue
144 should be one of
145 .BR LDAP_DEREF_NEVER
146 (the default),
147 .BR LDAP_DEREF_SEARCHING ,
148 .BR LDAP_DEREF_FINDING ,
149 or
150 .BR LDAP_DEREF_ALWAYS .
151 Note that this has ever been the only means to determine alias dereferencing
152 within search operations.
153 .TP
154 .B LDAP_OPT_DESC
155 Returns the file descriptor associated to the socket buffer
156 of the LDAP handle passed in as 
157 .BR ld ;
158 .BR outvalue
159 must be a 
160 .BR "int *" .
161 This is a read-only, handler-specific option.
162 .TP
163 .B LDAP_OPT_DIAGNOSTIC_MESSAGE
164 Sets/gets a string containing the error string associated to the LDAP handle.
165 This option was formerly known as 
166 .BR LDAP_OPT_ERROR_STRING .
167 .BR outvalue
168 must be a
169 .BR "char **" ,
170 and the caller is responsible of freeing the returned string by calling
171 .BR ldap_memfree (3),
172 while
173 .BR invalue
174 must be a 
175 .BR "char *" ;
176 the library duplicates the corresponding string.
177 .TP
178 .B LDAP_OPT_HOST_NAME
179 Sets/gets a space-separated list of hosts to be contacted by the library 
180 when trying to establish a connection.
181 This is now deprecated in favor of
182 .BR LDAP_OPT_URI .
183 .BR outvalue
184 must be a 
185 .BR "char **" ,
186 and the caller is responsible of freeing the resulting string by calling
187 .BR ldap_memfree (3),
188 while
189 .BR invalue
190 must be a 
191 .BR "char *" ;
192 the library duplicates the corresponding string.
193 .TP
194 .B LDAP_OPT_MATCHED_DN
195 Sets/gets a string containing the matched DN associated to the LDAP handle.
196 .BR outvalue
197 must be a
198 .BR "char **" ,
199 and the caller is responsible of freeing the returned string by calling
200 .BR ldap_memfree (3),
201 while
202 .BR invalue
203 must be a 
204 .BR "char *" ;
205 the library duplicates the corresponding string.
206 .TP
207 .B LDAP_OPT_NETWORK_TIMEOUT
208 Sets/gets the network timeout value after which
209 .BR poll (2)/ select (2) 
210 following a 
211 .BR connect (2) 
212 returns in case of no activity.
213 .B outvalue
214 must be a 
215 .BR "struct timeval **"
216 (the caller has to free
217 .BR *outvalue ) ,
218 and
219 .B invalue
220 must be a 
221 .BR "struct timeval *" ,
222 and they cannot be NULL. Using a struct with seconds set to \-1 results
223 in an infinite timeout, which is the default.
224 This option is OpenLDAP specific.
225 .TP
226 .B LDAP_OPT_PROTOCOL_VERSION
227 Sets/gets the protocol version.
228 .BR outvalue
229 and
230 .BR invalue
231 must be 
232 .BR "int *" .
233 .TP
234 .B LDAP_OPT_REFERRAL_URLS
235 Sets/gets an array containing the referral URIs associated to the LDAP handle.
236 .BR outvalue
237 must be a
238 .BR "char ***" ,
239 and the caller is responsible of freeing the returned string by calling
240 .BR ber_memvfree (3),
241 while
242 .BR invalue
243 must be a NULL-terminated
244 .BR "char **" ;
245 the library duplicates the corresponding string.
246 This option is OpenLDAP specific.
247 .TP
248 .B LDAP_OPT_REFERRALS
249 Determines whether the library should implicitly chase referrals or not.
250 .BR outvalue
251 and
252 .BR invalue
253 must be 
254 .BR "int *" ;
255 their value should either be
256 .BR LDAP_OPT_OFF
257 or
258 .BR LDAP_OPT_ON .
259 .TP
260 .B LDAP_OPT_REFHOPLIMIT
261 This option is OpenLDAP specific.
262 It is not currently implemented.
263 .TP
264 .B LDAP_OPT_RESTART
265 Determines whether the library should implicitly restart connections (FIXME).
266 .BR outvalue
267 and
268 .BR invalue
269 must be 
270 .BR "int *" ;
271 their value should either be
272 .BR LDAP_OPT_OFF
273 or
274 .BR LDAP_OPT_ON .
275 .TP
276 .B LDAP_OPT_RESULT_CODE
277 Sets/gets the LDAP result code associated to the handle.
278 This option was formerly known as
279 .BR LDAP_OPT_ERROR_NUMBER .
280 Both
281 .BR outvalue
282 and
283 .BR invalue
284 must be a 
285 .BR "int *" .
286 .TP
287 .B LDAP_OPT_SERVER_CONTROLS
288 Sets/gets the server-side controls to be used for all operations.
289 This is now deprecated as modern LDAP C API provides replacements
290 for all main operations which accepts server-side controls as
291 explicit arguments; see for example
292 .BR ldap_search_ext (3),
293 .BR ldap_add_ext (3),
294 .BR ldap_modify_ext (3)
295 and so on.
296 .BR outvalue
297 must be 
298 .BR "LDAPControl ***" ,
299 and the caller is responsible of freeing the returned controls, if any,
300 by calling 
301 .BR ldap_controls_free (3),
302 while
303 .BR invalue
304 must be 
305 .BR "LDAPControl **" ;
306 the library duplicates the controls passed via
307 .BR invalue .
308 .TP
309 .B LDAP_OPT_SIZELIMIT
310 Sets/gets the value that defines the maximum number of entries
311 to be returned by a search operation.
312 .BR outvalue 
313 and 
314 .BR invalue
315 must be
316 .BR "int *" ,
317 and they cannot be NULL.
318 .TP
319 .B LDAP_OPT_SOCKBUF
320 Returns a pointer to the socket buffer of the LDAP handle passed in as
321 .BR ld ;
322 .BR outvalue
323 must be a 
324 .BR "Sockbuf **" .
325 This is a read-only, handler-specific option.
326 This option is OpenLDAP specific.
327 .TP
328 .B LDAP_OPT_TIMELIMIT
329 Sets/gets the value that defines the time limit after which
330 a search operation should be terminated by the server.
331 .BR outvalue 
332 and 
333 .BR invalue
334 must be
335 .BR "int *" ,
336 and they cannot be NULL.
337 .TP
338 .B LDAP_OPT_TIMEOUT
339 Sets/gets a timeout value for the synchronous API calls.
340 .B outvalue
341 must be a 
342 .BR "struct timeval **"
343 (the caller has to free
344 .BR *outvalue ) ,
345 and
346 .B invalue
347 must be a 
348 .BR "struct timeval *" ,
349 and they cannot be NULL. Using a struct with seconds set to \-1 results
350 in an infinite timeout, which is the default.
351 This option is OpenLDAP specific.
352 .TP
353 .B LDAP_OPT_URI
354 Sets/gets a comma- or space-separated list of URIs to be contacted by the library 
355 when trying to establish a connection.
356 .BR outvalue
357 must be a 
358 .BR "char **" ,
359 and the caller is responsible of freeing the resulting string by calling
360 .BR ldap_memfree (3),
361 while
362 .BR invalue
363 must be a 
364 .BR "char *" ;
365 the library parses the string into a list of 
366 .BR LDAPURLDesc
367 structures, so the invocation of 
368 .BR ldap_set_option (3)
369 may fail if URL parsing fails.
370 URIs may only contain the
371 .BR schema ,
372 the
373 .BR host ,
374 and the
375 .BR port
376 fields.
377 This option is OpenLDAP specific.
378 .SH SASL OPTIONS
379 The SASL options are OpenLDAP specific.
380 .TP
381 .B LDAP_OPT_X_SASL_AUTHCID
382 Gets the SASL authentication identity;
383 .BR outvalue
384 must be a
385 .BR "char **" ,
386 its content needs to be freed by the caller.
387 .TP
388 .B LDAP_OPT_X_SASL_AUTHZID
389 Gets the SASL authorization identity;
390 .BR outvalue
391 must be a
392 .BR "char **" ,
393 its content needs to be freed by the caller.
394 .TP
395 .B LDAP_OPT_X_SASL_MAXBUFSIZE
396 Gets/sets SASL maximum buffer size;
397 .BR invalue
398 must be
399 .BR "const ber_len_t *" ,
400 while
401 .BR outvalue
402 must be
403 .BR "ber_len_t *" .
404 See also
405 .BR LDAP_OPT_X_SASL_SECPROPS .
406 .TP
407 .B LDAP_OPT_X_SASL_MECH
408 Gets the SASL mechanism;
409 .BR outvalue
410 must be a
411 .BR "char **" ,
412 its content needs to be freed by the caller.
413 .TP
414 .B LDAP_OPT_X_SASL_MECHLIST
415 Gets the list of the available mechanisms,
416 in form of a NULL-terminated array of strings;
417 .BR outvalue
418 must be
419 .BR "char ***" .
420 .TP
421 .B LDAP_OPT_X_SASL_NOCANON      
422 Sets/gets the NOCANON flag.
423 When unset, the hostname is canonicalized.
424 The value should either be
425 .BR LDAP_OPT_OFF
426 or
427 .BR LDAP_OPT_ON .
428 .TP
429 .B LDAP_OPT_X_SASL_REALM
430 Gets the SASL realm;
431 .BR outvalue
432 must be a
433 .BR "char **" ,
434 its content needs to be freed by the caller.
435 .TP
436 .B LDAP_OPT_X_SASL_SECPROPS
437 Sets the SASL secprops;
438 .BR invalue
439 must be a
440 .BR "char *" ,
441 containing a comma-separated list of properties.
442 Legal values are:
443 .BR none ,
444 .BR nodict ,
445 .BR noplain ,
446 .BR noactive ,
447 .BR passcred ,
448 .BR forwardsec ,
449 .BR noanonymous ,
450 .BR minssf=<minssf> ,
451 .BR maxssf=<maxssf> ,
452 .BR maxbufsize=<maxbufsize> .
453 .TP
454 .B LDAP_OPT_X_SASL_SSF
455 Gets the SASL SSF;
456 .BR outvalue
457 must be a
458 .BR "ber_len_t *" .
459 .TP
460 .B LDAP_OPT_X_SASL_SSF_EXTERNAL
461 Sets the SASL SSF value related to an authentication
462 performed using an EXTERNAL mechanism;
463 .BR invalue
464 must be a
465 .BR "ber_len_t *" .
466 .TP
467 .B LDAP_OPT_X_SASL_SSF_MAX
468 Gets/sets SASL maximum SSF;
469 .BR invalue
470 must be
471 .BR "const ber_len_t *" ,
472 while
473 .BR outvalue
474 must be
475 .BR "ber_len_t *" .
476 See also
477 .BR LDAP_OPT_X_SASL_SECPROPS .
478 .TP
479 .B LDAP_OPT_X_SASL_SSF_MIN
480 Gets/sets SASL minimum SSF;
481 .BR invalue
482 must be
483 .BR "const ber_len_t *" ,
484 while
485 .BR outvalue
486 must be
487 .BR "ber_len_t *" .
488 See also
489 .BR LDAP_OPT_X_SASL_SECPROPS .
490 .TP
491 .B LDAP_OPT_X_SASL_USERNAME
492 Gets the SASL username;
493 .BR outvalue
494 must be a
495 .BR "char **" .
496 Its content needs to be freed by the caller.
497 .SH TCP OPTIONS
498 The TCP options are OpenLDAP specific.
499 Mainly intended for use with Linux, they may not be portable.
500 .TP
501 .B LDAP_OPT_X_KEEPALIVE_IDLE
502 Sets/gets the number of seconds a connection needs to remain idle
503 before TCP starts sending keepalive probes.
504 .BR invalue
505 must be
506 .BR "const int *" ;
507 .BR outvalue
508 must be
509 .BR "int *" .
510 .TP
511 .B LDAP_OPT_X_KEEPALIVE_PROBES
512 Sets/gets the maximum number of keepalive probes TCP should send
513 before dropping the connection.
514 .BR invalue
515 must be
516 .BR "const int *" ;
517 .BR outvalue
518 must be
519 .BR "int *" .
520 .TP
521 .B LDAP_OPT_X_KEEPALIVE_INTERVAL
522 Sets/gets the interval in seconds between individual keepalive probes.
523 .BR invalue
524 must be
525 .BR "const int *" ;
526 .BR outvalue
527 must be
528 .BR "int *" .
529 .SH TLS OPTIONS
530 The TLS options are OpenLDAP specific.
531 .\".TP
532 .\".B LDAP_OPT_X_TLS
533 .\"Sets/gets the TLS mode.
534 .TP
535 .B LDAP_OPT_X_TLS_CACERTDIR
536 Sets/gets the path of the directory containing CA certificates.
537 .BR invalue
538 must be
539 .BR "const char *" ;
540 .BR outvalue
541 must be
542 .BR "char **" ,
543 and its contents need to be freed by the caller.
544 .TP
545 .B LDAP_OPT_X_TLS_CACERTFILE
546 Sets/gets the full-path CA certificate file.
547 .BR invalue
548 must be
549 .BR "const char *" ;
550 .BR outvalue
551 must be
552 .BR "char **" ,
553 and its contents need to be freed by the caller.
554 .TP
555 .B LDAP_OPT_X_TLS_CERTFILE
556 Sets/gets the full-path certificate file.
557 .BR invalue
558 must be
559 .BR "const char *" ;
560 .BR outvalue
561 must be
562 .BR "char **" ,
563 and its contents need to be freed by the caller.
564 .TP
565 .B LDAP_OPT_X_TLS_CIPHER_SUITE
566 Sets/gets the allowed cipher suite.
567 .BR invalue
568 must be
569 .BR "const char *" ;
570 .BR outvalue
571 must be
572 .BR "char **" ,
573 and its contents need to be freed by the caller.
574 .TP
575 .B LDAP_OPT_X_TLS_CONNECT_ARG
576 Sets/gets the connection callback argument.
577 .BR invalue
578 must be
579 .BR "const void *" ;
580 .BR outvalue
581 must be
582 .BR "void **" .
583 .TP
584 .B LDAP_OPT_X_TLS_CONNECT_CB
585 Sets/gets the connection callback handle.
586 .BR invalue
587 must be
588 .BR "const LDAP_TLS_CONNECT_CB *" ;
589 .BR outvalue
590 must be
591 .BR "LDAP_TLS_CONNECT_CB **" .
592 .TP
593 .B LDAP_OPT_X_TLS_CRLCHECK
594 Sets/gets the CRL evaluation strategy, one of
595 .BR LDAP_OPT_X_TLS_CRL_NONE ,
596 .BR LDAP_OPT_X_TLS_CRL_PEER ,
597 or
598 .BR LDAP_OPT_X_TLS_CRL_ALL .
599 .BR invalue
600 must be
601 .BR "const int *" ;
602 .BR outvalue
603 must be
604 .BR "int *" .
605 Requires OpenSSL.
606 .TP
607 .B LDAP_OPT_X_TLS_CRLFILE
608 Sets/gets the full-path of the CRL file.
609 .BR invalue
610 must be
611 .BR "const char *" ;
612 .BR outvalue
613 must be
614 .BR "char **" ,
615 and its contents need to be freed by the caller.
616 This option is only valid for GNUtls.
617 .TP
618 .B LDAP_OPT_X_TLS_CTX
619 Sets/gets the OpenSSL CTX.
620 .BR invalue
621 must be
622 .BR "const void *" ;
623 .BR outvalue
624 must be
625 .BR "void **" .
626 .TP
627 .B LDAP_OPT_X_TLS_DHFILE
628 Gets/sets the full-path of the file containing the parameters
629 for Diffie-Hellman ephemeral key exchange.
630 .BR invalue
631 must be
632 .BR "const char *" ;
633 .BR outvalue
634 must be
635 .BR "char **" ,
636 and its contents need to be freed by the caller.
637 Ignored by GNUtls.
638 .TP
639 .B LDAP_OPT_X_TLS_KEYFILE
640 Sets/gets the full-path certificate key file.
641 .BR invalue
642 must be
643 .BR "const char *" ;
644 .BR outvalue
645 must be
646 .BR "char **" ,
647 and its contents need to be freed by the caller.
648 .TP
649 .B LDAP_OPT_X_TLS_NEWCTX
650 Instructs the library to create a new TLS CTX.
651 .BR invalue
652 must be
653 .BR "const int *" .
654 A non-zero value pointed to by
655 .BR invalue
656 tells the library to create a CTX for a server.
657 .TP
658 .B LDAP_OPT_X_TLS_PROTOCOL_MIN
659 Sets/gets the minimum protocol version.
660 .BR invalue
661 must be
662 .BR "const int *" ;
663 .BR outvalue
664 must be
665 .BR "int *" .
666 .TP
667 .B LDAP_OPT_X_TLS_RANDOM_FILE
668 Sets/gets the random file when
669 .I /dev/random
670 and
671 .I /dev/urandom
672 are not available.
673 .BR invalue
674 must be
675 .BR "const char *" ;
676 .BR outvalue
677 must be
678 .BR "char **" ,
679 and its contents need to be freed by the caller.
680 Ignored by GNUtls.
681 .TP
682 .B LDAP_OPT_X_TLS_REQUIRE_CERT
683 Sets/gets the peer certificate checking strategy,
684 one of
685 .BR LDAP_OPT_X_TLS_NEVER ,
686 .BR LDAP_OPT_X_TLS_HARD ,
687 .BR LDAP_OPT_X_TLS_DEMAND ,
688 .BR LDAP_OPT_X_TLS_ALLOW ,
689 .BR LDAP_OPT_X_TLS_TRY .
690 .TP
691 .B LDAP_OPT_X_TLS_SSL_CTX
692 Gets the OpenSSL SSL CTX;
693 .BR outvalue
694 must be
695 .BR "void **" .
696 .SH ERRORS
697 On success, the functions return
698 .BR LDAP_OPT_SUCCESS ,
699 while they may return
700 .B LDAP_OPT_ERROR
701 to indicate a generic option handling error.
702 Occasionally, more specific errors can be returned, like
703 .B LDAP_NO_MEMORY
704 to indicate a failure in memory allocation.
705 .SH NOTES
706 The LDAP libraries with the
707 .B LDAP_OPT_REFERRALS 
708 option set to
709 .B LDAP_OPT_ON
710 (default value) automatically follow referrals using an anonymous bind.
711 Application developers are encouraged to either implement consistent
712 referral chasing features, or explicitly disable referral chasing
713 by setting that option to
714 .BR LDAP_OPT_OFF .
715 .P
716 The protocol version used by the library defaults to LDAPv2 (now historic),
717 which corresponds to the
718 .B LDAP_VERSION2
719 macro.
720 Application developers are encouraged to explicitly set
721 .B LDAP_OPT_PROTOCOL_VERSION
722 to LDAPv3, using the 
723 .B LDAP_VERSION3
724 macro, or to allow users to select the protocol version.
725 .SH SEE ALSO
726 .BR ldap (3),
727 .BR ldap_error (3),
728 .B RFC 4422
729 (http://www.rfc-editor.org),
730 .SH ACKNOWLEDGEMENTS
731 .so ../Project