3 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 /* common.c - common routines for the ldap client tools */
12 #include <ac/stdlib.h>
13 #include <ac/signal.h>
14 #include <ac/string.h>
15 #include <ac/unistd.h>
20 #include "lutil_ldap.h"
21 #include "ldap_defaults.h"
33 char *ldaphost = NULL;
35 #ifdef HAVE_CYRUS_SASL
36 unsigned sasl_flags = LDAP_SASL_AUTOMATIC;
37 char *sasl_realm = NULL;
38 char *sasl_authc_id = NULL;
39 char *sasl_authz_id = NULL;
40 char *sasl_mech = NULL;
41 char *sasl_secprops = NULL;
46 char *assertion = NULL;
51 char *preread_attrs = NULL;
53 char *postread_attrs = NULL;
57 struct berval passwd = { 0, NULL };
70 ldap_pvt_setlocale(LC_MESSAGES, "");
71 ldap_pvt_bindtextdomain(OPENLDAP_PACKAGE, LDAP_LOCALEDIR);
72 ldap_pvt_textdomain(OPENLDAP_PACKAGE);
76 tool_common_usage( void )
78 static const char *const descriptions[] = {
79 N_(" -c continuous operation mode (do not stop on errors)\n"),
80 N_(" -C chase referrals\n"),
81 N_(" -d level set LDAP debugging level to `level'\n"),
82 N_(" -D binddn bind DN\n"),
83 N_(" -e [!]<ctrl>[=<ctrlparam>] general controls (! indicates criticality)\n")
84 N_(" [!]assert=<filter> (an RFC 2254 Filter)\n")
85 N_(" [!]authzid=<authzid> (\"dn:<dn>\" or \"u:<user>\")\n")
86 N_(" [!]manageDSAit\n")
88 N_(" [!]postread[=<attrs>] (a comma-separated attribute list)\n"),
89 N_(" [!]preread[=<attrs>] (a comma-separated attribute list)\n"),
90 N_(" -f file read operations from `file'\n"),
91 N_(" -h host LDAP server\n"),
92 N_(" -H URI LDAP Uniform Resource Indentifier(s)\n"),
93 N_(" -I use SASL Interactive mode\n"),
94 N_(" -k use Kerberos authentication\n"),
95 N_(" -K like -k, but do only step 1 of the Kerberos bind\n"),
96 N_(" -M enable Manage DSA IT control (-MM to make critical)\n"),
97 N_(" -n show what would be done but don't actually do it\n"),
98 N_(" -O props SASL security properties\n"),
99 N_(" -p port port on LDAP server\n"),
100 N_(" -P version procotol version (default: 3)\n"),
101 N_(" -Q use SASL Quiet mode\n"),
102 N_(" -R realm SASL realm\n"),
103 N_(" -U authcid SASL authentication identity\n"),
104 N_(" -v run in verbose mode (diagnostics to standard output)\n"),
105 N_(" -V print version info (-VV only)\n"),
106 N_(" -w passwd bind password (for simple authentication)\n"),
107 N_(" -W prompt for bind password\n"),
108 N_(" -x Simple authentication\n"),
109 N_(" -X authzid SASL authorization identity (\"dn:<dn>\" or \"u:<user>\")\n"),
110 N_(" -y file Read password from file\n"),
111 N_(" -Y mech SASL mechanism\n"),
112 N_(" -Z Start TLS request (-ZZ to require successful response)\n"),
115 const char *const *cpp;
117 fputs( _("Common options:\n"), stderr );
118 for( cpp = descriptions; *cpp != NULL; cpp++ ) {
119 if( strchr( options, (*cpp)[3] ) ) {
120 fputs( _(*cpp), stderr );
127 tool_args( int argc, char **argv )
131 while (( i = getopt( argc, argv, options )) != EOF ) {
133 char *control, *cvalue;
135 case 'c': /* continuous operation mode */
142 debug |= atoi( optarg );
144 case 'D': /* bind DN */
145 if( binddn != NULL ) {
146 fprintf( stderr, "%s: -D previously specified\n", prog );
147 exit( EXIT_FAILURE );
149 binddn = ber_strdup( optarg );
151 case 'e': /* general controls */
152 /* should be extended to support comma separated list of
153 * [!]key[=value] parameters, e.g. -e !foo,bar=567
158 if( optarg[0] == '!' ) {
163 control = ber_strdup( optarg );
164 if ( (cvalue = strchr( control, '=' )) != NULL ) {
168 if ( strcasecmp( control, "assert" ) == 0 ) {
170 fprintf( stderr, "assert control previously specified\n");
171 exit( EXIT_FAILURE );
173 if( cvalue == NULL ) {
174 fprintf( stderr, "assert: control value expected\n" );
178 assertctl = 1 + crit;
180 assert( assertion == NULL );
183 } else if ( strcasecmp( control, "authzid" ) == 0 ) {
184 if( authzid != NULL ) {
185 fprintf( stderr, "authzid control previously specified\n");
186 exit( EXIT_FAILURE );
188 if( cvalue == NULL ) {
189 fprintf( stderr, "authzid: control value expected\n" );
193 fprintf( stderr, "authzid: must be marked critical\n" );
197 assert( authzid == NULL );
200 } else if ( strcasecmp( control, "manageDSAit" ) == 0 ) {
203 "manageDSAit control previously specified\n");
204 exit( EXIT_FAILURE );
206 if( cvalue != NULL ) {
208 "manageDSAit: no control value expected\n" );
212 manageDSAit = 1 + crit;
214 } else if ( strcasecmp( control, "noop" ) == 0 ) {
216 fprintf( stderr, "noop control previously specified\n");
217 exit( EXIT_FAILURE );
219 if( cvalue != NULL ) {
220 fprintf( stderr, "noop: no control value expected\n" );
226 } else if ( strcasecmp( control, "preread" ) == 0 ) {
228 fprintf( stderr, "preread control previously specified\n");
229 exit( EXIT_FAILURE );
233 preread_attrs = cvalue;
235 } else if ( strcasecmp( control, "postread" ) == 0 ) {
237 fprintf( stderr, "postread control previously specified\n");
238 exit( EXIT_FAILURE );
242 postread_attrs = cvalue;
245 fprintf( stderr, "Invalid general control name: %s\n",
250 case 'f': /* read from file */
251 if( infile != NULL ) {
252 fprintf( stderr, "%s: -f previously specified\n", prog );
253 exit( EXIT_FAILURE );
255 infile = ber_strdup( optarg );
257 case 'h': /* ldap host */
258 if( ldaphost != NULL ) {
259 fprintf( stderr, "%s: -h previously specified\n", prog );
260 exit( EXIT_FAILURE );
262 ldaphost = ber_strdup( optarg );
264 case 'H': /* ldap URI */
265 if( ldapuri != NULL ) {
266 fprintf( stderr, "%s: -H previously specified\n", prog );
267 exit( EXIT_FAILURE );
269 ldapuri = ber_strdup( optarg );
272 #ifdef HAVE_CYRUS_SASL
273 if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
274 fprintf( stderr, "%s: incompatible previous "
275 "authentication choice\n",
277 exit( EXIT_FAILURE );
279 authmethod = LDAP_AUTH_SASL;
280 sasl_flags = LDAP_SASL_INTERACTIVE;
283 fprintf( stderr, "%s: was not compiled with SASL support\n",
285 exit( EXIT_FAILURE );
287 case 'k': /* kerberos bind */
288 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
289 if( authmethod != -1 ) {
290 fprintf( stderr, "%s: -k incompatible with previous "
291 "authentication choice\n", prog );
292 exit( EXIT_FAILURE );
294 authmethod = LDAP_AUTH_KRBV4;
296 fprintf( stderr, "%s: not compiled with Kerberos support\n", prog );
297 exit( EXIT_FAILURE );
300 case 'K': /* kerberos bind, part one only */
301 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
302 if( authmethod != -1 ) {
303 fprintf( stderr, "%s: incompatible with previous "
304 "authentication choice\n", prog );
305 exit( EXIT_FAILURE );
307 authmethod = LDAP_AUTH_KRBV41;
309 fprintf( stderr, "%s: not compiled with Kerberos support\n", prog );
310 exit( EXIT_FAILURE );
314 /* enable Manage DSA IT */
317 case 'n': /* print operations, don't actually do them */
321 #ifdef HAVE_CYRUS_SASL
322 if( sasl_secprops != NULL ) {
323 fprintf( stderr, "%s: -O previously specified\n", prog );
324 exit( EXIT_FAILURE );
326 if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
327 fprintf( stderr, "%s: incompatible previous "
328 "authentication choice\n", prog );
329 exit( EXIT_FAILURE );
331 authmethod = LDAP_AUTH_SASL;
332 sasl_secprops = ber_strdup( optarg );
334 fprintf( stderr, "%s: not compiled with SASL support\n", prog );
335 exit( EXIT_FAILURE );
340 fprintf( stderr, "%s: -p previously specified\n", prog );
341 exit( EXIT_FAILURE );
343 ldapport = atoi( optarg );
346 switch( atoi(optarg) ) {
348 if( protocol == LDAP_VERSION3 ) {
349 fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
351 exit( EXIT_FAILURE );
353 protocol = LDAP_VERSION2;
356 if( protocol == LDAP_VERSION2 ) {
357 fprintf( stderr, "%s: -P 2 incompatible with version %d\n",
359 exit( EXIT_FAILURE );
361 protocol = LDAP_VERSION3;
364 fprintf( stderr, "%s: protocol version should be 2 or 3\n",
370 #ifdef HAVE_CYRUS_SASL
371 if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
372 fprintf( stderr, "%s: incompatible previous "
373 "authentication choice\n",
375 exit( EXIT_FAILURE );
377 authmethod = LDAP_AUTH_SASL;
378 sasl_flags = LDAP_SASL_QUIET;
381 fprintf( stderr, "%s: not compiled with SASL support\n",
383 exit( EXIT_FAILURE );
386 #ifdef HAVE_CYRUS_SASL
387 if( sasl_realm != NULL ) {
388 fprintf( stderr, "%s: -R previously specified\n", prog );
389 exit( EXIT_FAILURE );
391 if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
392 fprintf( stderr, "%s: incompatible previous "
393 "authentication choice\n",
395 exit( EXIT_FAILURE );
397 authmethod = LDAP_AUTH_SASL;
398 sasl_realm = ber_strdup( optarg );
400 fprintf( stderr, "%s: not compiled with SASL support\n",
402 exit( EXIT_FAILURE );
406 #ifdef HAVE_CYRUS_SASL
407 if( sasl_authc_id != NULL ) {
408 fprintf( stderr, "%s: -U previously specified\n", prog );
409 exit( EXIT_FAILURE );
411 if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
412 fprintf( stderr, "%s: incompatible previous "
413 "authentication choice\n",
415 exit( EXIT_FAILURE );
417 authmethod = LDAP_AUTH_SASL;
418 sasl_authc_id = ber_strdup( optarg );
420 fprintf( stderr, "%s: not compiled with SASL support\n",
422 exit( EXIT_FAILURE );
425 case 'v': /* verbose mode */
428 case 'V': /* version */
431 case 'w': /* password */
432 passwd.bv_val = ber_strdup( optarg );
436 for( p = optarg; *p != '\0'; p++ ) {
440 passwd.bv_len = strlen( passwd.bv_val );
449 #ifdef HAVE_CYRUS_SASL
450 if( sasl_mech != NULL ) {
451 fprintf( stderr, "%s: -Y previously specified\n", prog );
452 exit( EXIT_FAILURE );
454 if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
456 "%s: incompatible with authentication choice\n", prog );
457 exit( EXIT_FAILURE );
459 authmethod = LDAP_AUTH_SASL;
460 sasl_mech = ber_strdup( optarg );
462 fprintf( stderr, "%s: not compiled with SASL support\n", prog );
463 exit( EXIT_FAILURE );
467 if( authmethod != -1 && authmethod != LDAP_AUTH_SIMPLE ) {
468 fprintf( stderr, "%s: incompatible with previous "
469 "authentication choice\n", prog );
470 exit( EXIT_FAILURE );
472 authmethod = LDAP_AUTH_SIMPLE;
475 #ifdef HAVE_CYRUS_SASL
476 if( sasl_authz_id != NULL ) {
477 fprintf( stderr, "%s: -X previously specified\n", prog );
478 exit( EXIT_FAILURE );
480 if( authmethod != -1 && authmethod != LDAP_AUTH_SASL ) {
481 fprintf( stderr, "%s: -X incompatible with "
482 "authentication choice\n", prog );
483 exit( EXIT_FAILURE );
485 authmethod = LDAP_AUTH_SASL;
486 sasl_authz_id = ber_strdup( optarg );
488 fprintf( stderr, "%s: not compiled with SASL support\n", prog );
489 exit( EXIT_FAILURE );
496 fprintf( stderr, "%s: not compiled with TLS support\n", prog );
497 exit( EXIT_FAILURE );
501 if( handle_private_option( i ) ) break;
502 fprintf( stderr, "%s: unrecognized option -%c\n",
509 /* prevent bad linking */
511 api.ldapai_info_version = LDAP_API_INFO_VERSION;
513 if ( ldap_get_option(NULL, LDAP_OPT_API_INFO, &api)
514 != LDAP_OPT_SUCCESS )
516 fprintf( stderr, "%s: ldap_get_option(API_INFO) failed\n", prog );
517 exit( EXIT_FAILURE );
520 if (api.ldapai_info_version != LDAP_API_INFO_VERSION) {
521 fprintf( stderr, "LDAP APIInfo version mismatch: "
522 "got %d, expected %d\n",
523 api.ldapai_info_version, LDAP_API_INFO_VERSION );
524 exit( EXIT_FAILURE );
527 if( api.ldapai_api_version != LDAP_API_VERSION ) {
528 fprintf( stderr, "LDAP API version mismatch: "
529 "got %d, expected %d\n",
530 api.ldapai_api_version, LDAP_API_VERSION );
531 exit( EXIT_FAILURE );
534 if( strcmp(api.ldapai_vendor_name, LDAP_VENDOR_NAME ) != 0 ) {
535 fprintf( stderr, "LDAP vendor name mismatch: "
536 "got %s, expected %s\n",
537 api.ldapai_vendor_name, LDAP_VENDOR_NAME );
538 exit( EXIT_FAILURE );
541 if( api.ldapai_vendor_version != LDAP_VENDOR_VERSION ) {
542 fprintf( stderr, "LDAP vendor version mismatch: "
543 "got %d, expected %d\n",
544 api.ldapai_vendor_version, LDAP_VENDOR_VERSION );
545 exit( EXIT_FAILURE );
549 fprintf( stderr, "%s: %s\t(LDAP library: %s %d)\n",
551 LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION );
552 if (version > 1) exit( EXIT_SUCCESS );
557 protocol = LDAP_VERSION3;
559 if (authmethod == -1 && protocol > LDAP_VERSION2) {
560 #ifdef HAVE_CYRUS_SASL
561 authmethod = LDAP_AUTH_SASL;
563 authmethod = LDAP_AUTH_SIMPLE;
567 if( ldapuri == NULL ) {
568 if( ldapport && ( ldaphost == NULL )) {
569 fprintf( stderr, "%s: -p without -h is invalid.\n", prog );
570 exit( EXIT_FAILURE );
573 if( ldaphost != NULL ) {
574 fprintf( stderr, "%s: -H incompatible with -h\n", prog );
575 exit( EXIT_FAILURE );
578 fprintf( stderr, "%s: -H incompatible with -p\n", prog );
579 exit( EXIT_FAILURE );
582 if( protocol == LDAP_VERSION2 ) {
583 if( authzid || manageDSAit || noop ) {
584 fprintf( stderr, "%s: -e/-M incompatible with LDAPv2\n", prog );
585 exit( EXIT_FAILURE );
589 fprintf( stderr, "%s: -Z incompatible with LDAPv2\n", prog );
590 exit( EXIT_FAILURE );
593 #ifdef HAVE_CYRUS_SASL
594 if( authmethod == LDAP_AUTH_SASL ) {
595 fprintf( stderr, "%s: -[IOQRUXY] incompatible with LDAPv2\n",
597 exit( EXIT_FAILURE );
601 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
602 if ( authmethod == LDAP_AUTH_KRBV4 || authmethod == LDAP_AUTH_KRBV41 ) {
603 fprintf( stderr, "%s: -k/-K incompatible with LDAPv%d\n",
605 exit( EXIT_FAILURE );
613 tool_conn_setup( int not, void (*private_setup)( LDAP * ) )
618 if( ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &debug )
619 != LBER_OPT_SUCCESS )
621 fprintf( stderr, "Could not set LBER_OPT_DEBUG_LEVEL %d\n", debug );
623 if( ldap_set_option( NULL, LDAP_OPT_DEBUG_LEVEL, &debug )
624 != LDAP_OPT_SUCCESS )
626 fprintf( stderr, "Could not set LDAP_OPT_DEBUG_LEVEL %d\n", debug );
631 (void) SIGNAL( SIGPIPE, SIG_IGN );
635 /* connect to server */
636 if( ( ldaphost != NULL || ldapport ) && ( ldapuri == NULL ) ) {
638 fprintf( stderr, "ldap_init( %s, %d )\n",
639 ldaphost != NULL ? ldaphost : "<DEFAULT>",
643 ld = ldap_init( ldaphost, ldapport );
645 char buf[20 + sizeof(": ldap_init")];
646 sprintf( buf, "%.20s: ldap_init", prog );
648 exit( EXIT_FAILURE );
654 fprintf( stderr, "ldap_initialize( %s )\n",
655 ldapuri != NULL ? ldapuri : "<DEFAULT>" );
657 rc = ldap_initialize( &ld, ldapuri );
658 if( rc != LDAP_SUCCESS ) {
660 "Could not create LDAP session handle (%d): %s\n",
661 rc, ldap_err2string(rc) );
662 exit( EXIT_FAILURE );
666 if( private_setup ) private_setup( ld );
669 if( ldap_set_option( ld, LDAP_OPT_REFERRALS,
670 referrals ? LDAP_OPT_ON : LDAP_OPT_OFF ) != LDAP_OPT_SUCCESS )
672 fprintf( stderr, "Could not set LDAP_OPT_REFERRALS %s\n",
673 referrals ? "on" : "off" );
674 exit( EXIT_FAILURE );
677 if( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &protocol )
678 != LDAP_OPT_SUCCESS )
680 fprintf( stderr, "Could not set LDAP_OPT_PROTOCOL_VERSION %d\n",
682 exit( EXIT_FAILURE );
686 ( ldap_start_tls_s( ld, NULL, NULL ) != LDAP_SUCCESS ))
688 ldap_perror( ld, "ldap_start_tls" );
690 exit( EXIT_FAILURE );
700 tool_bind( LDAP *ld )
702 if ( authmethod == LDAP_AUTH_SASL ) {
703 #ifdef HAVE_CYRUS_SASL
707 if( sasl_secprops != NULL ) {
708 rc = ldap_set_option( ld, LDAP_OPT_X_SASL_SECPROPS,
709 (void *) sasl_secprops );
711 if( rc != LDAP_OPT_SUCCESS ) {
713 "Could not set LDAP_OPT_X_SASL_SECPROPS: %s\n",
715 exit( EXIT_FAILURE );
719 defaults = lutil_sasl_defaults( ld,
726 rc = ldap_sasl_interactive_bind_s( ld, binddn,
727 sasl_mech, NULL, NULL,
728 sasl_flags, lutil_sasl_interact, defaults );
730 lutil_sasl_freedefs( defaults );
731 if( rc != LDAP_SUCCESS ) {
732 ldap_perror( ld, "ldap_sasl_interactive_bind_s" );
733 exit( EXIT_FAILURE );
736 fprintf( stderr, "%s: not compiled with SASL support\n",
738 exit( EXIT_FAILURE );
741 if ( ldap_bind_s( ld, binddn, passwd.bv_val, authmethod )
744 ldap_perror( ld, "ldap_bind" );
745 exit( EXIT_FAILURE );
751 /* Set server controls. Add controls extra_c[0..count-1], if set. */
753 tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
755 int i = 0, j, crit = 0, err;
756 LDAPControl c[6], **ctrls;
758 ctrls = (LDAPControl**) malloc(sizeof(c) + (count+1)*sizeof(LDAPControl*));
759 if ( ctrls == NULL ) {
760 fprintf( stderr, "No memory\n" );
761 exit( EXIT_FAILURE );
765 char berbuf[LBER_ELEMENT_SIZEOF];
766 BerElement *ber = (BerElement *)berbuf;
768 if( assertion == NULL || *assertion == '\0' ) {
769 fprintf( stderr, "Assertion=<empty>\n" );
770 exit( EXIT_FAILURE );
773 ber_init2( ber, NULL, LBER_USE_DER );
775 err = ldap_pvt_put_filter( ber, assertion );
777 fprintf( stderr, "assertion encode failed (%d)\n", err );
778 exit( EXIT_FAILURE );
781 err = ber_flatten2( ber, &c[i].ldctl_value, 0 );
783 fprintf( stderr, "assertion flatten failed (%d)\n", err );
784 exit( EXIT_FAILURE );
787 c[i].ldctl_oid = LDAP_CONTROL_ASSERT;
788 c[i].ldctl_iscritical = assertctl > 1;
794 c[i].ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
795 c[i].ldctl_value.bv_val = authzid;
796 c[i].ldctl_value.bv_len = strlen( authzid );
797 c[i].ldctl_iscritical = 1;
803 c[i].ldctl_oid = LDAP_CONTROL_MANAGEDSAIT;
804 c[i].ldctl_value.bv_val = NULL;
805 c[i].ldctl_value.bv_len = 0;
806 c[i].ldctl_iscritical = manageDSAit > 1;
812 c[i].ldctl_oid = LDAP_CONTROL_NOOP;
813 c[i].ldctl_value.bv_val = NULL;
814 c[i].ldctl_value.bv_len = 0;
815 c[i].ldctl_iscritical = noop > 1;
821 char berbuf[LBER_ELEMENT_SIZEOF];
822 BerElement *ber = (BerElement *)berbuf;
825 if( preread_attrs ) {
826 attrs = ldap_str2charray( preread_attrs, "," );
829 ber_init2( ber, NULL, LBER_USE_DER );
831 if( ber_printf( ber, "{v}", attrs ) == -1 ) {
832 fprintf( stderr, "preread attrs encode failed.\n" );
833 exit( EXIT_FAILURE );
836 err = ber_flatten2( ber, &c[i].ldctl_value, 0 );
838 fprintf( stderr, "preread flatten failed (%d)\n", err );
839 exit( EXIT_FAILURE );
842 c[i].ldctl_oid = LDAP_CONTROL_PRE_READ;
843 c[i].ldctl_iscritical = preread > 1;
847 if( attrs ) ldap_charray_free( attrs );
851 char berbuf[LBER_ELEMENT_SIZEOF];
852 BerElement *ber = (BerElement *)berbuf;
855 if( postread_attrs ) {
856 attrs = ldap_str2charray( postread_attrs, "," );
859 ber_init2( ber, NULL, LBER_USE_DER );
861 if( ber_printf( ber, "{v}", attrs ) == -1 ) {
862 fprintf( stderr, "postread attrs encode failed.\n" );
863 exit( EXIT_FAILURE );
866 err = ber_flatten2( ber, &c[i].ldctl_value, 0 );
868 fprintf( stderr, "postread flatten failed (%d)\n", err );
869 exit( EXIT_FAILURE );
872 c[i].ldctl_oid = LDAP_CONTROL_POST_READ;
873 c[i].ldctl_iscritical = postread > 1;
877 if( attrs ) ldap_charray_free( attrs );
881 ctrls[i++] = extra_c++;
885 err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
887 if ( err != LDAP_OPT_SUCCESS ) {
888 for ( j = 0; j < i; j++ ) {
889 if ( ctrls[j]->ldctl_iscritical ) crit = 1;
891 fprintf( stderr, "Could not set %scontrols\n",
892 crit ? "critical " : "" );
897 exit( EXIT_FAILURE );