/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2005 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#endif
-#include "ldap_pvt.h"
-#include "lber_pvt.h"
#include <lutil.h>
static struct berval ext_bv = BER_BVC( "EXTERNAL" );
if ( op.o_bd && op.o_bd->be_search ) {
SlapReply rs = {REP_RESULT};
+ op.o_hdr = conn->c_sasl_bindop->o_hdr;
op.o_tag = LDAP_REQ_SEARCH;
- op.o_protocol = LDAP_VERSION3;
op.o_ndn = conn->c_ndn;
op.o_callback = &cb;
op.o_time = slap_get_time();
op.o_do_not_cache = 1;
op.o_is_auth_check = 1;
- op.o_threadctx = conn->c_sasl_bindop->o_threadctx;
- op.o_tmpmemctx = conn->c_sasl_bindop->o_tmpmemctx;
- op.o_tmpmfuncs = conn->c_sasl_bindop->o_tmpmfuncs;
- op.o_conn = conn;
- op.o_connid = conn->c_connid;
op.o_req_dn = op.o_req_ndn;
op.ors_scope = LDAP_SCOPE_BASE;
op.ors_deref = LDAP_DEREF_NEVER;
}
*modtail = NULL;
- rc = slap_mods_check( modlist, 0, &text, textbuf, textlen, NULL );
+ rc = slap_mods_check( modlist, &text, textbuf, textlen, NULL );
if ( rc == LDAP_SUCCESS ) {
- rc = slap_mods_opattrs( &op, modlist, modtail, &text, textbuf,
- textlen, 1 );
- }
-
- if ( rc == LDAP_SUCCESS ) {
- op.o_tag = LDAP_REQ_MODIFY;
- op.o_protocol = LDAP_VERSION3;
- op.o_ndn = op.o_req_ndn;
- op.o_callback = &cb;
- op.o_time = slap_get_time();
- op.o_do_not_cache = 1;
- op.o_is_auth_check = 1;
- op.o_threadctx = conn->c_sasl_bindop->o_threadctx;
- op.o_tmpmemctx = conn->c_sasl_bindop->o_tmpmemctx;
- op.o_tmpmfuncs = conn->c_sasl_bindop->o_tmpmfuncs;
- op.o_conn = conn;
- op.o_connid = conn->c_connid;
- op.o_req_dn = op.o_req_ndn;
- op.orm_modlist = modlist;
-
- rc = op.o_bd->be_modify( &op, &rs );
+ rc = slap_mods_no_update_check( modlist, &text,
+ textbuf, textlen );
+
+ if ( rc == LDAP_SUCCESS ) {
+ rc = slap_mods_opattrs( &op, modlist, modtail,
+ &text, textbuf, textlen, 1 );
+
+ if ( rc == LDAP_SUCCESS ) {
+ op.o_hdr = conn->c_sasl_bindop->o_hdr;
+ op.o_tag = LDAP_REQ_MODIFY;
+ op.o_ndn = op.o_req_ndn;
+ op.o_callback = &cb;
+ op.o_time = slap_get_time();
+ op.o_do_not_cache = 1;
+ op.o_is_auth_check = 1;
+ op.o_req_dn = op.o_req_ndn;
+ op.orm_modlist = modlist;
+
+ rc = op.o_bd->be_modify( &op, &rs );
+ }
+ }
}
slap_mods_free( modlist );
- return rc ? SASL_FAIL : SASL_OK;
+ return rc != LDAP_SUCCESS ? SASL_FAIL : SASL_OK;
}
#endif /* SASL_VERSION_FULL >= 2.1.16 */
char version[sizeof("xxx.xxx.xxxxx")];
sprintf( version, "%u.%d.%d", (unsigned)rc >> 24, (rc >> 16) & 0xff,
rc & 0xffff );
- Debug( LDAP_DEBUG_ANY,
- "slap_sasl_init: SASL library version mismatch:"
- " expected " SASL_VERSION_STRING ","
- " got %s\n", version, 0, 0 );
+ Debug( LDAP_DEBUG_ANY, "slap_sasl_init: SASL library version mismatch:"
+ " expected " SASL_VERSION_STRING ","
+ " got %s\n", version, 0, 0 );
return -1;
}
#endif
#if SASL_VERSION_MAJOR >= 2
generic_filter.f_desc = slap_schema.si_ad_objectClass;
- sasl_auxprop_add_plugin( "slapd", slap_auxprop_init );
+ rc = sasl_auxprop_add_plugin( "slapd", slap_auxprop_init );
+ if( rc != SASL_OK ) {
+ Debug( LDAP_DEBUG_ANY, "slap_sasl_init: auxprop add plugin failed\n",
+ 0, 0, 0 );
+ return -1;
+ }
#endif
/* should provide callbacks for logging */
/* server name should be configurable */
rc = sasl_server_init( server_callbacks, "slapd" );
if( rc != SASL_OK ) {
- Debug( LDAP_DEBUG_ANY, "sasl_server_init failed\n",
+ Debug( LDAP_DEBUG_ANY, "slap_sasl_init: server init failed\n",
0, 0, 0 );
#if SASL_VERSION_MAJOR < 2
/* A no-op used to make sure we linked with Cyrus 1.5 */
/* Username strings */
if( is_dn == SET_U ) {
- char *p;
- struct berval realm = BER_BVNULL, c1 = *dn;
- ber_len_t len;
-
- len = dn->bv_len + STRLENOF( "uid=" ) + STRLENOF( ",cn=auth" );
-
- if( user_realm && *user_realm ) {
- ber_str2bv( user_realm, 0, 0, &realm );
- len += realm.bv_len + STRLENOF( ",cn=" );
+ /* ITS#3419: values may need escape */
+ LDAPRDN DN[ 5 ];
+ LDAPAVA *RDNs[ 4 ][ 2 ];
+ LDAPAVA AVAs[ 4 ];
+ int irdn;
+
+ irdn = 0;
+ DN[ irdn ] = RDNs[ irdn ];
+ RDNs[ irdn ][ 0 ] = &AVAs[ irdn ];
+ AVAs[ irdn ].la_attr = slap_schema.si_ad_uid->ad_cname;
+ AVAs[ irdn ].la_value = *dn;
+ AVAs[ irdn ].la_flags = LDAP_AVA_NULL;
+ AVAs[ irdn ].la_private = NULL;
+ RDNs[ irdn ][ 1 ] = NULL;
+
+ if ( user_realm && *user_realm ) {
+ irdn++;
+ DN[ irdn ] = RDNs[ irdn ];
+ RDNs[ irdn ][ 0 ] = &AVAs[ irdn ];
+ AVAs[ irdn ].la_attr = slap_schema.si_ad_cn->ad_cname;
+ ber_str2bv( user_realm, 0, 0, &AVAs[ irdn ].la_value );
+ AVAs[ irdn ].la_flags = LDAP_AVA_NULL;
+ AVAs[ irdn ].la_private = NULL;
+ RDNs[ irdn ][ 1 ] = NULL;
}
- if( mech->bv_len ) {
- len += mech->bv_len + STRLENOF( ",cn=" );
+ if ( !BER_BVISNULL( mech ) ) {
+ irdn++;
+ DN[ irdn ] = RDNs[ irdn ];
+ RDNs[ irdn ][ 0 ] = &AVAs[ irdn ];
+ AVAs[ irdn ].la_attr = slap_schema.si_ad_cn->ad_cname;
+ AVAs[ irdn ].la_value = *mech;
+ AVAs[ irdn ].la_flags = LDAP_AVA_NULL;
+ AVAs[ irdn ].la_private = NULL;
+ RDNs[ irdn ][ 1 ] = NULL;
}
- /* Build the new dn */
- dn->bv_val = slap_sl_malloc( len + 1, op->o_tmpmemctx );
- if( dn->bv_val == NULL ) {
- Debug( LDAP_DEBUG_ANY,
- "slap_sasl_getdn: SLAP_MALLOC failed", 0, 0, 0 );
- return LDAP_OTHER;
- }
- p = lutil_strcopy( dn->bv_val, "uid=" );
- p = lutil_strncopy( p, c1.bv_val, c1.bv_len );
+ irdn++;
+ DN[ irdn ] = RDNs[ irdn ];
+ RDNs[ irdn ][ 0 ] = &AVAs[ irdn ];
+ AVAs[ irdn ].la_attr = slap_schema.si_ad_cn->ad_cname;
+ BER_BVSTR( &AVAs[ irdn ].la_value, "auth" );
+ AVAs[ irdn ].la_flags = LDAP_AVA_NULL;
+ AVAs[ irdn ].la_private = NULL;
+ RDNs[ irdn ][ 1 ] = NULL;
- if( realm.bv_len ) {
- p = lutil_strcopy( p, ",cn=" );
- p = lutil_strncopy( p, realm.bv_val, realm.bv_len );
- }
+ irdn++;
+ DN[ irdn ] = NULL;
- if( mech->bv_len ) {
- p = lutil_strcopy( p, ",cn=" );
- p = lutil_strcopy( p, mech->bv_val );
+ rc = ldap_dn2bv_x( DN, dn, LDAP_DN_FORMAT_LDAPV3, op->o_tmpmemctx );
+ if ( rc != LDAP_SUCCESS ) {
+ BER_BVZERO( dn );
+ return rc;
}
- p = lutil_strcopy( p, ",cn=auth" );
- dn->bv_len = p - dn->bv_val;
Debug( LDAP_DEBUG_TRACE, "slap_sasl_getdn: u:id converted to %s\n", dn->bv_val,0,0 );
+
} else {
/* Dup the DN in any case, so we don't risk