1 /* config.c - ldap backend configuration file routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2003-2005 The OpenLDAP Foundation.
6 * Portions Copyright 1999-2003 Howard Chu.
7 * Portions Copyright 2000-2003 Pierangelo Masarati.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted only as authorized by the OpenLDAP
14 * A copy of this license is available in the file LICENSE in the
15 * top-level directory of the distribution or, alternatively, at
16 * <http://www.OpenLDAP.org/license.html>.
19 * This work was initially developed by the Howard Chu for inclusion
20 * in OpenLDAP Software and subsequently enhanced by Pierangelo
28 #include <ac/string.h>
30 #include <ac/socket.h>
34 #include "back-ldap.h"
38 /* for advanced URL parsing */
39 #include "../../../libraries/libldap/ldap-int.h"
41 static SLAP_EXTOP_MAIN_FN ldap_back_exop_whoami;
43 static ConfigDriver ldap_back_cf_gen;
46 LDAP_BACK_CFG_URI = 1,
48 LDAP_BACK_CFG_ACL_AUTHCDN,
49 LDAP_BACK_CFG_ACL_PASSWD,
50 LDAP_BACK_CFG_ACL_METHOD,
51 LDAP_BACK_CFG_ACL_BIND,
52 LDAP_BACK_CFG_IDASSERT_MODE,
53 LDAP_BACK_CFG_IDASSERT_AUTHCDN,
54 LDAP_BACK_CFG_IDASSERT_PASSWD,
55 LDAP_BACK_CFG_IDASSERT_AUTHZFROM,
56 LDAP_BACK_CFG_IDASSERT_METHOD,
57 LDAP_BACK_CFG_IDASSERT_BIND,
62 LDAP_BACK_CFG_TIMEOUT,
66 static ConfigTable ldapcfg[] = {
67 { "uri", "uri", 2, 2, 0,
68 ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_URI,
69 ldap_back_cf_gen, "( OLcfgDbAt:0.14 "
71 "DESC 'URI (list) for remote DSA' "
72 "SYNTAX OMsDirectoryString "
75 { "tls", "what", 2, 2, 0,
76 ARG_MAGIC|LDAP_BACK_CFG_TLS,
77 ldap_back_cf_gen, "( OLcfgDbAt:3.1 "
78 "NAME 'olcDbStartTLS' "
80 "SYNTAX OMsDirectoryString "
83 { "acl-authcDN", "DN", 2, 2, 0,
84 ARG_DN|ARG_MAGIC|LDAP_BACK_CFG_ACL_AUTHCDN,
85 ldap_back_cf_gen, "( OLcfgDbAt:3.2 "
86 "NAME 'olcDbACLAuthcDn' "
87 "DESC 'Remote ACL administrative identity' "
92 /* deprecated, will be removed; aliases "acl-authcDN" */
93 { "binddn", "DN", 2, 2, 0,
94 ARG_DN|ARG_MAGIC|LDAP_BACK_CFG_ACL_AUTHCDN,
95 ldap_back_cf_gen, NULL, NULL, NULL },
96 { "acl-passwd", "cred", 2, 2, 0,
97 ARG_MAGIC|LDAP_BACK_CFG_ACL_PASSWD,
98 ldap_back_cf_gen, "( OLcfgDbAt:3.3 "
99 "NAME 'olcDbACLPasswd' "
100 "DESC 'Remote ACL administrative identity credentials' "
102 "SYNTAX OMsDirectoryString "
105 /* deprecated, will be removed; aliases "acl-passwd" */
106 { "bindpw", "cred", 2, 2, 0,
107 ARG_MAGIC|LDAP_BACK_CFG_ACL_PASSWD,
108 ldap_back_cf_gen, NULL, NULL, NULL },
109 /* deprecated, will be removed; aliases "acl-bind" */
110 { "acl-method", "args", 2, 0, 0,
111 ARG_MAGIC|LDAP_BACK_CFG_ACL_METHOD,
112 ldap_back_cf_gen, NULL, NULL, NULL },
113 { "acl-bind", "args", 2, 0, 0,
114 ARG_MAGIC|LDAP_BACK_CFG_ACL_BIND,
115 ldap_back_cf_gen, "( OLcfgDbAt:3.4 "
116 "NAME 'olcDbACLBind' "
117 "DESC 'Remote ACL administrative identity auth bind configuration' "
118 "SYNTAX OMsDirectoryString "
121 { "idassert-authcDN", "DN", 2, 2, 0,
122 ARG_DN|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_AUTHCDN,
123 ldap_back_cf_gen, "( OLcfgDbAt:3.5 "
124 "NAME 'olcDbIDAssertAuthcDn' "
125 "DESC 'Remote Identity Assertion administrative identity' "
130 /* deprecated, will be removed; partially aliases "idassert-authcDN" */
131 { "proxyauthzdn", "DN", 2, 2, 0,
132 ARG_DN|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_AUTHCDN,
133 ldap_back_cf_gen, NULL, NULL, NULL },
134 { "idassert-passwd", "cred", 2, 2, 0,
135 ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_PASSWD,
136 ldap_back_cf_gen, "( OLcfgDbAt:3.6 "
137 "NAME 'olcDbIDAssertPasswd' "
138 "DESC 'Remote Identity Assertion administrative identity credentials' "
140 "SYNTAX OMsDirectoryString "
143 /* deprecated, will be removed; partially aliases "idassert-passwd" */
144 { "proxyauthzpw", "cred", 2, 2, 0,
145 ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_PASSWD,
146 ldap_back_cf_gen, NULL, NULL, NULL },
147 { "idassert-bind", "args", 2, 0, 0,
148 ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_BIND,
149 ldap_back_cf_gen, "( OLcfgDbAt:3.7 "
150 "NAME 'olcDbIDAssertBind' "
151 "DESC 'Remote Identity Assertion administrative identity auth bind configuration' "
152 "SYNTAX OMsDirectoryString "
155 { "idassert-method", "args", 2, 0, 0,
156 ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_METHOD,
157 ldap_back_cf_gen, NULL, NULL, NULL },
158 { "idassert-mode", "mode>|u:<user>|[dn:]<DN", 2, 0, 0,
159 ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_MODE,
160 ldap_back_cf_gen, "( OLcfgDbAt:3.8 "
161 "NAME 'olcDbIDAssertMode' "
162 "DESC 'Remote Identity Assertion mode' "
164 "SYNTAX OMsDirectoryString "
167 { "idassert-authzFrom", "authzRule", 2, 2, 0,
168 ARG_MAGIC|LDAP_BACK_CFG_IDASSERT_AUTHZFROM,
169 ldap_back_cf_gen, "( OLcfgDbAt:3.9 "
170 "NAME 'olcDbIDAssertAuthzFrom' "
171 "DESC 'Remote Identity Assertion authz rules' "
172 "SYNTAX OMsDirectoryString "
173 "X-ORDERED 'VALUES' )",
175 { "rebind-as-user", "NO|yes", 1, 2, 0,
176 ARG_MAGIC|LDAP_BACK_CFG_REBIND,
177 ldap_back_cf_gen, "( OLcfgDbAt:3.10 "
178 "NAME 'olcDbRebindAsUser' "
179 "DESC 'Rebind as user' "
180 "SYNTAX OMsDirectoryString "
183 { "chase-referrals", "YES|no", 2, 2, 0,
184 ARG_MAGIC|LDAP_BACK_CFG_CHASE,
185 ldap_back_cf_gen, "( OLcfgDbAt:3.11 "
186 "NAME 'olcDbChaseReferrals' "
187 "DESC 'Chase referrals' "
188 "SYNTAX OMsDirectoryString "
191 { "t-f-support", "NO|yes|discover", 2, 2, 0,
192 ARG_MAGIC|LDAP_BACK_CFG_T_F,
193 ldap_back_cf_gen, "( OLcfgDbAt:3.12 "
194 "NAME 'olcDbTFSupport' "
195 "DESC 'Absolute filters support' "
196 "SYNTAX OMsDirectoryString "
199 { "proxy-whoami", "NO|yes", 1, 2, 0,
200 ARG_MAGIC|LDAP_BACK_CFG_WHOAMI,
201 ldap_back_cf_gen, "( OLcfgDbAt:3.13 "
202 "NAME 'olcDbProxyWhoAmI' "
203 "DESC 'Proxy whoAmI exop' "
204 "SYNTAX OMsDirectoryString "
207 { "timeout", "timeout", 0, 2, 0,
208 ARG_MAGIC|LDAP_BACK_CFG_TIMEOUT,
209 ldap_back_cf_gen, "( OLcfgDbAt:3.14 "
210 "NAME 'olcDbTimeout' "
211 "DESC 'Per-operation timeouts' "
212 "SYNTAX OMsDirectoryString "
215 { "suffixmassage", "[virtual]> <real", 2, 3, 0,
216 ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_REWRITE,
217 ldap_back_cf_gen, NULL, NULL, NULL },
218 { "map", "attribute|objectClass> [*|<local>] *|<remote", 3, 4, 0,
219 ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_REWRITE,
220 ldap_back_cf_gen, NULL, NULL, NULL },
221 { "rewrite", "<arglist>", 2, 4, STRLENOF( "rewrite" ),
222 ARG_STRING|ARG_MAGIC|LDAP_BACK_CFG_REWRITE,
223 ldap_back_cf_gen, NULL, NULL, NULL },
224 { NULL, NULL, 0, 0, 0, ARG_IGNORED,
225 NULL, NULL, NULL, NULL }
228 static ConfigOCs ldapocs[] = {
230 "NAME 'olcLDAPConfig' "
231 "DESC 'LDAP backend configuration' "
232 "SUP olcDatabaseConfig "
234 "MAY ( olcDbStartTLS "
238 "$ olcDbIDAssertAuthcDn "
239 "$ olcDbIDAssertPasswd "
240 "$ olcDbIDAssertBind "
241 "$ olcDbIDAssertMode "
242 "$ olcDbIDAssertAuthzFrom "
243 "$ olcDbRebindAsUser "
244 "$ olcDbChaseReferrals "
246 "$ olcDbProxyWhoAmI "
249 Cft_Database, ldapcfg},
253 #define LDAP_BACK_C_NO (0x0U)
254 #define LDAP_BACK_C_YES (0x1U)
255 static slap_verbmasks yn_mode[] = {
256 { BER_BVC( "yes" ), LDAP_BACK_C_YES},
257 { BER_BVC( "no" ), LDAP_BACK_C_NO },
261 static slap_verbmasks idassert_mode[] = {
262 { BER_BVC("self"), LDAP_BACK_IDASSERT_SELF },
263 { BER_BVC("anonymous"), LDAP_BACK_IDASSERT_ANONYMOUS },
264 { BER_BVC("none"), LDAP_BACK_IDASSERT_NOASSERT },
265 { BER_BVC("legacy"), LDAP_BACK_IDASSERT_LEGACY },
269 static slap_verbmasks tls_mode[] = {
270 { BER_BVC( "propagate" ), LDAP_BACK_F_TLS_PROPAGATE_MASK },
271 { BER_BVC( "try-propagate" ), LDAP_BACK_F_PROPAGATE_TLS },
272 { BER_BVC( "start" ), LDAP_BACK_F_TLS_USE_MASK },
273 { BER_BVC( "try-start" ), LDAP_BACK_F_USE_TLS },
274 { BER_BVC( "none" ), LDAP_BACK_C_NO },
278 static slap_verbmasks t_f_mode[] = {
279 { BER_BVC( "yes" ), LDAP_BACK_F_SUPPORT_T_F },
280 { BER_BVC( "discover" ), LDAP_BACK_F_SUPPORT_T_F_DISCOVER },
281 { BER_BVC( "no" ), LDAP_BACK_C_NO },
285 static slap_cf_aux_table timeout_table[] = {
286 { BER_BVC("add="), 0 * sizeof( time_t ), 'u', 0, NULL },
287 { BER_BVC("delete="), 1 * sizeof( time_t ), 'u', 0, NULL },
288 { BER_BVC("modify="), 2 * sizeof( time_t ), 'u', 0, NULL },
289 { BER_BVC("modrdn="), 3 * sizeof( time_t ), 'u', 0, NULL },
290 { BER_BVNULL, 0, 0, 0, NULL }
294 ldap_back_cf_gen( ConfigArgs *c )
296 struct ldapinfo *li = ( struct ldapinfo * )c->be->be_private;
300 if ( c->op == SLAP_CONFIG_EMIT ) {
301 struct berval bv = BER_BVNULL;
305 case LDAP_BACK_CFG_URI:
306 if ( li->url != NULL ) {
307 c->value_string = ch_strdup( li->url );
314 case LDAP_BACK_CFG_TLS:
315 enum_to_verb( tls_mode, ( li->flags & LDAP_BACK_F_TLS_MASK ), &bv );
316 if ( BER_BVISNULL( &bv ) ) {
317 /* there's something wrong... */
322 value_add_one( &c->rvalue_vals, &bv );
326 case LDAP_BACK_CFG_ACL_AUTHCDN:
327 case LDAP_BACK_CFG_ACL_PASSWD:
328 case LDAP_BACK_CFG_ACL_METHOD:
329 /* handled by LDAP_BACK_CFG_ACL_BIND */
333 case LDAP_BACK_CFG_ACL_BIND: {
336 bindconf_unparse( &li->acl_sb, &bv );
338 for ( i = 0; isspace( bv.bv_val[ i ] ); i++ )
343 AC_MEMCPY( bv.bv_val, &bv.bv_val[ i ],
347 ber_bvarray_add( &c->rvalue_vals, &bv );
351 case LDAP_BACK_CFG_IDASSERT_MODE:
352 case LDAP_BACK_CFG_IDASSERT_AUTHCDN:
353 case LDAP_BACK_CFG_IDASSERT_PASSWD:
354 case LDAP_BACK_CFG_IDASSERT_METHOD:
355 /* handled by LDAP_BACK_CFG_IDASSERT_BIND */
359 case LDAP_BACK_CFG_IDASSERT_AUTHZFROM: {
362 if ( li->idassert_authz == NULL ) {
367 for ( i = 0; !BER_BVISNULL( &li->idassert_authz[ i ] ); i++ )
369 value_add_one( &c->rvalue_vals, &li->idassert_authz[ i ] );
374 case LDAP_BACK_CFG_IDASSERT_BIND: {
376 struct berval bc = BER_BVNULL;
379 if ( li->idassert_authmethod != LDAP_AUTH_NONE ) {
382 switch ( li->idassert_mode ) {
383 case LDAP_BACK_IDASSERT_OTHERID:
384 case LDAP_BACK_IDASSERT_OTHERDN:
388 struct berval mode = BER_BVNULL;
390 enum_to_verb( idassert_mode, li->idassert_mode, &mode );
391 if ( BER_BVISNULL( &mode ) ) {
392 /* there's something wrong... */
397 bv.bv_len = STRLENOF( "mode=" ) + mode.bv_len;
398 bv.bv_val = ch_malloc( bv.bv_len + 1 );
400 ptr = lutil_strcopy( bv.bv_val, "mode=" );
401 ptr = lutil_strcopy( ptr, mode.bv_val );
407 if ( li->idassert_flags & LDAP_BACK_AUTH_NATIVE_AUTHZ ) {
408 len = bv.bv_len + STRLENOF( "authz=native" );
410 if ( !BER_BVISEMPTY( &bv ) ) {
411 len += STRLENOF( " " );
414 bv.bv_val = ch_realloc( bv.bv_val, len + 1 );
416 ptr = &bv.bv_val[ bv.bv_len ];
418 if ( !BER_BVISEMPTY( &bv ) ) {
419 ptr = lutil_strcopy( ptr, " " );
422 (void)lutil_strcopy( ptr, "authz=native" );
425 len = bv.bv_len + STRLENOF( "flags=non-prescriptive,override" );
427 if ( !BER_BVISEMPTY( &bv ) ) {
428 len += STRLENOF( " " );
431 bv.bv_val = ch_realloc( bv.bv_val, len + 1 );
433 ptr = &bv.bv_val[ bv.bv_len ];
435 if ( !BER_BVISEMPTY( &bv ) ) {
436 ptr = lutil_strcopy( ptr, " " );
439 ptr = lutil_strcopy( ptr, "flags=" );
441 if ( li->idassert_flags & LDAP_BACK_AUTH_PRESCRIPTIVE ) {
442 ptr = lutil_strcopy( ptr, "prescriptive" );
444 ptr = lutil_strcopy( ptr, "non-prescriptive" );
447 if ( li->idassert_flags & LDAP_BACK_AUTH_OVERRIDE ) {
448 ptr = lutil_strcopy( ptr, ",override" );
451 bv.bv_len = ( ptr - bv.bv_val );
455 bindconf_unparse( &li->idassert_sb, &bc );
457 if ( !BER_BVISNULL( &bv ) ) {
458 ber_len_t len = bv.bv_len + bc.bv_len;
460 bv.bv_val = ch_realloc( bv.bv_val, len + 1 );
462 assert( bc.bv_val[ 0 ] == ' ' );
464 ptr = lutil_strcopy( &bv.bv_val[ bv.bv_len ], bc.bv_val );
466 bv.bv_len = ptr - bv.bv_val;
469 for ( i = 0; isspace( bc.bv_val[ i ] ); i++ )
474 AC_MEMCPY( bc.bv_val, &bc.bv_val[ i ], bc.bv_len + 1 );
480 ber_bvarray_add( &c->rvalue_vals, &bv );
485 case LDAP_BACK_CFG_REBIND:
486 enum_to_verb( yn_mode, ( ( li->flags & LDAP_BACK_F_SAVECRED ) == LDAP_BACK_F_SAVECRED ), &bv );
487 if ( BER_BVISNULL( &bv ) ) {
488 /* there's something wrong... */
493 value_add_one( &c->rvalue_vals, &bv );
497 case LDAP_BACK_CFG_CHASE:
498 enum_to_verb( yn_mode, ( ( li->flags & LDAP_BACK_F_CHASE_REFERRALS ) == LDAP_BACK_F_CHASE_REFERRALS ), &bv );
499 if ( BER_BVISNULL( &bv ) ) {
500 /* there's something wrong... */
505 value_add_one( &c->rvalue_vals, &bv );
509 case LDAP_BACK_CFG_T_F:
510 enum_to_verb( t_f_mode, ( ( li->flags & LDAP_BACK_F_SUPPORT_T_F_MASK ) == LDAP_BACK_F_SUPPORT_T_F_MASK ), &bv );
511 if ( BER_BVISNULL( &bv ) ) {
512 /* there's something wrong... */
517 value_add_one( &c->rvalue_vals, &bv );
521 case LDAP_BACK_CFG_WHOAMI:
522 enum_to_verb( yn_mode, ( ( li->flags & LDAP_BACK_F_PROXY_WHOAMI ) == LDAP_BACK_F_PROXY_WHOAMI ), &bv );
523 if ( BER_BVISNULL( &bv ) ) {
524 /* there's something wrong... */
529 value_add_one( &c->rvalue_vals, &bv );
533 case LDAP_BACK_CFG_TIMEOUT:
536 slap_cf_aux_table_unparse( li->timeout, &bv, timeout_table );
538 if ( !BER_BVISNULL( &bv ) ) {
539 for ( i = 0; isspace( bv.bv_val[ i ] ); i++ )
544 AC_MEMCPY( bv.bv_val, &bv.bv_val[ i ],
548 ber_bvarray_add( &c->rvalue_vals, &bv );
553 /* FIXME: we need to handle all... */
559 } else if ( c->op == LDAP_MOD_DELETE ) {
562 case LDAP_BACK_CFG_URI:
563 if ( li->url != NULL ) {
568 if ( li->lud != NULL ) {
569 ldap_free_urllist( li->lud );
573 /* better cleanup the cached connections... */
574 /* NOTE: don't worry about locking: if we got here,
575 * other threads are suspended. */
576 avl_free( li->conntree, ldap_back_conn_free );
581 case LDAP_BACK_CFG_TLS:
585 case LDAP_BACK_CFG_ACL_AUTHCDN:
586 case LDAP_BACK_CFG_ACL_PASSWD:
587 case LDAP_BACK_CFG_ACL_METHOD:
588 /* handled by LDAP_BACK_CFG_ACL_BIND */
592 case LDAP_BACK_CFG_ACL_BIND:
593 bindconf_free( &li->acl_sb );
596 case LDAP_BACK_CFG_IDASSERT_MODE:
597 case LDAP_BACK_CFG_IDASSERT_AUTHCDN:
598 case LDAP_BACK_CFG_IDASSERT_PASSWD:
599 case LDAP_BACK_CFG_IDASSERT_METHOD:
600 /* handled by LDAP_BACK_CFG_IDASSERT_BIND */
604 case LDAP_BACK_CFG_IDASSERT_AUTHZFROM:
605 if ( li->idassert_authz != NULL ) {
606 ber_bvarray_free( li->idassert_authz );
607 li->idassert_authz = NULL;
611 case LDAP_BACK_CFG_IDASSERT_BIND:
612 bindconf_free( &li->idassert_sb );
615 case LDAP_BACK_CFG_REBIND:
616 case LDAP_BACK_CFG_CHASE:
617 case LDAP_BACK_CFG_T_F:
618 case LDAP_BACK_CFG_WHOAMI:
622 case LDAP_BACK_CFG_TIMEOUT:
623 for ( i = 0; i < LDAP_BACK_OP_LAST; i++ ) {
624 li->timeout[ i ] = 0;
629 /* FIXME: we need to handle all... */
638 case LDAP_BACK_CFG_URI: {
639 LDAPURLDesc *tmpludp;
645 if ( c->argc != 2 ) {
646 fprintf( stderr, "%s: line %d: "
648 "in \"uri <uri>\" line\n",
649 c->fname, c->lineno );
653 if ( li->url != NULL ) {
657 if ( li->lud != NULL ) {
658 ldap_free_urllist( li->lud );
662 /* PARANOID: DN and more are not required nor allowed */
663 urlrc = ldap_url_parselist_ext( &li->lud, c->value_string, "\t" );
665 urlrc = ldap_url_parselist( &li->lud, c->value_string );
667 if ( urlrc != LDAP_URL_SUCCESS ) {
671 case LDAP_URL_ERR_MEM:
674 case LDAP_URL_ERR_PARAM:
675 why = "parameter is bad";
677 case LDAP_URL_ERR_BADSCHEME:
678 why = "URL doesn't begin with \"[c]ldap[si]://\"";
680 case LDAP_URL_ERR_BADENCLOSURE:
681 why = "URL is missing trailing \">\"";
683 case LDAP_URL_ERR_BADURL:
685 case LDAP_URL_ERR_BADHOST:
686 why = "host/port is bad";
688 case LDAP_URL_ERR_BADATTRS:
689 why = "bad (or missing) attributes";
691 case LDAP_URL_ERR_BADSCOPE:
692 why = "scope string is invalid (or missing)";
694 case LDAP_URL_ERR_BADFILTER:
695 why = "bad or missing filter";
697 case LDAP_URL_ERR_BADEXTS:
698 why = "bad or missing extensions";
701 why = "unknown reason";
704 fprintf( stderr, "%s: line %d: "
705 "unable to parse uri \"%s\" "
706 "in \"uri <uri>\" line: %s\n",
707 c->fname, c->lineno, c->value_string, why );
711 for ( i = 0, tmpludp = li->lud;
713 i++, tmpludp = tmpludp->lud_next )
715 if ( ( tmpludp->lud_dn != NULL
716 && tmpludp->lud_dn[0] != '\0' )
717 || tmpludp->lud_attrs != NULL
718 /* || tmpludp->lud_scope != LDAP_SCOPE_DEFAULT */
719 || tmpludp->lud_filter != NULL
720 || tmpludp->lud_exts != NULL )
722 fprintf( stderr, "%s: line %d: "
723 "warning, only protocol, "
724 "host and port allowed "
725 "in \"uri <uri>\" statement "
726 "for uri #%d of \"%s\"\n",
727 c->fname, c->lineno, i, c->value_string );
732 for ( i = 0, tmpludp = li->lud;
734 i++, tmpludp = tmpludp->lud_next )
737 urllist = ch_calloc( sizeof( char * ), i + 1 );
739 for ( i = 0, tmpludp = li->lud;
741 i++, tmpludp = tmpludp->lud_next )
744 ber_len_t oldlen = 0, len;
748 tmplud.lud_attrs = NULL;
749 tmplud.lud_filter = NULL;
750 if ( !ldap_is_ldapi_url( tmplud.lud_scheme ) ) {
751 tmplud.lud_exts = NULL;
752 tmplud.lud_crit_exts = 0;
755 urllist[ i ] = ldap_url_desc2str( &tmplud );
757 if ( urllist[ i ] == NULL ) {
758 fprintf( stderr, "%s: line %d: "
759 "unable to rebuild uri "
760 "in \"uri <uri>\" statement "
762 c->fname, c->lineno, argv[ 1 ] );
767 li->url = ldap_charray2str( urllist, " " );
768 ldap_charray_free( urllist );
770 li->url = c->value_string;
771 c->value_string = NULL;
776 case LDAP_BACK_CFG_TLS:
777 i = verb_to_mask( c->argv[1], tls_mode );
778 if ( BER_BVISNULL( &tls_mode[i].word ) ) {
781 li->flags &= ~LDAP_BACK_F_TLS_MASK;
782 li->flags |= tls_mode[i].mask;
785 case LDAP_BACK_CFG_ACL_AUTHCDN:
786 switch ( li->acl_authmethod ) {
788 li->acl_authmethod = LDAP_AUTH_SIMPLE;
791 case LDAP_AUTH_SIMPLE:
795 fprintf( stderr, "%s: line %d: "
796 "\"acl-authcDN <DN>\" incompatible "
797 "with auth method %d.",
798 c->fname, c->lineno, li->acl_authmethod );
801 if ( !BER_BVISNULL( &li->acl_authcDN ) ) {
802 free( li->acl_authcDN.bv_val );
804 ber_memfree_x( c->value_dn.bv_val, NULL );
805 li->acl_authcDN = c->value_ndn;
806 BER_BVZERO( &c->value_dn );
807 BER_BVZERO( &c->value_ndn );
810 case LDAP_BACK_CFG_ACL_PASSWD:
811 switch ( li->acl_authmethod ) {
813 li->acl_authmethod = LDAP_AUTH_SIMPLE;
816 case LDAP_AUTH_SIMPLE:
820 fprintf( stderr, "%s: line %d: "
821 "\"acl-passwd <cred>\" incompatible "
822 "with auth method %d.",
823 c->fname, c->lineno, li->acl_authmethod );
826 if ( !BER_BVISNULL( &li->acl_passwd ) ) {
827 free( li->acl_passwd.bv_val );
829 ber_str2bv( c->argv[ 1 ], 0, 1, &li->acl_passwd );
832 case LDAP_BACK_CFG_ACL_METHOD:
833 case LDAP_BACK_CFG_ACL_BIND:
834 for ( i = 1; i < c->argc; i++ ) {
835 if ( bindconf_parse( c->argv[ i ], &li->acl_sb ) ) {
841 case LDAP_BACK_CFG_IDASSERT_MODE:
842 i = verb_to_mask( c->argv[1], idassert_mode );
843 if ( BER_BVISNULL( &idassert_mode[i].word ) ) {
844 if ( strncasecmp( c->argv[1], "u:", STRLENOF( "u:" ) ) == 0 ) {
845 li->idassert_mode = LDAP_BACK_IDASSERT_OTHERID;
846 ber_str2bv( c->argv[1], 0, 1, &li->idassert_authzID );
847 li->idassert_authzID.bv_val[ 0 ] = 'u';
850 struct berval id, ndn;
852 ber_str2bv( c->argv[1], 0, 0, &id );
854 if ( strncasecmp( c->argv[1], "dn:", STRLENOF( "dn:" ) ) == 0 ) {
855 id.bv_val += STRLENOF( "dn:" );
856 id.bv_len -= STRLENOF( "dn:" );
859 rc = dnNormalize( 0, NULL, NULL, &id, &ndn, NULL );
860 if ( rc != LDAP_SUCCESS ) {
861 Debug( LDAP_DEBUG_ANY,
862 "%s: line %d: idassert ID \"%s\" is not a valid DN\n",
863 c->fname, c->lineno, c->argv[1] );
867 li->idassert_authzID.bv_len = STRLENOF( "dn:" ) + ndn.bv_len;
868 li->idassert_authzID.bv_val = ch_malloc( li->idassert_authzID.bv_len + 1 );
869 AC_MEMCPY( li->idassert_authzID.bv_val, "dn:", STRLENOF( "dn:" ) );
870 AC_MEMCPY( &li->idassert_authzID.bv_val[ STRLENOF( "dn:" ) ], ndn.bv_val, ndn.bv_len + 1 );
871 ch_free( ndn.bv_val );
873 li->idassert_mode = LDAP_BACK_IDASSERT_OTHERDN;
877 li->idassert_mode = idassert_mode[i].mask;
883 for ( i = 2; i < c->argc; i++ ) {
884 if ( strcasecmp( c->argv[ i ], "override" ) == 0 ) {
885 li->idassert_flags |= LDAP_BACK_AUTH_OVERRIDE;
887 } else if ( strcasecmp( c->argv[ i ], "prescriptive" ) == 0 ) {
888 li->idassert_flags |= LDAP_BACK_AUTH_PRESCRIPTIVE;
890 } else if ( strcasecmp( c->argv[ i ], "non-prescriptive" ) == 0 ) {
891 li->idassert_flags &= ( ~LDAP_BACK_AUTH_PRESCRIPTIVE );
894 Debug( LDAP_DEBUG_ANY,
895 "%s: line %d: unknown flag #%d "
896 "in \"idassert-mode <args> "
897 "[<flags>]\" line.\n",
898 c->fname, c->lineno, i - 2 );
905 case LDAP_BACK_CFG_IDASSERT_AUTHCDN:
906 switch ( li->idassert_authmethod ) {
908 li->idassert_authmethod = LDAP_AUTH_SIMPLE;
911 case LDAP_AUTH_SIMPLE:
915 fprintf( stderr, "%s: line %d: "
916 "\"idassert-authcDN <DN>\" incompatible "
917 "with auth method %d.",
918 c->fname, c->lineno, li->idassert_authmethod );
921 if ( !BER_BVISNULL( &li->idassert_authcDN ) ) {
922 free( li->idassert_authcDN.bv_val );
924 ber_memfree_x( c->value_dn.bv_val, NULL );
925 li->idassert_authcDN = c->value_ndn;
926 BER_BVZERO( &c->value_dn );
927 BER_BVZERO( &c->value_ndn );
930 case LDAP_BACK_CFG_IDASSERT_PASSWD:
931 switch ( li->idassert_authmethod ) {
933 li->idassert_authmethod = LDAP_AUTH_SIMPLE;
936 case LDAP_AUTH_SIMPLE:
940 fprintf( stderr, "%s: line %d: "
941 "\"idassert-passwd <cred>\" incompatible "
942 "with auth method %d.",
943 c->fname, c->lineno, li->idassert_authmethod );
946 if ( !BER_BVISNULL( &li->idassert_passwd ) ) {
947 free( li->idassert_passwd.bv_val );
949 ber_str2bv( c->argv[ 1 ], 0, 1, &li->idassert_passwd );
952 case LDAP_BACK_CFG_IDASSERT_AUTHZFROM: {
954 #ifdef SLAP_AUTHZ_SYNTAX
958 ber_str2bv( c->argv[ 1 ], 0, 0, &in );
959 rc = authzNormalize( 0, NULL, NULL, &in, &bv, NULL );
960 if ( rc != LDAP_SUCCESS ) {
961 fprintf( stderr, "%s: %d: "
962 "\"idassert-authzFrom <authz>\": "
964 c->fname, c->lineno );
967 #else /* !SLAP_AUTHZ_SYNTAX */
968 ber_str2bv( c->argv[ 1 ], 0, 1, &bv );
969 #endif /* !SLAP_AUTHZ_SYNTAX */
970 ber_bvarray_add( &li->idassert_authz, &bv );
973 case LDAP_BACK_CFG_IDASSERT_METHOD:
974 /* no longer supported */
975 fprintf( stderr, "%s: %d: "
976 "\"idassert-method <args>\": "
977 "no longer supported; use \"idassert-bind\".\n",
978 c->fname, c->lineno );
981 case LDAP_BACK_CFG_IDASSERT_BIND:
982 for ( i = 1; i < c->argc; i++ ) {
983 if ( strncasecmp( c->argv[ i ], "mode=", STRLENOF( "mode=" ) ) == 0 ) {
984 char *argvi = c->argv[ i ] + STRLENOF( "mode=" );
987 j = verb_to_mask( argvi, idassert_mode );
988 if ( BER_BVISNULL( &idassert_mode[ j ].word ) ) {
989 fprintf( stderr, "%s: %d: "
990 "\"idassert-bind <args>\": "
991 "unknown mode \"%s\".\n",
992 c->fname, c->lineno, argvi );
996 li->idassert_mode = idassert_mode[ j ].mask;
998 } else if ( strncasecmp( c->argv[ i ], "authz=", STRLENOF( "authz=" ) ) == 0 ) {
999 char *argvi = c->argv[ i ] + STRLENOF( "authz=" );
1001 if ( strcasecmp( argvi, "native" ) == 0 ) {
1002 if ( li->idassert_authmethod != LDAP_AUTH_SASL ) {
1003 fprintf( stderr, "%s: %d: "
1004 "\"idassert-bind <args>\": "
1005 "authz=\"native\" incompatible "
1006 "with auth method.\n",
1007 c->fname, c->lineno );
1010 li->idassert_flags |= LDAP_BACK_AUTH_NATIVE_AUTHZ;
1012 } else if ( strcasecmp( argvi, "proxyAuthz" ) == 0 ) {
1013 li->idassert_flags &= ~LDAP_BACK_AUTH_NATIVE_AUTHZ;
1016 fprintf( stderr, "%s: %d: "
1017 "\"idassert-bind <args>\": "
1018 "unknown authz \"%s\".\n",
1019 c->fname, c->lineno, argvi );
1023 } else if ( strncasecmp( c->argv[ i ], "flags=", STRLENOF( "flags=" ) ) == 0 ) {
1024 char *argvi = c->argv[ i ] + STRLENOF( "flags=" );
1025 char **flags = ldap_str2charray( argvi, "," );
1028 if ( flags == NULL ) {
1029 fprintf( stderr, "%s: %d: "
1030 "\"idassert-bind <args>\": "
1031 "unable to parse flags \"%s\".\n",
1032 c->fname, c->lineno, argvi );
1036 for ( j = 0; flags[ j ] != NULL; j++ ) {
1037 if ( strcasecmp( flags[ j ], "override" ) == 0 ) {
1038 li->idassert_flags |= LDAP_BACK_AUTH_OVERRIDE;
1040 } else if ( strcasecmp( flags[ j ], "prescriptive" ) == 0 ) {
1041 li->idassert_flags |= LDAP_BACK_AUTH_PRESCRIPTIVE;
1043 } else if ( strcasecmp( flags[ j ], "non-prescriptive" ) == 0 ) {
1044 li->idassert_flags &= ( ~LDAP_BACK_AUTH_PRESCRIPTIVE );
1047 fprintf( stderr, "%s: %d: "
1048 "\"idassert-bind <args>\": "
1049 "unknown flag \"%s\".\n",
1050 c->fname, c->lineno, flags[ j ] );
1055 ldap_charray_free( flags );
1057 } else if ( bindconf_parse( c->argv[ i ], &li->idassert_sb ) ) {
1063 case LDAP_BACK_CFG_REBIND: {
1066 if ( c->argc == 1 ) {
1071 i = verb_to_mask( c->argv[1], yn_mode );
1072 if ( BER_BVISNULL( &yn_mode[i].word ) ) {
1075 if ( yn_mode[i].mask & LDAP_BACK_C_YES ) {
1081 li->flags |= LDAP_BACK_F_SAVECRED;
1084 li->flags &= ~LDAP_BACK_F_SAVECRED;
1088 case LDAP_BACK_CFG_CHASE: {
1091 if ( c->argc == 1 ) {
1096 i = verb_to_mask( c->argv[1], yn_mode );
1097 if ( BER_BVISNULL( &yn_mode[i].word ) ) {
1100 if ( yn_mode[i].mask & LDAP_BACK_C_YES ) {
1106 li->flags |= LDAP_BACK_F_CHASE_REFERRALS;
1109 li->flags &= ~LDAP_BACK_F_CHASE_REFERRALS;
1113 case LDAP_BACK_CFG_T_F:
1114 i = verb_to_mask( c->argv[1], t_f_mode );
1115 if ( BER_BVISNULL( &t_f_mode[i].word ) ) {
1118 li->flags &= ~LDAP_BACK_F_SUPPORT_T_F_MASK;
1119 li->flags |= t_f_mode[i].mask;
1122 case LDAP_BACK_CFG_WHOAMI: {
1125 if ( c->argc == 1 ) {
1130 i = verb_to_mask( c->argv[1], yn_mode );
1131 if ( BER_BVISNULL( &yn_mode[i].word ) ) {
1134 if ( yn_mode[i].mask & LDAP_BACK_C_YES ) {
1140 li->flags |= LDAP_BACK_F_PROXY_WHOAMI;
1142 load_extop( (struct berval *)&slap_EXOP_WHOAMI,
1143 0, ldap_back_exop_whoami );
1146 li->flags &= ~LDAP_BACK_F_PROXY_WHOAMI;
1150 case LDAP_BACK_CFG_TIMEOUT:
1151 if ( c->argc < 2 ) {
1155 for ( i = 1; i < c->argc; i++ ) {
1156 if ( isdigit( c->argv[ i ][ 0 ] ) ) {
1161 u = strtoul( c->argv[ i ], &next, 0 );
1162 if ( next == c->argv[ i ] || next[ 0 ] != '\0' ) {
1166 for ( j = 0; j < LDAP_BACK_OP_LAST; j++ ) {
1167 li->timeout[ j ] = u;
1173 if ( slap_cf_aux_table_parse( c->argv[ i ], li->timeout, timeout_table, "slapd-ldap timeout" ) ) {
1179 case LDAP_BACK_CFG_REWRITE:
1180 fprintf( stderr, "%s: line %d: "
1181 "rewrite/remap capabilities have been moved "
1182 "to the \"rwm\" overlay; see slapo-rwm(5) "
1183 "for details (hint: add \"overlay rwm\" "
1184 "and prefix all directives with \"rwm-\").\n",
1185 c->fname, c->lineno );
1189 /* FIXME: try to catch inconsistencies */
1198 ldap_back_init_cf( BackendInfo *bi )
1201 AttributeDescription *ad = NULL;
1204 bi->bi_cf_ocs = ldapocs;
1206 rc = config_register_schema( ldapcfg, ldapocs );
1211 /* setup olcDbAclPasswd and olcDbIDAssertPasswd
1212 * to be base64-encoded when written in LDIF form;
1213 * basically, we don't care if it fails */
1214 rc = slap_str2ad( "olcDbACLPasswd", &ad, &text );
1216 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
1217 "warning, unable to get \"olcDbACLPasswd\" "
1218 "attribute description: %d: %s\n",
1221 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
1222 ad->ad_type->sat_oid );
1226 rc = slap_str2ad( "olcDbIDAssertPasswd", &ad, &text );
1228 Debug( LDAP_DEBUG_ANY, "config_back_initialize: "
1229 "warning, unable to get \"olcDbIDAssertPasswd\" "
1230 "attribute description: %d: %s\n",
1233 (void)ldif_must_b64_encode_register( ad->ad_cname.bv_val,
1234 ad->ad_type->sat_oid );
1242 parse_idassert( BackendDB *be, const char *fname, int lineno,
1243 int argc, char **argv );
1246 parse_acl_auth( BackendDB *be, const char *fname, int lineno,
1247 int argc, char **argv );
1250 ldap_back_db_config(
1257 struct ldapinfo *li = (struct ldapinfo *) be->be_private;
1260 fprintf( stderr, "%s: line %d: ldap backend info is null!\n",
1265 /* server address to query (no longer supported, use "uri" directive) */
1266 if ( strcasecmp( argv[0], "server" ) == 0 ) {
1268 "%s: line %d: \"server <address>\" directive is no longer supported.\n",
1272 /* URI of server to query (obsoletes "server" directive) */
1273 } else if ( strcasecmp( argv[0], "uri" ) == 0 ) {
1274 LDAPURLDesc *tmpludp;
1281 fprintf( stderr, "%s: line %d: "
1283 "in \"uri <uri>\" line\n",
1287 if ( li->url != NULL ) {
1290 if ( li->lud != NULL ) {
1291 ldap_free_urllist( li->lud );
1295 /* PARANOID: DN and more are not required nor allowed */
1296 urlrc = ldap_url_parselist_ext( &li->lud, argv[ 1 ], "\t" );
1298 urlrc = ldap_url_parselist( &li->lud, argv[ 1 ] );
1300 if ( urlrc != LDAP_URL_SUCCESS ) {
1304 case LDAP_URL_ERR_MEM:
1307 case LDAP_URL_ERR_PARAM:
1308 why = "parameter is bad";
1310 case LDAP_URL_ERR_BADSCHEME:
1311 why = "URL doesn't begin with \"[c]ldap[si]://\"";
1313 case LDAP_URL_ERR_BADENCLOSURE:
1314 why = "URL is missing trailing \">\"";
1316 case LDAP_URL_ERR_BADURL:
1318 case LDAP_URL_ERR_BADHOST:
1319 why = "host/port is bad";
1321 case LDAP_URL_ERR_BADATTRS:
1322 why = "bad (or missing) attributes";
1324 case LDAP_URL_ERR_BADSCOPE:
1325 why = "scope string is invalid (or missing)";
1327 case LDAP_URL_ERR_BADFILTER:
1328 why = "bad or missing filter";
1330 case LDAP_URL_ERR_BADEXTS:
1331 why = "bad or missing extensions";
1334 why = "unknown reason";
1337 fprintf( stderr, "%s: line %d: "
1338 "unable to parse uri \"%s\" "
1339 "in \"uri <uri>\" line: %s\n",
1340 fname, lineno, argv[ 1 ], why );
1344 for ( i = 0, tmpludp = li->lud;
1346 i++, tmpludp = tmpludp->lud_next )
1348 if ( ( tmpludp->lud_dn != NULL
1349 && tmpludp->lud_dn[0] != '\0' )
1350 || tmpludp->lud_attrs != NULL
1351 /* || tmpludp->lud_scope != LDAP_SCOPE_DEFAULT */
1352 || tmpludp->lud_filter != NULL
1353 || tmpludp->lud_exts != NULL )
1355 fprintf( stderr, "%s: line %d: "
1356 "warning, only protocol, "
1357 "host and port allowed "
1358 "in \"uri <uri>\" statement "
1359 "for uri #%d of \"%s\"\n",
1360 fname, lineno, i, argv[1] );
1365 for ( i = 0, tmpludp = li->lud;
1367 i++, tmpludp = tmpludp->lud_next )
1370 urllist = ch_calloc( sizeof( char * ), i + 1 );
1372 for ( i = 0, tmpludp = li->lud;
1374 i++, tmpludp = tmpludp->lud_next )
1377 ber_len_t oldlen = 0, len;
1381 tmplud.lud_attrs = NULL;
1382 tmplud.lud_filter = NULL;
1383 if ( !ldap_is_ldapi_url( tmplud.lud_scheme ) ) {
1384 tmplud.lud_exts = NULL;
1385 tmplud.lud_crit_exts = 0;
1388 urllist[ i ] = ldap_url_desc2str( &tmplud );
1390 if ( urllist[ i ] == NULL ) {
1391 fprintf( stderr, "%s: line %d: "
1392 "unable to rebuild uri "
1393 "in \"uri <uri>\" statement "
1395 fname, lineno, argv[ 1 ] );
1400 li->url = ldap_charray2str( urllist, " " );
1401 ldap_charray_free( urllist );
1403 li->url = ch_strdup( argv[ 1 ] );
1406 } else if ( strcasecmp( argv[0], "tls" ) == 0 ) {
1409 "%s: line %d: \"tls <what>\" needs 1 argument.\n",
1415 if ( strcasecmp( argv[1], "none" ) == 0 ) {
1416 li->flags &= ~LDAP_BACK_F_TLS_MASK;
1419 } else if ( strcasecmp( argv[1], "start" ) == 0 ) {
1420 li->flags |= LDAP_BACK_F_TLS_USE_MASK;
1423 } else if ( strcasecmp( argv[1], "try-start" ) == 0 ) {
1424 li->flags &= ~LDAP_BACK_F_TLS_CRITICAL;
1425 li->flags |= LDAP_BACK_F_USE_TLS;
1427 /* propagate start tls */
1428 } else if ( strcasecmp( argv[1], "propagate" ) == 0 ) {
1429 li->flags |= LDAP_BACK_F_TLS_PROPAGATE_MASK;
1432 } else if ( strcasecmp( argv[1], "try-propagate" ) == 0 ) {
1433 li->flags &= ~LDAP_BACK_F_TLS_CRITICAL;
1434 li->flags |= LDAP_BACK_F_PROPAGATE_TLS;
1438 "%s: line %d: \"tls <what>\": unknown argument \"%s\".\n",
1439 fname, lineno, argv[1] );
1443 /* remote ACL stuff... */
1444 } else if ( strncasecmp( argv[0], "acl-", STRLENOF( "acl-" ) ) == 0
1445 || strncasecmp( argv[0], "bind", STRLENOF( "bind" ) ) == 0 )
1447 /* NOTE: "bind{DN,pw}" was initially used; it's now
1448 * deprected and undocumented, it can be dropped at some
1449 * point, since nobody should be really using it */
1450 return parse_acl_auth( be, fname, lineno, argc, argv );
1452 /* identity assertion stuff... */
1453 } else if ( strncasecmp( argv[0], "idassert-", STRLENOF( "idassert-" ) ) == 0
1454 || strncasecmp( argv[0], "proxyauthz", STRLENOF( "proxyauthz" ) ) == 0 )
1456 /* NOTE: "proxyauthz{DN,pw}" was initially used; it's now
1457 * deprected and undocumented, it can be dropped at some
1458 * point, since nobody should be really using it */
1459 return parse_idassert( be, fname, lineno, argc, argv );
1461 /* save bind creds for referral rebinds? */
1462 } else if ( strcasecmp( argv[0], "rebind-as-user" ) == 0 ) {
1466 "%s: line %d: \"rebind-as-user {NO|yes}\": use without args is deprecated.\n",
1469 li->flags |= LDAP_BACK_F_SAVECRED;
1473 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
1474 li->flags |= LDAP_BACK_F_SAVECRED;
1476 } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
1477 li->flags &= ~LDAP_BACK_F_SAVECRED;
1481 "%s: line %d: \"rebind-as-user {NO|yes}\": unknown argument \"%s\".\n",
1482 fname, lineno, argv[ 1 ] );
1489 "%s: line %d: \"rebind-as-user {NO|yes}\" needs 1 argument.\n",
1494 } else if ( strcasecmp( argv[0], "chase-referrals" ) == 0 ) {
1497 "%s: line %d: \"chase-referrals {YES|no}\" needs 1 argument.\n",
1502 /* this is the default; we add it because the default might change... */
1503 if ( strcasecmp( argv[1], "yes" ) == 0 ) {
1504 li->flags |= LDAP_BACK_F_CHASE_REFERRALS;
1506 } else if ( strcasecmp( argv[1], "no" ) == 0 ) {
1507 li->flags &= ~LDAP_BACK_F_CHASE_REFERRALS;
1511 "%s: line %d: \"chase-referrals {YES|no}\": unknown argument \"%s\".\n",
1512 fname, lineno, argv[1] );
1516 } else if ( strcasecmp( argv[ 0 ], "t-f-support" ) == 0 ) {
1519 "%s: line %d: \"t-f-support {NO|yes|discover}\" needs 1 argument.\n",
1524 if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) {
1525 li->flags &= ~(LDAP_BACK_F_SUPPORT_T_F|LDAP_BACK_F_SUPPORT_T_F_DISCOVER);
1527 } else if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
1528 li->flags |= LDAP_BACK_F_SUPPORT_T_F;
1530 } else if ( strcasecmp( argv[ 1 ], "discover" ) == 0 ) {
1531 li->flags |= LDAP_BACK_F_SUPPORT_T_F_DISCOVER;
1535 "%s: line %d: \"t-f-support {NO|yes|discover}\": unknown argument \"%s\".\n",
1536 fname, lineno, argv[ 1 ] );
1540 /* intercept exop_who_am_i? */
1541 } else if ( strcasecmp( argv[0], "proxy-whoami" ) == 0 ) {
1542 int doload_extop = 0;
1547 "%s: line %d: \"proxy-whoami {NO|yes}\": use without args is deprecated.\n",
1554 if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) {
1557 } else if ( strcasecmp( argv[ 1 ], "no" ) != 0 ) {
1559 "%s: line %d: \"proxy-whoami {NO|yes}\": unknown argument \"%s\".\n",
1560 fname, lineno, argv[ 1 ] );
1567 "%s: line %d: \"proxy-whoami {NO|yes}\" needs 1 argument.\n",
1572 if ( doload_extop ) {
1573 li->flags |= LDAP_BACK_F_PROXY_WHOAMI;
1575 load_extop( (struct berval *)&slap_EXOP_WHOAMI,
1576 0, ldap_back_exop_whoami );
1579 /* FIXME: legacy: intercept old rewrite/remap directives
1580 * and try to start the rwm overlay */
1581 } else if ( strcasecmp( argv[0], "suffixmassage" ) == 0
1582 || strcasecmp( argv[0], "map" ) == 0
1583 || strncasecmp( argv[0], "rewrite", STRLENOF( "rewrite" ) ) == 0 )
1586 fprintf( stderr, "%s: line %d: "
1587 "rewrite/remap capabilities have been moved "
1588 "to the \"rwm\" overlay; see slapo-rwm(5) "
1589 "for details. I'm trying to do my best "
1590 "to preserve backwards compatibility...\n",
1593 if ( li->rwm_started == 0 ) {
1594 if ( overlay_config( be, "rwm" ) ) {
1595 fprintf( stderr, "%s: line %d: "
1596 "unable to configure the \"rwm\" "
1597 "overlay, required by directive "
1599 fname, lineno, argv[0] );
1600 #if SLAPD_OVER_RWM == SLAPD_MOD_DYNAMIC
1601 fprintf( stderr, "\thint: try loading the \"rwm.la\" dynamic module.\n" );
1602 #endif /* SLAPD_OVER_RWM == SLAPD_MOD_DYNAMIC */
1606 fprintf( stderr, "%s: line %d: back-ldap: "
1607 "automatically starting \"rwm\" overlay, "
1608 "triggered by \"%s\" directive.\n",
1609 fname, lineno, argv[ 0 ] );
1611 /* this is the default; we add it because the default might change... */
1612 li->rwm_started = 1;
1614 return ( *be->bd_info->bi_db_config )( be, fname, lineno, argc, argv );
1617 fprintf( stderr, "%s: line %d: "
1618 "rewrite/remap capabilities have been moved "
1619 "to the \"rwm\" overlay; see slapo-rwm(5) "
1620 "for details (hint: add \"overlay rwm\" "
1621 "and prefix all directives with \"rwm-\").\n",
1629 return SLAP_CONF_UNKNOWN;
1636 ldap_back_exop_whoami(
1640 struct berval *bv = NULL;
1642 if ( op->oq_extended.rs_reqdata != NULL ) {
1643 /* no request data should be provided */
1644 rs->sr_text = "no request data expected";
1645 return rs->sr_err = LDAP_PROTOCOL_ERROR;
1648 Statslog( LDAP_DEBUG_STATS, "%s WHOAMI\n",
1649 op->o_log_prefix, 0, 0, 0, 0 );
1651 rs->sr_err = backend_check_restrictions( op, rs,
1652 (struct berval *)&slap_EXOP_WHOAMI );
1653 if( rs->sr_err != LDAP_SUCCESS ) return rs->sr_err;
1655 /* if auth'd by back-ldap and request is proxied, forward it */
1656 if ( op->o_conn->c_authz_backend && !strcmp(op->o_conn->c_authz_backend->be_type, "ldap" ) && !dn_match(&op->o_ndn, &op->o_conn->c_ndn)) {
1657 struct ldapconn *lc;
1659 LDAPControl c, *ctrls[2] = {NULL, NULL};
1661 Operation op2 = *op;
1666 op2.o_ndn = op->o_conn->c_ndn;
1667 lc = ldap_back_getconn(&op2, rs, LDAP_BACK_SENDERR);
1668 if (!lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR )) {
1671 c.ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
1672 c.ldctl_iscritical = 1;
1673 c.ldctl_value.bv_val = ch_malloc(op->o_ndn.bv_len+4);
1674 c.ldctl_value.bv_len = op->o_ndn.bv_len + 3;
1675 strcpy(c.ldctl_value.bv_val, "dn:");
1676 strcpy(c.ldctl_value.bv_val+3, op->o_ndn.bv_val);
1679 rs->sr_err = ldap_whoami(lc->lc_ld, ctrls, NULL, &msgid);
1680 if (rs->sr_err == LDAP_SUCCESS) {
1681 if (ldap_result(lc->lc_ld, msgid, 1, NULL, &res) == -1) {
1682 ldap_get_option(lc->lc_ld, LDAP_OPT_ERROR_NUMBER,
1684 if ( rs->sr_err == LDAP_SERVER_DOWN && doretry ) {
1686 if ( ldap_back_retry( lc, op, rs, LDAP_BACK_SENDERR ) )
1689 ldap_back_freeconn( op, lc );
1693 rs->sr_err = ldap_parse_whoami(lc->lc_ld, res, &bv);
1697 ch_free(c.ldctl_value.bv_val);
1698 if (rs->sr_err != LDAP_SUCCESS) {
1699 rs->sr_err = slap_map_api2result( rs );
1703 ldap_back_release_conn( &op2, rs, lc );
1707 /* else just do the same as before */
1708 bv = (struct berval *) ch_malloc( sizeof(struct berval) );
1709 if ( !BER_BVISEMPTY( &op->o_dn ) ) {
1710 bv->bv_len = op->o_dn.bv_len + STRLENOF("dn:");
1711 bv->bv_val = ch_malloc( bv->bv_len + 1 );
1712 AC_MEMCPY( bv->bv_val, "dn:", STRLENOF("dn:") );
1713 AC_MEMCPY( &bv->bv_val[STRLENOF("dn:")], op->o_dn.bv_val,
1715 bv->bv_val[bv->bv_len] = '\0';
1722 rs->sr_rspdata = bv;
1736 struct ldapinfo *li = (struct ldapinfo *) be->be_private;
1738 /* identity assertion mode */
1739 if ( strcasecmp( argv[0], "idassert-mode" ) == 0 ) {
1741 Debug( LDAP_DEBUG_ANY,
1742 "%s: line %d: illegal args number %d in \"idassert-mode <args> [<flag> [...]]\" line.\n",
1743 fname, lineno, argc );
1747 if ( strcasecmp( argv[1], "legacy" ) == 0 ) {
1748 /* will proxyAuthz as client's identity only if bound */
1749 li->idassert_mode = LDAP_BACK_IDASSERT_LEGACY;
1751 } else if ( strcasecmp( argv[1], "self" ) == 0 ) {
1752 /* will proxyAuthz as client's identity */
1753 li->idassert_mode = LDAP_BACK_IDASSERT_SELF;
1755 } else if ( strcasecmp( argv[1], "anonymous" ) == 0 ) {
1756 /* will proxyAuthz as anonymous */
1757 li->idassert_mode = LDAP_BACK_IDASSERT_ANONYMOUS;
1759 } else if ( strcasecmp( argv[1], "none" ) == 0 ) {
1760 /* will not proxyAuthz */
1761 li->idassert_mode = LDAP_BACK_IDASSERT_NOASSERT;
1767 /* will proxyAuthz as argv[1] */
1768 ber_str2bv( argv[1], 0, 0, &id );
1770 if ( strncasecmp( id.bv_val, "u:", STRLENOF( "u:" ) ) == 0 ) {
1771 /* force lowercase... */
1773 li->idassert_mode = LDAP_BACK_IDASSERT_OTHERID;
1774 ber_dupbv( &li->idassert_authzID, &id );
1779 /* default is DN? */
1780 if ( strncasecmp( id.bv_val, "dn:", STRLENOF( "dn:" ) ) == 0 ) {
1781 id.bv_val += STRLENOF( "dn:" );
1782 id.bv_len -= STRLENOF( "dn:" );
1785 rc = dnNormalize( 0, NULL, NULL, &id, &dn, NULL );
1786 if ( rc != LDAP_SUCCESS ) {
1787 Debug( LDAP_DEBUG_ANY,
1788 "%s: line %d: idassert ID \"%s\" is not a valid DN\n",
1789 fname, lineno, argv[1] );
1793 li->idassert_authzID.bv_len = STRLENOF( "dn:" ) + dn.bv_len;
1794 li->idassert_authzID.bv_val = ch_malloc( li->idassert_authzID.bv_len + 1 );
1795 AC_MEMCPY( li->idassert_authzID.bv_val, "dn:", STRLENOF( "dn:" ) );
1796 AC_MEMCPY( &li->idassert_authzID.bv_val[ STRLENOF( "dn:" ) ], dn.bv_val, dn.bv_len + 1 );
1797 ch_free( dn.bv_val );
1799 li->idassert_mode = LDAP_BACK_IDASSERT_OTHERDN;
1803 for ( argc -= 2, argv += 2; argc--; argv++ ) {
1804 if ( strcasecmp( argv[0], "override" ) == 0 ) {
1805 li->idassert_flags |= LDAP_BACK_AUTH_OVERRIDE;
1808 Debug( LDAP_DEBUG_ANY,
1809 "%s: line %d: unknown flag \"%s\" "
1810 "in \"idassert-mode <args> "
1811 "[<flags>]\" line.\n",
1812 fname, lineno, argv[0] );
1817 /* name to use for proxyAuthz propagation */
1818 } else if ( strcasecmp( argv[0], "idassert-authcdn" ) == 0
1819 || strcasecmp( argv[0], "proxyauthzdn" ) == 0 )
1824 /* FIXME: "proxyauthzdn" is no longer documented, and
1825 * temporarily supported for backwards compatibility */
1829 "%s: line %d: missing name in \"%s <name>\" line\n",
1830 fname, lineno, argv[0] );
1834 if ( !BER_BVISNULL( &li->idassert_authcDN ) ) {
1835 fprintf( stderr, "%s: line %d: "
1836 "authcDN already defined; replacing...\n",
1838 ch_free( li->idassert_authcDN.bv_val );
1841 ber_str2bv( argv[1], 0, 0, &dn );
1842 rc = dnNormalize( 0, NULL, NULL, &dn, &li->idassert_authcDN, NULL );
1843 if ( rc != LDAP_SUCCESS ) {
1844 Debug( LDAP_DEBUG_ANY,
1845 "%s: line %d: idassert ID \"%s\" is not a valid DN\n",
1846 fname, lineno, argv[1] );
1850 /* password to use for proxyAuthz propagation */
1851 } else if ( strcasecmp( argv[0], "idassert-passwd" ) == 0
1852 || strcasecmp( argv[0], "proxyauthzpw" ) == 0 )
1854 /* FIXME: "proxyauthzpw" is no longer documented, and
1855 * temporarily supported for backwards compatibility */
1859 "%s: line %d: missing password in \"%s <password>\" line\n",
1860 fname, lineno, argv[0] );
1864 if ( !BER_BVISNULL( &li->idassert_passwd ) ) {
1865 fprintf( stderr, "%s: line %d: "
1866 "passwd already defined; replacing...\n",
1868 ch_free( li->idassert_passwd.bv_val );
1871 ber_str2bv( argv[1], 0, 1, &li->idassert_passwd );
1873 /* rules to accept identity assertion... */
1874 } else if ( strcasecmp( argv[0], "idassert-authzFrom" ) == 0 ) {
1877 ber_str2bv( argv[1], 0, 1, &rule );
1879 ber_bvarray_add( &li->idassert_authz, &rule );
1881 } else if ( strcasecmp( argv[0], "idassert-method" ) == 0 ) {
1886 "%s: line %d: missing method in \"%s <method>\" line\n",
1887 fname, lineno, argv[0] );
1892 if ( strncasecmp( argv1, "bindmethod=", STRLENOF( "bindmethod=" ) ) == 0 ) {
1893 argv1 += STRLENOF( "bindmethod=" );
1896 if ( strcasecmp( argv1, "none" ) == 0 ) {
1897 /* FIXME: is this at all useful? */
1898 li->idassert_authmethod = LDAP_AUTH_NONE;
1902 "%s: line %d: trailing args in \"%s %s ...\" line ignored\"\n",
1903 fname, lineno, argv[0], argv[1] );
1906 } else if ( strcasecmp( argv1, "simple" ) == 0 ) {
1909 for ( arg = 2; arg < argc; arg++ ) {
1910 if ( strncasecmp( argv[arg], "authcdn=", STRLENOF( "authcdn=" ) ) == 0 ) {
1911 char *val = argv[arg] + STRLENOF( "authcdn=" );
1915 if ( !BER_BVISNULL( &li->idassert_authcDN ) ) {
1916 fprintf( stderr, "%s: line %d: "
1917 "SASL authcDN already defined; replacing...\n",
1919 ch_free( li->idassert_authcDN.bv_val );
1921 if ( strncasecmp( argv[arg], "dn:", STRLENOF( "dn:" ) ) == 0 ) {
1922 val += STRLENOF( "dn:" );
1925 ber_str2bv( val, 0, 0, &dn );
1926 rc = dnNormalize( 0, NULL, NULL, &dn, &li->idassert_authcDN, NULL );
1927 if ( rc != LDAP_SUCCESS ) {
1928 Debug( LDAP_DEBUG_ANY,
1929 "%s: line %d: SASL authcdn \"%s\" is not a valid DN\n",
1930 fname, lineno, val );
1934 } else if ( strncasecmp( argv[arg], "cred=", STRLENOF( "cred=" ) ) == 0 ) {
1935 char *val = argv[arg] + STRLENOF( "cred=" );
1937 if ( !BER_BVISNULL( &li->idassert_passwd ) ) {
1938 fprintf( stderr, "%s: line %d: "
1939 "SASL cred already defined; replacing...\n",
1941 ch_free( li->idassert_passwd.bv_val );
1943 ber_str2bv( val, 0, 1, &li->idassert_passwd );
1946 fprintf( stderr, "%s: line %d: "
1947 "unknown parameter %s\n",
1948 fname, lineno, argv[arg] );
1953 li->idassert_authmethod = LDAP_AUTH_SIMPLE;
1955 } else if ( strcasecmp( argv1, "sasl" ) == 0 ) {
1956 #ifdef HAVE_CYRUS_SASL
1959 for ( arg = 2; arg < argc; arg++ ) {
1960 if ( strncasecmp( argv[arg], "mech=", STRLENOF( "mech=" ) ) == 0 ) {
1961 char *val = argv[arg] + STRLENOF( "mech=" );
1963 if ( !BER_BVISNULL( &li->idassert_sasl_mech ) ) {
1964 fprintf( stderr, "%s: line %d: "
1965 "SASL mech already defined; replacing...\n",
1967 ch_free( li->idassert_sasl_mech.bv_val );
1969 ber_str2bv( val, 0, 1, &li->idassert_sasl_mech );
1971 } else if ( strncasecmp( argv[arg], "realm=", STRLENOF( "realm=" ) ) == 0 ) {
1972 char *val = argv[arg] + STRLENOF( "realm=" );
1974 if ( !BER_BVISNULL( &li->idassert_sasl_realm ) ) {
1975 fprintf( stderr, "%s: line %d: "
1976 "SASL realm already defined; replacing...\n",
1978 ch_free( li->idassert_sasl_realm.bv_val );
1980 ber_str2bv( val, 0, 1, &li->idassert_sasl_realm );
1982 } else if ( strncasecmp( argv[arg], "authcdn=", STRLENOF( "authcdn=" ) ) == 0 ) {
1983 char *val = argv[arg] + STRLENOF( "authcdn=" );
1987 if ( !BER_BVISNULL( &li->idassert_authcDN ) ) {
1988 fprintf( stderr, "%s: line %d: "
1989 "SASL authcDN already defined; replacing...\n",
1991 ch_free( li->idassert_authcDN.bv_val );
1993 if ( strncasecmp( argv[arg], "dn:", STRLENOF( "dn:" ) ) == 0 ) {
1994 val += STRLENOF( "dn:" );
1997 ber_str2bv( val, 0, 0, &dn );
1998 rc = dnNormalize( 0, NULL, NULL, &dn, &li->idassert_authcDN, NULL );
1999 if ( rc != LDAP_SUCCESS ) {
2000 Debug( LDAP_DEBUG_ANY,
2001 "%s: line %d: SASL authcdn \"%s\" is not a valid DN\n",
2002 fname, lineno, val );
2006 } else if ( strncasecmp( argv[arg], "authcid=", STRLENOF( "authcid=" ) ) == 0 ) {
2007 char *val = argv[arg] + STRLENOF( "authcid=" );
2009 if ( !BER_BVISNULL( &li->idassert_authcID ) ) {
2010 fprintf( stderr, "%s: line %d: "
2011 "SASL authcID already defined; replacing...\n",
2013 ch_free( li->idassert_authcID.bv_val );
2015 if ( strncasecmp( argv[arg], "u:", STRLENOF( "u:" ) ) == 0 ) {
2016 val += STRLENOF( "u:" );
2018 ber_str2bv( val, 0, 1, &li->idassert_authcID );
2020 } else if ( strncasecmp( argv[arg], "cred=", STRLENOF( "cred=" ) ) == 0 ) {
2021 char *val = argv[arg] + STRLENOF( "cred=" );
2023 if ( !BER_BVISNULL( &li->idassert_passwd ) ) {
2024 fprintf( stderr, "%s: line %d: "
2025 "SASL cred already defined; replacing...\n",
2027 ch_free( li->idassert_passwd.bv_val );
2029 ber_str2bv( val, 0, 1, &li->idassert_passwd );
2031 } else if ( strncasecmp( argv[arg], "authz=", STRLENOF( "authz=" ) ) == 0 ) {
2032 char *val = argv[arg] + STRLENOF( "authz=" );
2034 if ( strcasecmp( val, "proxyauthz" ) == 0 ) {
2035 li->idassert_flags &= ~LDAP_BACK_AUTH_NATIVE_AUTHZ;
2037 } else if ( strcasecmp( val, "native" ) == 0 ) {
2038 li->idassert_flags |= LDAP_BACK_AUTH_NATIVE_AUTHZ;
2041 fprintf( stderr, "%s: line %d: "
2042 "unknown authz mode \"%s\"\n",
2043 fname, lineno, val );
2048 fprintf( stderr, "%s: line %d: "
2049 "unknown SASL parameter %s\n",
2050 fname, lineno, argv[arg] );
2055 li->idassert_authmethod = LDAP_AUTH_SASL;
2057 #else /* !HAVE_CYRUS_SASL */
2058 fprintf( stderr, "%s: line %d: "
2059 "compile --with-cyrus-sasl to enable SASL auth\n",
2062 #endif /* !HAVE_CYRUS_SASL */
2065 fprintf( stderr, "%s: line %d: "
2066 "unhandled idassert-method method %s\n",
2067 fname, lineno, argv[1] );
2072 return SLAP_CONF_UNKNOWN;
2087 struct ldapinfo *li = (struct ldapinfo *) be->be_private;
2089 /* name to use for remote ACL access */
2090 if ( strcasecmp( argv[0], "acl-authcdn" ) == 0
2091 || strcasecmp( argv[0], "binddn" ) == 0 )
2096 /* FIXME: "binddn" is no longer documented, and
2097 * temporarily supported for backwards compatibility */
2101 "%s: line %d: missing name in \"%s <name>\" line\n",
2102 fname, lineno, argv[0] );
2106 if ( !BER_BVISNULL( &li->acl_authcDN ) ) {
2107 fprintf( stderr, "%s: line %d: "
2108 "authcDN already defined; replacing...\n",
2110 ch_free( li->acl_authcDN.bv_val );
2113 ber_str2bv( argv[1], 0, 0, &dn );
2114 rc = dnNormalize( 0, NULL, NULL, &dn, &li->acl_authcDN, NULL );
2115 if ( rc != LDAP_SUCCESS ) {
2116 Debug( LDAP_DEBUG_ANY,
2117 "%s: line %d: acl ID \"%s\" is not a valid DN\n",
2118 fname, lineno, argv[1] );
2122 /* password to use for remote ACL access */
2123 } else if ( strcasecmp( argv[0], "acl-passwd" ) == 0
2124 || strcasecmp( argv[0], "bindpw" ) == 0 )
2126 /* FIXME: "bindpw" is no longer documented, and
2127 * temporarily supported for backwards compatibility */
2131 "%s: line %d: missing password in \"%s <password>\" line\n",
2132 fname, lineno, argv[0] );
2136 if ( !BER_BVISNULL( &li->acl_passwd ) ) {
2137 fprintf( stderr, "%s: line %d: "
2138 "passwd already defined; replacing...\n",
2140 ch_free( li->acl_passwd.bv_val );
2143 ber_str2bv( argv[1], 0, 1, &li->acl_passwd );
2145 } else if ( strcasecmp( argv[0], "acl-method" ) == 0 ) {
2150 "%s: line %d: missing method in \"%s <method>\" line\n",
2151 fname, lineno, argv[0] );
2156 if ( strncasecmp( argv1, "bindmethod=", STRLENOF( "bindmethod=" ) ) == 0 ) {
2157 argv1 += STRLENOF( "bindmethod=" );
2160 if ( strcasecmp( argv1, "none" ) == 0 ) {
2161 /* FIXME: is this at all useful? */
2162 li->acl_authmethod = LDAP_AUTH_NONE;
2166 "%s: line %d: trailing args in \"%s %s ...\" line ignored\"\n",
2167 fname, lineno, argv[0], argv[1] );
2170 } else if ( strcasecmp( argv1, "simple" ) == 0 ) {
2171 li->acl_authmethod = LDAP_AUTH_SIMPLE;
2175 "%s: line %d: trailing args in \"%s %s ...\" line ignored\"\n",
2176 fname, lineno, argv[0], argv[1] );
2179 } else if ( strcasecmp( argv1, "sasl" ) == 0 ) {
2180 #ifdef HAVE_CYRUS_SASL
2183 for ( arg = 2; arg < argc; arg++ ) {
2184 if ( strncasecmp( argv[arg], "mech=", STRLENOF( "mech=" ) ) == 0 ) {
2185 char *val = argv[arg] + STRLENOF( "mech=" );
2187 if ( !BER_BVISNULL( &li->acl_sasl_mech ) ) {
2188 fprintf( stderr, "%s: line %d: "
2189 "SASL mech already defined; replacing...\n",
2191 ch_free( li->acl_sasl_mech.bv_val );
2193 ber_str2bv( val, 0, 1, &li->acl_sasl_mech );
2195 } else if ( strncasecmp( argv[arg], "realm=", STRLENOF( "realm=" ) ) == 0 ) {
2196 char *val = argv[arg] + STRLENOF( "realm=" );
2198 if ( !BER_BVISNULL( &li->acl_sasl_realm ) ) {
2199 fprintf( stderr, "%s: line %d: "
2200 "SASL realm already defined; replacing...\n",
2202 ch_free( li->acl_sasl_realm.bv_val );
2204 ber_str2bv( val, 0, 1, &li->acl_sasl_realm );
2206 } else if ( strncasecmp( argv[arg], "authcdn=", STRLENOF( "authcdn=" ) ) == 0 ) {
2207 char *val = argv[arg] + STRLENOF( "authcdn=" );
2211 if ( !BER_BVISNULL( &li->acl_authcDN ) ) {
2212 fprintf( stderr, "%s: line %d: "
2213 "SASL authcDN already defined; replacing...\n",
2215 ch_free( li->acl_authcDN.bv_val );
2217 if ( strncasecmp( argv[arg], "dn:", STRLENOF( "dn:" ) ) == 0 ) {
2218 val += STRLENOF( "dn:" );
2221 ber_str2bv( val, 0, 0, &dn );
2222 rc = dnNormalize( 0, NULL, NULL, &dn, &li->acl_authcDN, NULL );
2223 if ( rc != LDAP_SUCCESS ) {
2224 Debug( LDAP_DEBUG_ANY,
2225 "%s: line %d: SASL authcdn \"%s\" is not a valid DN\n",
2226 fname, lineno, val );
2230 } else if ( strncasecmp( argv[arg], "authcid=", STRLENOF( "authcid=" ) ) == 0 ) {
2231 char *val = argv[arg] + STRLENOF( "authcid=" );
2233 if ( !BER_BVISNULL( &li->acl_authcID ) ) {
2234 fprintf( stderr, "%s: line %d: "
2235 "SASL authcID already defined; replacing...\n",
2237 ch_free( li->acl_authcID.bv_val );
2239 if ( strncasecmp( argv[arg], "u:", STRLENOF( "u:" ) ) == 0 ) {
2240 val += STRLENOF( "u:" );
2242 ber_str2bv( val, 0, 1, &li->acl_authcID );
2244 } else if ( strncasecmp( argv[arg], "cred=", STRLENOF( "cred=" ) ) == 0 ) {
2245 char *val = argv[arg] + STRLENOF( "cred=" );
2247 if ( !BER_BVISNULL( &li->acl_passwd ) ) {
2248 fprintf( stderr, "%s: line %d: "
2249 "SASL cred already defined; replacing...\n",
2251 ch_free( li->acl_passwd.bv_val );
2253 ber_str2bv( val, 0, 1, &li->acl_passwd );
2256 fprintf( stderr, "%s: line %d: "
2257 "unknown SASL parameter %s\n",
2258 fname, lineno, argv[arg] );
2263 li->acl_authmethod = LDAP_AUTH_SASL;
2265 #else /* !HAVE_CYRUS_SASL */
2266 fprintf( stderr, "%s: line %d: "
2267 "compile --with-cyrus-sasl to enable SASL auth\n",
2270 #endif /* !HAVE_CYRUS_SASL */
2273 fprintf( stderr, "%s: line %d: "
2274 "unhandled acl-method method %s\n",
2275 fname, lineno, argv[1] );
2280 return SLAP_CONF_UNKNOWN;