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,
504 ldap_back_freeconn( op, lc );
508 rs->sr_err = ldap_parse_whoami(lc->ld, res, &bv);
512 ch_free(c.ldctl_value.bv_val);
513 if (rs->sr_err != LDAP_SUCCESS) {
514 rs->sr_err = slap_map_api2result( rs );
517 /* else just do the same as before */
518 bv = (struct berval *) ch_malloc( sizeof(struct berval) );
519 if( op->o_dn.bv_len ) {
520 bv->bv_len = op->o_dn.bv_len + sizeof("dn:") - 1;
521 bv->bv_val = ch_malloc( bv->bv_len + 1 );
522 AC_MEMCPY( bv->bv_val, "dn:", sizeof("dn:") - 1 );
523 AC_MEMCPY( &bv->bv_val[sizeof("dn:") - 1], op->o_dn.bv_val,
525 bv->bv_val[bv->bv_len] = '\0';
537 #ifdef ENABLE_REWRITE
539 suffix_massage_regexize( const char *s )
546 ( r = strchr( p, ',' ) ) != NULL;
550 res = ch_calloc( sizeof( char ), strlen( s ) + 4 + 4*i + 1 );
552 ptr = lutil_strcopy( res, "(.*)" );
554 ( r = strchr( p, ',' ) ) != NULL;
556 ptr = lutil_strncopy( ptr, p, r - p + 1 );
557 ptr = lutil_strcopy( ptr, "[ ]?" );
559 if ( r[ 1 ] == ' ' ) {
563 lutil_strcopy( ptr, p );
569 suffix_massage_patternize( const char *s )
576 res = ch_calloc( sizeof( char ), len + sizeof( "%1" ) );
582 strcpy( res + sizeof( "%1" ) - 1, s );
588 suffix_massage_config(
589 struct rewrite_info *info,
599 rargv[ 0 ] = "rewriteEngine";
602 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
604 rargv[ 0 ] = "rewriteContext";
605 rargv[ 1 ] = "default";
607 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
609 rargv[ 0 ] = "rewriteRule";
610 rargv[ 1 ] = suffix_massage_regexize( pvnc->bv_val );
611 rargv[ 2 ] = suffix_massage_patternize( prnc->bv_val );
614 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
615 ch_free( rargv[ 1 ] );
616 ch_free( rargv[ 2 ] );
618 rargv[ 0 ] = "rewriteContext";
619 rargv[ 1 ] = "searchResult";
621 rewrite_parse( info, "<suffix massage>", ++line, 2, rargv );
623 rargv[ 0 ] = "rewriteRule";
624 rargv[ 1 ] = suffix_massage_regexize( prnc->bv_val );
625 rargv[ 2 ] = suffix_massage_patternize( pvnc->bv_val );
628 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
629 ch_free( rargv[ 1 ] );
630 ch_free( rargv[ 2 ] );
632 rargv[ 0 ] = "rewriteContext";
633 rargv[ 1 ] = "matchedDN";
634 rargv[ 2 ] = "alias";
635 rargv[ 3 ] = "searchResult";
637 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
639 rargv[ 0 ] = "rewriteContext";
640 rargv[ 1 ] = "searchAttrDN";
641 rargv[ 2 ] = "alias";
642 rargv[ 3 ] = "searchResult";
644 rewrite_parse( info, "<suffix massage>", ++line, 4, rargv );
648 #endif /* ENABLE_REWRITE */
650 #ifdef LDAP_BACK_PROXY_AUTHZ
660 struct ldapinfo *li = (struct ldapinfo *) be->be_private;
662 /* identity assertion mode */
663 if ( strcasecmp( argv[0], "idassert-mode" ) == 0 ) {
666 LDAP_LOG( CONFIG, CRIT,
667 "%s: line %d: illegal args number %d in \"idassert-mode <args>\" line.\n",
668 fname, lineno, argc );
670 Debug( LDAP_DEBUG_ANY,
671 "%s: line %d: illegal args number %d in \"idassert-mode <args>\" line.\n",
672 fname, lineno, argc );
677 if ( strcasecmp( argv[1], "legacy" ) == 0 ) {
678 /* will proxyAuthz as client's identity only if bound */
679 li->idassert_mode = LDAP_BACK_IDASSERT_LEGACY;
681 } else if ( strcasecmp( argv[1], "self" ) == 0 ) {
682 /* will proxyAuthz as client's identity */
683 li->idassert_mode = LDAP_BACK_IDASSERT_SELF;
685 } else if ( strcasecmp( argv[1], "anonymous" ) == 0 ) {
686 /* will proxyAuthz as anonymous */
687 li->idassert_mode = LDAP_BACK_IDASSERT_ANONYMOUS;
689 } else if ( strcasecmp( argv[1], "none" ) == 0 ) {
690 /* will not proxyAuthz */
691 li->idassert_mode = LDAP_BACK_IDASSERT_NOASSERT;
697 /* will proxyAuthz as argv[1] */
698 ber_str2bv( argv[1], 0, 0, &id );
700 if ( strncasecmp( id.bv_val, "u:", STRLENOF( "u:" ) ) == 0 ) {
701 /* force lowercase... */
703 li->idassert_mode = LDAP_BACK_IDASSERT_OTHERID;
704 ber_dupbv( &li->idassert_authzID, &id );
710 if ( strncasecmp( id.bv_val, "dn:", STRLENOF( "dn:" ) ) == 0 ) {
711 id.bv_val += STRLENOF( "dn:" );
712 id.bv_len -= STRLENOF( "dn:" );
715 rc = dnNormalize( 0, NULL, NULL, &id, &dn, NULL );
716 if ( rc != LDAP_SUCCESS ) {
718 LDAP_LOG( CONFIG, CRIT,
719 "%s: line %d: idassert ID \"%s\" is not a valid DN.\n",
720 fname, lineno, argv[1] );
722 Debug( LDAP_DEBUG_ANY,
723 "%s: line %d: idassert ID \"%s\" is not a valid DN\n",
724 fname, lineno, argv[1] );
729 li->idassert_authzID.bv_len = STRLENOF( "dn:" ) + dn.bv_len;
730 li->idassert_authzID.bv_val = ch_malloc( li->idassert_authzID.bv_len + 1 );
731 AC_MEMCPY( li->idassert_authzID.bv_val, "dn:", STRLENOF( "dn:" ) );
732 AC_MEMCPY( &li->idassert_authzID.bv_val[ STRLENOF( "dn:" ) ], dn.bv_val, dn.bv_len + 1 );
733 ch_free( dn.bv_val );
735 li->idassert_mode = LDAP_BACK_IDASSERT_OTHERDN;
739 /* name to use for proxyAuthz propagation */
740 } else if ( strcasecmp( argv[0], "idassert-authcdn" ) == 0
741 || strcasecmp( argv[0], "proxyauthzdn" ) == 0 )
746 /* FIXME: "proxyauthzdn" is no longer documented, and
747 * temporarily supported for backwards compatibility */
751 "%s: line %d: missing name in \"%s <name>\" line\n",
752 fname, lineno, argv[0] );
756 if ( !BER_BVISNULL( &li->idassert_authcDN ) ) {
757 fprintf( stderr, "%s: line %d: "
758 "authcDN already defined; replacing...\n",
760 ch_free( li->idassert_authcDN.bv_val );
763 ber_str2bv( argv[1], 0, 0, &dn );
764 rc = dnNormalize( 0, NULL, NULL, &dn, &li->idassert_authcDN, NULL );
765 if ( rc != LDAP_SUCCESS ) {
767 LDAP_LOG( CONFIG, CRIT,
768 "%s: line %d: idassert ID \"%s\" is not a valid DN.\n",
769 fname, lineno, argv[1] );
771 Debug( LDAP_DEBUG_ANY,
772 "%s: line %d: idassert ID \"%s\" is not a valid DN\n",
773 fname, lineno, argv[1] );
778 /* password to use for proxyAuthz propagation */
779 } else if ( strcasecmp( argv[0], "idassert-passwd" ) == 0
780 || strcasecmp( argv[0], "proxyauthzpw" ) == 0 )
782 /* FIXME: "proxyauthzpw" is no longer documented, and
783 * temporarily supported for backwards compatibility */
787 "%s: line %d: missing password in \"%s <password>\" line\n",
788 fname, lineno, argv[0] );
792 if ( !BER_BVISNULL( &li->idassert_passwd ) ) {
793 fprintf( stderr, "%s: line %d: "
794 "passwd already defined; replacing...\n",
796 ch_free( li->idassert_passwd.bv_val );
799 ber_str2bv( argv[1], 0, 1, &li->idassert_passwd );
801 /* rules to accept identity assertion... */
802 } else if ( strcasecmp( argv[0], "idassert-authzFrom" ) == 0 ) {
805 ber_str2bv( argv[1], 0, 1, &rule );
807 ber_bvarray_add( &li->idassert_authz, &rule );
809 } else if ( strcasecmp( argv[0], "idassert-method" ) == 0 ) {
812 "%s: line %d: missing method in \"%s <method>\" line\n",
813 fname, lineno, argv[0] );
817 if ( strcasecmp( argv[1], "none" ) == 0 ) {
818 /* FIXME: is this useful? */
819 li->idassert_authmethod = LDAP_AUTH_NONE;
823 "%s: line %d: trailing args in \"%s %s ...\" line ignored\"\n",
824 fname, lineno, argv[0], argv[1] );
827 } else if ( strcasecmp( argv[1], "simple" ) == 0 ) {
828 li->idassert_authmethod = LDAP_AUTH_SIMPLE;
832 "%s: line %d: trailing args in \"%s %s ...\" line ignored\"\n",
833 fname, lineno, argv[0], argv[1] );
836 } else if ( strcasecmp( argv[1], "sasl" ) == 0 ) {
837 #ifdef HAVE_CYRUS_SASL
840 for ( arg = 2; arg < argc; arg++ ) {
841 if ( strncasecmp( argv[arg], "mech=", STRLENOF( "mech=" ) ) == 0 ) {
842 char *val = argv[arg] + STRLENOF( "mech=" );
844 if ( !BER_BVISNULL( &li->idassert_sasl_mech ) ) {
845 fprintf( stderr, "%s: line %d: "
846 "SASL mech already defined; replacing...\n",
848 ch_free( li->idassert_sasl_mech.bv_val );
850 ber_str2bv( val, 0, 1, &li->idassert_sasl_mech );
852 } else if ( strncasecmp( argv[arg], "realm=", STRLENOF( "realm=" ) ) == 0 ) {
853 char *val = argv[arg] + STRLENOF( "realm=" );
855 if ( !BER_BVISNULL( &li->idassert_sasl_realm ) ) {
856 fprintf( stderr, "%s: line %d: "
857 "SASL realm already defined; replacing...\n",
859 ch_free( li->idassert_sasl_realm.bv_val );
861 ber_str2bv( val, 0, 1, &li->idassert_sasl_realm );
863 } else if ( strncasecmp( argv[arg], "authcdn=", STRLENOF( "authcdn=" ) ) == 0 ) {
864 char *val = argv[arg] + STRLENOF( "authcdn=" );
868 if ( !BER_BVISNULL( &li->idassert_authcDN ) ) {
869 fprintf( stderr, "%s: line %d: "
870 "SASL authcDN already defined; replacing...\n",
872 ch_free( li->idassert_authcDN.bv_val );
874 if ( strncasecmp( argv[arg], "dn:", STRLENOF( "dn:" ) ) == 0 ) {
875 val += STRLENOF( "dn:" );
878 ber_str2bv( val, 0, 0, &dn );
879 rc = dnNormalize( 0, NULL, NULL, &dn, &li->idassert_authcDN, NULL );
880 if ( rc != LDAP_SUCCESS ) {
882 LDAP_LOG( CONFIG, CRIT,
883 "%s: line %d: SASL authcdn \"%s\" is not a valid DN.\n",
884 fname, lineno, val );
886 Debug( LDAP_DEBUG_ANY,
887 "%s: line %d: SASL authcdn \"%s\" is not a valid DN\n",
888 fname, lineno, val );
893 } else if ( strncasecmp( argv[arg], "authcid=", STRLENOF( "authcid=" ) ) == 0 ) {
894 char *val = argv[arg] + STRLENOF( "authcid=" );
896 if ( !BER_BVISNULL( &li->idassert_authcID ) ) {
897 fprintf( stderr, "%s: line %d: "
898 "SASL authcID already defined; replacing...\n",
900 ch_free( li->idassert_authcID.bv_val );
902 if ( strncasecmp( argv[arg], "u:", STRLENOF( "u:" ) ) == 0 ) {
903 val += STRLENOF( "u:" );
905 ber_str2bv( val, 0, 1, &li->idassert_authcID );
907 } else if ( strncasecmp( argv[arg], "cred=", STRLENOF( "cred=" ) ) == 0 ) {
908 char *val = argv[arg] + STRLENOF( "cred=" );
910 if ( !BER_BVISNULL( &li->idassert_passwd ) ) {
911 fprintf( stderr, "%s: line %d: "
912 "SASL cred already defined; replacing...\n",
914 ch_free( li->idassert_passwd.bv_val );
916 ber_str2bv( val, 0, 1, &li->idassert_passwd );
918 } else if ( strncasecmp( argv[arg], "authz=", STRLENOF( "authz=" ) ) == 0 ) {
919 char *val = argv[arg] + STRLENOF( "authz=" );
921 if ( strcasecmp( val, "proxyauthz" ) == 0 ) {
922 li->idassert_flags &= ~LDAP_BACK_AUTH_NATIVE_AUTHZ;
924 } else if ( strcasecmp( val, "native" ) == 0 ) {
925 li->idassert_flags |= LDAP_BACK_AUTH_NATIVE_AUTHZ;
928 fprintf( stderr, "%s: line %s: "
929 "unknown authz mode \"%s\"\n",
930 fname, lineno, val );
935 fprintf( stderr, "%s: line %d: "
936 "unknown SASL parameter %s\n",
937 fname, lineno, argv[arg] );
942 li->idassert_authmethod = LDAP_AUTH_SASL;
944 #else /* !HAVE_CYRUS_SASL */
945 fprintf( stderr, "%s: line %d: "
946 "compile --with-cyrus-sasl to enable SASL auth\n",
949 #endif /* !HAVE_CYRUS_SASL */
952 fprintf( stderr, "%s: line %d: "
953 "unhandled idassert-method method %s\n",
954 fname, lineno, argv[1] );
959 return SLAP_CONF_UNKNOWN;
964 #endif /* LDAP_BACK_PROXY_AUTHZ */