1 /* config.c - ldap backend configuration file routine */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2003-2004 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>
29 #include <ac/socket.h>
32 #include "back-ldap.h"
35 static SLAP_EXTOP_MAIN_FN ldap_back_exop_whoami;
38 parse_idassert( BackendDB *be, const char *fname, int lineno,
39 int argc, char **argv );
50 struct ldapinfo *li = (struct ldapinfo *) be->be_private;
53 fprintf( stderr, "%s: line %d: ldap backend info is null!\n",
58 /* server address to query (depricated, use "uri" directive) */
59 if ( strcasecmp( argv[0], "server" ) == 0 ) {
62 "%s: line %d: missing address in \"server <address>\" line\n",
68 li->url = ch_calloc(strlen(argv[1]) + 9, sizeof(char));
69 if (li->url != NULL) {
70 strcpy(li->url, "ldap://");
71 strcat(li->url, argv[1]);
75 /* URI of server to query (preferred over "server" directive) */
76 } else if ( strcasecmp( argv[0], "uri" ) == 0 ) {
80 fprintf( stderr, "%s: line %d: "
82 "in \"uri <uri>\" line\n",
86 if ( li->url != NULL ) {
89 if ( li->lud != NULL ) {
90 ldap_free_urldesc( li->lud );
93 if ( ldap_url_parse( argv[ 1 ], &li->lud ) != LDAP_URL_SUCCESS ) {
94 fprintf( stderr, "%s: line %d: "
95 "unable to parse uri \"%s\" "
96 "in \"uri <uri>\" line\n",
97 fname, lineno, argv[ 1 ] );
101 if ( ( li->lud->lud_dn != NULL && li->lud->lud_dn[0] != '\0' )
102 || li->lud->lud_attrs != NULL
103 || li->lud->lud_filter != NULL
104 || li->lud->lud_exts != NULL )
106 fprintf( stderr, "%s: line %d: "
107 "warning, only protocol, "
108 "host and port allowed "
109 "in \"uri <uri>\" line\n",
116 tmplud.lud_attrs = NULL;
117 tmplud.lud_filter = NULL;
118 if ( !ldap_is_ldapi_url( argv[ 1 ] ) ) {
119 tmplud.lud_exts = NULL;
120 tmplud.lud_crit_exts = 0;
123 li->url = ldap_url_desc2str( &tmplud );
124 if ( li->url == NULL ) {
125 fprintf( stderr, "%s: line %d: "
126 "unable to rebuild uri \"%s\" "
127 "in \"uri <uri>\" line\n",
128 fname, lineno, argv[ 1 ] );
132 li->url = ch_strdup( argv[ 1 ] );
135 /* name to use for ldap_back_group */
136 } else if ( strcasecmp( argv[0], "acl-authcdn" ) == 0
137 || strcasecmp( argv[0], "binddn" ) == 0 ) {
140 "%s: line %d: missing name in \"%s <name>\" line\n",
141 fname, lineno, argv[0] );
144 ber_str2bv( argv[1], 0, 1, &li->acl_authcDN );
146 /* password to use for ldap_back_group */
147 } else if ( strcasecmp( argv[0], "acl-passwd" ) == 0
148 || strcasecmp( argv[0], "bindpw" ) == 0 ) {
151 "%s: line %d: missing password in \"%s <password>\" line\n",
152 fname, lineno, argv[0] );
155 ber_str2bv( argv[1], 0, 1, &li->acl_passwd );
157 #ifdef LDAP_BACK_PROXY_AUTHZ
158 /* identity assertion stuff... */
159 } else if ( strncasecmp( argv[0], "idassert-", STRLENOF( "idassert-" ) ) == 0
160 || strncasecmp( argv[0], "proxyauthz", STRLENOF( "proxyauthz" ) ) == 0 ) {
161 return parse_idassert( be, fname, lineno, argc, argv );
162 #endif /* LDAP_BACK_PROXY_AUTHZ */
164 /* save bind creds for referral rebinds? */
165 } else if ( strcasecmp( argv[0], "rebind-as-user" ) == 0 ) {
168 "%s: line %d: rebind-as-user takes no arguments\n",
174 /* intercept exop_who_am_i? */
175 } else if ( strcasecmp( argv[0], "proxy-whoami" ) == 0 ) {
178 "%s: line %d: proxy-whoami takes no arguments\n",
182 load_extop( (struct berval *)&slap_EXOP_WHOAMI,
183 0, ldap_back_exop_whoami );
186 } else if ( strcasecmp( argv[0], "suffixmassage" ) == 0 ) {
188 struct berval bvnc, nvnc, pvnc, brnc, nrnc, prnc;
189 #ifdef ENABLE_REWRITE
191 #endif /* ENABLE_REWRITE */
196 * suffixmassage <suffix> <massaged suffix>
198 * the <suffix> field must be defined as a valid suffix
199 * (or suffixAlias?) for the current database;
200 * the <massaged suffix> shouldn't have already been
201 * defined as a valid suffix or suffixAlias for the
205 fprintf( stderr, "%s: line %d: syntax is"
206 " \"suffixMassage <suffix>"
207 " <massaged suffix>\"\n",
212 ber_str2bv( argv[1], 0, 0, &bvnc );
213 if ( dnPrettyNormal( NULL, &bvnc, &pvnc, &nvnc, NULL ) != LDAP_SUCCESS ) {
214 fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
215 fname, lineno, bvnc.bv_val );
218 tmp_be = select_backend( &nvnc, 0, 0 );
219 if ( tmp_be != NULL && tmp_be != be ) {
220 fprintf( stderr, "%s: line %d: suffix already in use"
221 " by another backend in"
222 " \"suffixMassage <suffix>"
223 " <massaged suffix>\"\n",
230 ber_str2bv( argv[2], 0, 0, &brnc );
231 if ( dnPrettyNormal( NULL, &brnc, &prnc, &nrnc, NULL ) != LDAP_SUCCESS ) {
232 fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n",
233 fname, lineno, brnc.bv_val );
240 tmp_be = select_backend( &nrnc, 0, 0 );
241 if ( tmp_be != NULL ) {
242 fprintf( stderr, "%s: line %d: massaged suffix"
243 " already in use by another backend in"
244 " \"suffixMassage <suffix>"
245 " <massaged suffix>\"\n",
255 #ifdef ENABLE_REWRITE
257 * The suffix massaging is emulated by means of the
258 * rewrite capabilities
259 * FIXME: no extra rewrite capabilities should be added
262 rc = suffix_massage_config( li->rwmap.rwm_rw,
263 &pvnc, &nvnc, &prnc, &nrnc );
271 #else /* !ENABLE_REWRITE */
272 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &pvnc );
273 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &nvnc );
275 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &prnc );
276 ber_bvarray_add( &li->rwmap.rwm_suffix_massage, &nrnc );
277 #endif /* !ENABLE_REWRITE */
279 /* rewrite stuff ... */
280 } else if ( strncasecmp( argv[0], "rewrite", 7 ) == 0 ) {
281 #ifdef ENABLE_REWRITE
282 return rewrite_parse( li->rwmap.rwm_rw,
283 fname, lineno, argc, argv );
285 #else /* !ENABLE_REWRITE */
286 fprintf( stderr, "%s: line %d: rewrite capabilities "
287 "are not enabled\n", fname, lineno );
288 #endif /* !ENABLE_REWRITE */
290 /* objectclass/attribute mapping */
291 } else if ( strcasecmp( argv[0], "map" ) == 0 ) {
292 return ldap_back_map_config( &li->rwmap.rwm_oc,
294 fname, lineno, argc, argv );
298 return SLAP_CONF_UNKNOWN;
304 ldap_back_map_config(
305 struct ldapmap *oc_map,
306 struct ldapmap *at_map,
313 struct ldapmapping *mapping;
317 if ( argc < 3 || argc > 4 ) {
319 "%s: line %d: syntax is \"map {objectclass | attribute} [<local> | *] {<foreign> | *}\"\n",
324 if ( strcasecmp( argv[1], "objectclass" ) == 0 ) {
328 } else if ( strcasecmp( argv[1], "attribute" ) == 0 ) {
332 fprintf( stderr, "%s: line %d: syntax is "
333 "\"map {objectclass | attribute} [<local> | *] "
334 "{<foreign> | *}\"\n",
339 if ( strcmp( argv[2], "*" ) == 0 ) {
340 if ( argc < 4 || strcmp( argv[3], "*" ) == 0 ) {
341 map->drop_missing = ( argc < 4 );
346 } else if ( argc < 4 ) {
352 dst = ( strcmp( argv[3], "*" ) == 0 ? src : argv[3] );
355 if ( ( map == at_map )
356 && ( strcasecmp( src, "objectclass" ) == 0
357 || strcasecmp( dst, "objectclass" ) == 0 ) )
360 "%s: line %d: objectclass attribute cannot be mapped\n",
364 mapping = (struct ldapmapping *)ch_calloc( 2,
365 sizeof(struct ldapmapping) );
366 if ( mapping == NULL ) {
368 "%s: line %d: out of memory\n",
372 ber_str2bv( src, 0, 1, &mapping->src );
373 ber_str2bv( dst, 0, 1, &mapping->dst );
374 mapping[1].src = mapping->dst;
375 mapping[1].dst = mapping->src;
381 if ( src[0] != '\0' ) {
382 if ( oc_bvfind( &mapping->src ) == NULL ) {
384 "%s: line %d: warning, source objectClass '%s' "
385 "should be defined in schema\n",
386 fname, lineno, src );
389 * FIXME: this should become an err
395 if ( oc_bvfind( &mapping->dst ) == NULL ) {
397 "%s: line %d: warning, destination objectClass '%s' "
398 "is not defined in schema\n",
399 fname, lineno, dst );
403 const char *text = NULL;
404 AttributeDescription *ad = NULL;
406 if ( src[0] != '\0' ) {
407 rc = slap_bv2ad( &mapping->src, &ad, &text );
408 if ( rc != LDAP_SUCCESS ) {
410 "%s: line %d: warning, source attributeType '%s' "
411 "should be defined in schema\n",
412 fname, lineno, src );
415 * FIXME: this should become an err
423 rc = slap_bv2ad( &mapping->dst, &ad, &text );
424 if ( rc != LDAP_SUCCESS ) {
426 "%s: line %d: warning, destination attributeType '%s' "
427 "is not defined in schema\n",
428 fname, lineno, dst );
432 if ( (src[0] != '\0' && avl_find( map->map, (caddr_t)mapping, mapping_cmp ) != NULL)
433 || avl_find( map->remap, (caddr_t)&mapping[1], mapping_cmp ) != NULL)
436 "%s: line %d: duplicate mapping found (ignored)\n",
441 if ( src[0] != '\0' ) {
442 avl_insert( &map->map, (caddr_t)mapping,
443 mapping_cmp, mapping_dup );
445 avl_insert( &map->remap, (caddr_t)&mapping[1],
446 mapping_cmp, mapping_dup );
452 ch_free( mapping->src.bv_val );
453 ch_free( mapping->dst.bv_val );
461 ldap_back_exop_whoami(
465 struct berval *bv = NULL;
467 if ( op->oq_extended.rs_reqdata != NULL ) {
468 /* no request data should be provided */
469 rs->sr_text = "no request data expected";
470 return rs->sr_err = LDAP_PROTOCOL_ERROR;
473 rs->sr_err = backend_check_restrictions( op, rs,
474 (struct berval *)&slap_EXOP_WHOAMI );
475 if( rs->sr_err != LDAP_SUCCESS ) return rs->sr_err;
477 /* if auth'd by back-ldap and request is proxied, forward it */
478 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)) {
481 LDAPControl c, *ctrls[2] = {NULL, NULL};
487 op2.o_ndn = op->o_conn->c_ndn;
488 lc = ldap_back_getconn(&op2, rs);
489 if (!lc || !ldap_back_dobind( lc, op, rs )) {
492 c.ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
493 c.ldctl_iscritical = 1;
494 c.ldctl_value.bv_val = ch_malloc(op->o_ndn.bv_len+4);
495 c.ldctl_value.bv_len = op->o_ndn.bv_len + 3;
496 strcpy(c.ldctl_value.bv_val, "dn:");
497 strcpy(c.ldctl_value.bv_val+3, op->o_ndn.bv_val);
499 rs->sr_err = ldap_whoami(lc->ld, ctrls, NULL, &msgid);
500 if (rs->sr_err == LDAP_SUCCESS) {
501 if (ldap_result(lc->ld, msgid, 1, NULL, &res) == -1) {
502 ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER,
505 rs->sr_err = ldap_parse_whoami(lc->ld, res, &bv);
509 ch_free(c.ldctl_value.bv_val);
510 if (rs->sr_err != LDAP_SUCCESS) {
511 rs->sr_err = slap_map_api2result( rs );
514 /* else just do the same as before */
515 bv = (struct berval *) ch_malloc( sizeof(struct berval) );
516 if( op->o_dn.bv_len ) {
517 bv->bv_len = op->o_dn.bv_len + sizeof("dn:") - 1;
518 bv->bv_val = ch_malloc( bv->bv_len + 1 );
519 AC_MEMCPY( bv->bv_val, "dn:", sizeof("dn:") - 1 );
520 AC_MEMCPY( &bv->bv_val[sizeof("dn:") - 1], op->o_dn.bv_val,
522 bv->bv_val[bv->bv_len] = '\0';
534 #ifdef ENABLE_REWRITE
536 suffix_massage_regexize( const char *s )
543 ( r = strchr( p, ',' ) ) != NULL;
547 res = ch_calloc( sizeof( char ), strlen( s ) + 4 + 4*i + 1 );
549 ptr = lutil_strcopy( res, "(.*)" );
551 ( r = strchr( p, ',' ) ) != NULL;
553 ptr = lutil_strncopy( ptr, p, r - p + 1 );
554 ptr = lutil_strcopy( ptr, "[ ]?" );
556 if ( r[ 1 ] == ' ' ) {
560 lutil_strcopy( ptr, p );
566 suffix_massage_patternize( const char *s )
573 res = ch_calloc( sizeof( char ), len + sizeof( "%1" ) );
579 strcpy( res + sizeof( "%1" ) - 1, s );
585 suffix_massage_config(
586 struct rewrite_info *info,
596 rargv[ 0 ] = "rewriteEngine";
599 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
601 rargv[ 0 ] = "rewriteContext";
602 rargv[ 1 ] = "default";
604 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
606 rargv[ 0 ] = "rewriteRule";
607 rargv[ 1 ] = suffix_massage_regexize( pvnc->bv_val );
608 rargv[ 2 ] = suffix_massage_patternize( prnc->bv_val );
611 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
612 ch_free( rargv[ 1 ] );
613 ch_free( rargv[ 2 ] );
615 rargv[ 0 ] = "rewriteContext";
616 rargv[ 1 ] = "searchResult";
618 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
620 rargv[ 0 ] = "rewriteRule";
621 rargv[ 1 ] = suffix_massage_regexize( prnc->bv_val );
622 rargv[ 2 ] = suffix_massage_patternize( pvnc->bv_val );
625 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
626 ch_free( rargv[ 1 ] );
627 ch_free( rargv[ 2 ] );
629 rargv[ 0 ] = "rewriteContext";
630 rargv[ 1 ] = "matchedDN";
631 rargv[ 2 ] = "alias";
632 rargv[ 3 ] = "searchResult";
634 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
636 rargv[ 0 ] = "rewriteContext";
637 rargv[ 1 ] = "searchAttrDN";
638 rargv[ 2 ] = "alias";
639 rargv[ 3 ] = "searchResult";
641 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
645 #endif /* ENABLE_REWRITE */
647 #ifdef LDAP_BACK_PROXY_AUTHZ
657 struct ldapinfo *li = (struct ldapinfo *) be->be_private;
659 /* identity assertion mode */
660 if ( strcasecmp( argv[0], "idassert-mode" ) == 0 ) {
663 LDAP_LOG( CONFIG, CRIT,
664 "%s: line %d: illegal args number %d in \"idassert-mode <args>\" line.\n",
665 fname, lineno, argc );
667 Debug( LDAP_DEBUG_ANY,
668 "%s: line %d: illegal args number %d in \"idassert-mode <args>\" line.\n",
669 fname, lineno, argc );
674 if ( strcasecmp( argv[1], "legacy" ) == 0 ) {
675 /* will proxyAuthz as client's identity only if bound */
676 li->idassert_mode = LDAP_BACK_IDASSERT_LEGACY;
678 } else if ( strcasecmp( argv[1], "self" ) == 0 ) {
679 /* will proxyAuthz as client's identity */
680 li->idassert_mode = LDAP_BACK_IDASSERT_SELF;
682 } else if ( strcasecmp( argv[1], "anonymous" ) == 0 ) {
683 /* will proxyAuthz as anonymous */
684 li->idassert_mode = LDAP_BACK_IDASSERT_ANONYMOUS;
686 } else if ( strcasecmp( argv[1], "none" ) == 0 ) {
687 /* will not proxyAuthz */
688 li->idassert_mode = LDAP_BACK_IDASSERT_NOASSERT;
694 /* will proxyAuthz as argv[1] */
695 ber_str2bv( argv[1], 0, 0, &id );
697 if ( strncasecmp( id.bv_val, "u:", STRLENOF( "u:" ) ) == 0 ) {
698 /* force lowercase... */
700 li->idassert_mode = LDAP_BACK_IDASSERT_OTHERID;
701 ber_dupbv( &li->idassert_authzID, &id );
707 if ( strncasecmp( id.bv_val, "dn:", STRLENOF( "dn:" ) ) == 0 ) {
708 id.bv_val += STRLENOF( "dn:" );
709 id.bv_len -= STRLENOF( "dn:" );
712 rc = dnNormalize( 0, NULL, NULL, &id, &dn, NULL );
713 if ( rc != LDAP_SUCCESS ) {
715 LDAP_LOG( CONFIG, CRIT,
716 "%s: line %d: idassert ID \"%s\" is not a valid DN.\n",
717 fname, lineno, argv[1] );
719 Debug( LDAP_DEBUG_ANY,
720 "%s: line %d: idassert ID \"%s\" is not a valid DN\n",
721 fname, lineno, argv[1] );
726 li->idassert_authzID.bv_len = STRLENOF( "dn:" ) + dn.bv_len;
727 li->idassert_authzID.bv_val = ch_malloc( li->idassert_authzID.bv_len + 1 );
728 AC_MEMCPY( li->idassert_authzID.bv_val, "dn:", STRLENOF( "dn:" ) );
729 AC_MEMCPY( &li->idassert_authzID.bv_val[ STRLENOF( "dn:" ) ], dn.bv_val, dn.bv_len + 1 );
730 ch_free( dn.bv_val );
732 li->idassert_mode = LDAP_BACK_IDASSERT_OTHERDN;
736 /* name to use for proxyAuthz propagation */
737 } else if ( strcasecmp( argv[0], "idassert-authcdn" ) == 0
738 || strcasecmp( argv[0], "proxyauthzdn" ) == 0 )
743 /* FIXME: "proxyauthzdn" is no longer documented, and
744 * temporarily supported for backwards compatibility */
748 "%s: line %d: missing name in \"%s <name>\" line\n",
749 fname, lineno, argv[0] );
753 if ( !BER_BVISNULL( &li->idassert_authcDN ) ) {
754 fprintf( stderr, "%s: line %d: "
755 "authcDN already defined; replacing...\n",
757 ch_free( li->idassert_authcDN.bv_val );
760 ber_str2bv( argv[1], 0, 0, &dn );
761 rc = dnNormalize( 0, NULL, NULL, &dn, &li->idassert_authcDN, NULL );
762 if ( rc != LDAP_SUCCESS ) {
764 LDAP_LOG( CONFIG, CRIT,
765 "%s: line %d: idassert ID \"%s\" is not a valid DN.\n",
766 fname, lineno, argv[1] );
768 Debug( LDAP_DEBUG_ANY,
769 "%s: line %d: idassert ID \"%s\" is not a valid DN\n",
770 fname, lineno, argv[1] );
775 /* password to use for proxyAuthz propagation */
776 } else if ( strcasecmp( argv[0], "idassert-passwd" ) == 0
777 || strcasecmp( argv[0], "proxyauthzpw" ) == 0 )
779 /* FIXME: "proxyauthzpw" is no longer documented, and
780 * temporarily supported for backwards compatibility */
784 "%s: line %d: missing password in \"%s <password>\" line\n",
785 fname, lineno, argv[0] );
789 if ( !BER_BVISNULL( &li->idassert_passwd ) ) {
790 fprintf( stderr, "%s: line %d: "
791 "passwd already defined; replacing...\n",
793 ch_free( li->idassert_passwd.bv_val );
796 ber_str2bv( argv[1], 0, 1, &li->idassert_passwd );
798 /* rules to accept identity assertion... */
799 } else if ( strcasecmp( argv[0], "idassert-authzFrom" ) == 0 ) {
802 ber_str2bv( argv[1], 0, 1, &rule );
804 ber_bvarray_add( &li->idassert_authz, &rule );
806 } else if ( strcasecmp( argv[0], "idassert-method" ) == 0 ) {
809 "%s: line %d: missing method in \"%s <method>\" line\n",
810 fname, lineno, argv[0] );
814 if ( strcasecmp( argv[1], "none" ) == 0 ) {
815 /* FIXME: is this useful? */
816 li->idassert_authmethod = LDAP_AUTH_NONE;
820 "%s: line %d: trailing args in \"%s %s ...\" line ignored\"\n",
821 fname, lineno, argv[0], argv[1] );
824 } else if ( strcasecmp( argv[1], "simple" ) == 0 ) {
825 li->idassert_authmethod = LDAP_AUTH_SIMPLE;
829 "%s: line %d: trailing args in \"%s %s ...\" line ignored\"\n",
830 fname, lineno, argv[0], argv[1] );
833 } else if ( strcasecmp( argv[1], "sasl" ) == 0 ) {
834 #ifdef HAVE_CYRUS_SASL
837 for ( arg = 2; arg < argc; arg++ ) {
838 if ( strncasecmp( argv[arg], "mech=", STRLENOF( "mech=" ) ) == 0 ) {
839 char *val = argv[arg] + STRLENOF( "mech=" );
841 if ( !BER_BVISNULL( &li->idassert_sasl_mech ) ) {
842 fprintf( stderr, "%s: line %d: "
843 "SASL mech already defined; replacing...\n",
845 ch_free( li->idassert_sasl_mech.bv_val );
847 ber_str2bv( val, 0, 1, &li->idassert_sasl_mech );
849 } else if ( strncasecmp( argv[arg], "realm=", STRLENOF( "realm=" ) ) == 0 ) {
850 char *val = argv[arg] + STRLENOF( "realm=" );
852 if ( !BER_BVISNULL( &li->idassert_sasl_realm ) ) {
853 fprintf( stderr, "%s: line %d: "
854 "SASL realm already defined; replacing...\n",
856 ch_free( li->idassert_sasl_realm.bv_val );
858 ber_str2bv( val, 0, 1, &li->idassert_sasl_realm );
860 } else if ( strncasecmp( argv[arg], "authcdn=", STRLENOF( "authcdn=" ) ) == 0 ) {
861 char *val = argv[arg] + STRLENOF( "authcdn=" );
865 if ( !BER_BVISNULL( &li->idassert_authcDN ) ) {
866 fprintf( stderr, "%s: line %d: "
867 "SASL authcDN already defined; replacing...\n",
869 ch_free( li->idassert_authcDN.bv_val );
871 if ( strncasecmp( argv[arg], "dn:", STRLENOF( "dn:" ) ) == 0 ) {
872 val += STRLENOF( "dn:" );
875 ber_str2bv( val, 0, 0, &dn );
876 rc = dnNormalize( 0, NULL, NULL, &dn, &li->idassert_authcDN, NULL );
877 if ( rc != LDAP_SUCCESS ) {
879 LDAP_LOG( CONFIG, CRIT,
880 "%s: line %d: SASL authcdn \"%s\" is not a valid DN.\n",
881 fname, lineno, val );
883 Debug( LDAP_DEBUG_ANY,
884 "%s: line %d: SASL authcdn \"%s\" is not a valid DN\n",
885 fname, lineno, val );
890 } else if ( strncasecmp( argv[arg], "authcid=", STRLENOF( "authcid=" ) ) == 0 ) {
891 char *val = argv[arg] + STRLENOF( "authcid=" );
893 if ( !BER_BVISNULL( &li->idassert_authcID ) ) {
894 fprintf( stderr, "%s: line %d: "
895 "SASL authcID already defined; replacing...\n",
897 ch_free( li->idassert_authcID.bv_val );
899 if ( strncasecmp( argv[arg], "u:", STRLENOF( "u:" ) ) == 0 ) {
900 val += STRLENOF( "u:" );
902 ber_str2bv( val, 0, 1, &li->idassert_authcID );
904 } else if ( strncasecmp( argv[arg], "cred=", STRLENOF( "cred=" ) ) == 0 ) {
905 char *val = argv[arg] + STRLENOF( "cred=" );
907 if ( !BER_BVISNULL( &li->idassert_passwd ) ) {
908 fprintf( stderr, "%s: line %d: "
909 "SASL cred already defined; replacing...\n",
911 ch_free( li->idassert_passwd.bv_val );
913 ber_str2bv( val, 0, 1, &li->idassert_passwd );
915 } else if ( strncasecmp( argv[arg], "authz=", STRLENOF( "authz=" ) ) == 0 ) {
916 char *val = argv[arg] + STRLENOF( "authz=" );
918 if ( strcasecmp( val, "proxyauthz" ) == 0 ) {
919 li->idassert_flags &= ~LDAP_BACK_AUTH_NATIVE_AUTHZ;
921 } else if ( strcasecmp( val, "native" ) == 0 ) {
922 li->idassert_flags |= LDAP_BACK_AUTH_NATIVE_AUTHZ;
925 fprintf( stderr, "%s: line %s: "
926 "unknown authz mode \"%s\"\n",
927 fname, lineno, val );
932 fprintf( stderr, "%s: line %d: "
933 "unknown SASL parameter %s\n",
934 fname, lineno, argv[arg] );
939 li->idassert_authmethod = LDAP_AUTH_SASL;
941 #else /* !HAVE_CYRUS_SASL */
942 fprintf( stderr, "%s: line %d: "
943 "compile --with-cyrus-sasl to enable SASL auth\n",
946 #endif /* !HAVE_CYRUS_SASL */
949 fprintf( stderr, "%s: line %d: "
950 "unhandled auth method %s\n",
956 return SLAP_CONF_UNKNOWN;
961 #endif /* LDAP_BACK_PROXY_AUTHZ */