2003-02-16 17:22:44 +08:00
|
|
|
/* extended.c - ldap backend extended routines */
|
|
|
|
/* $OpenLDAP$ */
|
2003-11-27 14:35:14 +08:00
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2012-01-01 23:07:45 +08:00
|
|
|
* Copyright 2003-2012 The OpenLDAP Foundation.
|
2003-11-27 14:35:14 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
2003-02-16 17:22:44 +08:00
|
|
|
*/
|
2003-11-27 14:35:14 +08:00
|
|
|
/* ACKNOWLEDGEMENTS:
|
|
|
|
* This work was initially developed by the Howard Chu for inclusion
|
|
|
|
* in OpenLDAP Software and subsequently enhanced by Pierangelo
|
|
|
|
* Masarati.
|
|
|
|
*/
|
2003-02-16 17:22:44 +08:00
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "back-ldap.h"
|
|
|
|
#include "lber_pvt.h"
|
|
|
|
|
2007-05-19 22:08:49 +08:00
|
|
|
typedef int (ldap_back_exop_f)( Operation *op, SlapReply *rs, ldapconn_t **lc );
|
|
|
|
|
|
|
|
static ldap_back_exop_f ldap_back_exop_passwd;
|
|
|
|
static ldap_back_exop_f ldap_back_exop_generic;
|
2003-02-16 17:22:44 +08:00
|
|
|
|
|
|
|
static struct exop {
|
2007-05-19 22:08:49 +08:00
|
|
|
struct berval oid;
|
|
|
|
ldap_back_exop_f *extended;
|
2003-02-16 17:22:44 +08:00
|
|
|
} exop_table[] = {
|
2006-01-02 16:19:35 +08:00
|
|
|
{ BER_BVC(LDAP_EXOP_MODIFY_PASSWD), ldap_back_exop_passwd },
|
2005-08-26 10:17:13 +08:00
|
|
|
{ BER_BVNULL, NULL }
|
2003-02-16 17:22:44 +08:00
|
|
|
};
|
|
|
|
|
2006-01-02 16:19:35 +08:00
|
|
|
static int
|
2007-05-19 22:08:49 +08:00
|
|
|
ldap_back_extended_one( Operation *op, SlapReply *rs, ldap_back_exop_f exop )
|
2006-01-02 16:19:35 +08:00
|
|
|
{
|
2006-06-16 07:12:38 +08:00
|
|
|
ldapinfo_t *li = (ldapinfo_t *) op->o_bd->be_private;
|
|
|
|
|
2006-10-08 02:07:56 +08:00
|
|
|
ldapconn_t *lc = NULL;
|
2007-08-22 23:49:35 +08:00
|
|
|
LDAPControl **ctrls = NULL, **oldctrls = NULL;
|
2006-01-02 16:19:35 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* FIXME: this needs to be called here, so it is
|
|
|
|
* called twice; maybe we could avoid the
|
|
|
|
* ldap_back_dobind() call inside each extended()
|
|
|
|
* call ... */
|
2006-10-08 02:07:56 +08:00
|
|
|
if ( !ldap_back_dobind( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
|
2006-01-02 16:19:35 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-08-22 23:49:35 +08:00
|
|
|
ctrls = op->o_ctrls;
|
|
|
|
if ( ldap_back_controls_add( op, rs, lc, &ctrls ) )
|
2006-06-16 07:12:38 +08:00
|
|
|
{
|
2006-01-02 16:19:35 +08:00
|
|
|
op->o_ctrls = oldctrls;
|
|
|
|
send_ldap_extended( op, rs );
|
|
|
|
rs->sr_text = NULL;
|
|
|
|
/* otherwise frontend resends result */
|
|
|
|
rc = rs->sr_err = SLAPD_ABANDON;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2007-08-22 23:49:35 +08:00
|
|
|
op->o_ctrls = ctrls;
|
2007-05-19 22:08:49 +08:00
|
|
|
rc = exop( op, rs, &lc );
|
2006-01-02 16:19:35 +08:00
|
|
|
|
|
|
|
op->o_ctrls = oldctrls;
|
2007-08-22 23:49:35 +08:00
|
|
|
(void)ldap_back_controls_free( op, rs, &ctrls );
|
2006-01-02 16:19:35 +08:00
|
|
|
|
|
|
|
done:;
|
|
|
|
if ( lc != NULL ) {
|
2007-01-10 08:53:05 +08:00
|
|
|
ldap_back_release_conn( li, lc );
|
2006-01-02 16:19:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2003-02-16 17:22:44 +08:00
|
|
|
int
|
|
|
|
ldap_back_extended(
|
2004-11-13 22:43:30 +08:00
|
|
|
Operation *op,
|
|
|
|
SlapReply *rs )
|
2003-02-16 17:22:44 +08:00
|
|
|
{
|
2004-11-13 22:43:30 +08:00
|
|
|
int i;
|
2003-02-16 17:22:44 +08:00
|
|
|
|
2011-01-01 04:53:17 +08:00
|
|
|
RS_ASSERT( !(rs->sr_flags & REP_ENTRY_MASK) );
|
|
|
|
rs->sr_flags &= ~REP_ENTRY_MASK; /* paranoia */
|
|
|
|
|
2004-11-13 22:43:30 +08:00
|
|
|
for ( i = 0; exop_table[i].extended != NULL; i++ ) {
|
2005-08-26 10:17:13 +08:00
|
|
|
if ( bvmatch( &exop_table[i].oid, &op->oq_extended.rs_reqoid ) )
|
2004-11-13 22:43:30 +08:00
|
|
|
{
|
2006-01-02 16:19:35 +08:00
|
|
|
return ldap_back_extended_one( op, rs, exop_table[i].extended );
|
2003-02-16 17:22:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-02 16:19:35 +08:00
|
|
|
/* if we get here, the exop is known; the best that we can do
|
|
|
|
* is pass it thru as is */
|
|
|
|
/* FIXME: maybe a list of OIDs to pass thru would be safer */
|
|
|
|
return ldap_back_extended_one( op, rs, ldap_back_exop_generic );
|
2003-02-16 17:22:44 +08:00
|
|
|
}
|
|
|
|
|
2006-01-02 16:19:35 +08:00
|
|
|
static int
|
2003-02-16 17:22:44 +08:00
|
|
|
ldap_back_exop_passwd(
|
2007-05-19 22:08:49 +08:00
|
|
|
Operation *op,
|
|
|
|
SlapReply *rs,
|
|
|
|
ldapconn_t **lcp )
|
2003-02-16 17:22:44 +08:00
|
|
|
{
|
2006-05-28 03:54:27 +08:00
|
|
|
ldapinfo_t *li = (ldapinfo_t *) op->o_bd->be_private;
|
|
|
|
|
2007-05-19 22:08:49 +08:00
|
|
|
ldapconn_t *lc = *lcp;
|
2004-11-13 22:43:30 +08:00
|
|
|
req_pwdexop_s *qpw = &op->oq_pwdexop;
|
|
|
|
LDAPMessage *res;
|
|
|
|
ber_int_t msgid;
|
2007-05-19 22:08:49 +08:00
|
|
|
int rc, isproxy, freedn = 0;
|
2004-11-13 22:43:30 +08:00
|
|
|
int do_retry = 1;
|
2007-05-19 22:08:49 +08:00
|
|
|
char *text = NULL;
|
|
|
|
struct berval dn = op->o_req_dn,
|
|
|
|
ndn = op->o_req_ndn;
|
2004-11-13 22:43:30 +08:00
|
|
|
|
2007-05-19 22:08:49 +08:00
|
|
|
assert( lc != NULL );
|
2007-08-22 20:07:27 +08:00
|
|
|
assert( rs->sr_ctrls == NULL );
|
2007-05-19 22:08:49 +08:00
|
|
|
|
|
|
|
if ( BER_BVISNULL( &ndn ) && op->ore_reqdata != NULL ) {
|
2007-09-23 12:40:51 +08:00
|
|
|
/* NOTE: most of this code is mutated
|
|
|
|
* from slap_passwd_parse();
|
|
|
|
* But here we only need
|
2007-05-19 22:08:49 +08:00
|
|
|
* the first berval... */
|
|
|
|
|
|
|
|
ber_tag_t tag;
|
|
|
|
ber_len_t len = -1;
|
|
|
|
BerElementBuffer berbuf;
|
|
|
|
BerElement *ber = (BerElement *)&berbuf;
|
|
|
|
|
|
|
|
struct berval tmpid = BER_BVNULL;
|
|
|
|
|
|
|
|
if ( op->ore_reqdata->bv_len == 0 ) {
|
|
|
|
return LDAP_PROTOCOL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ber_init2 uses reqdata directly, doesn't allocate new buffers */
|
|
|
|
ber_init2( ber, op->ore_reqdata, 0 );
|
|
|
|
|
|
|
|
tag = ber_scanf( ber, "{" /*}*/ );
|
|
|
|
|
|
|
|
if ( tag == LBER_ERROR ) {
|
|
|
|
return LDAP_PROTOCOL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
tag = ber_peek_tag( ber, &len );
|
|
|
|
if ( tag == LDAP_TAG_EXOP_MODIFY_PASSWD_ID ) {
|
2007-09-23 12:40:51 +08:00
|
|
|
tag = ber_get_stringbv( ber, &tmpid, LBER_BV_NOTERM );
|
2007-05-19 22:08:49 +08:00
|
|
|
|
|
|
|
if ( tag == LBER_ERROR ) {
|
|
|
|
return LDAP_PROTOCOL_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !BER_BVISEMPTY( &tmpid ) ) {
|
2007-09-23 12:40:51 +08:00
|
|
|
char idNull = tmpid.bv_val[tmpid.bv_len];
|
|
|
|
tmpid.bv_val[tmpid.bv_len] = '\0';
|
2007-05-19 22:08:49 +08:00
|
|
|
rs->sr_err = dnPrettyNormal( NULL, &tmpid, &dn,
|
|
|
|
&ndn, op->o_tmpmemctx );
|
2007-09-23 12:40:51 +08:00
|
|
|
tmpid.bv_val[tmpid.bv_len] = idNull;
|
2007-05-19 22:08:49 +08:00
|
|
|
if ( rs->sr_err != LDAP_SUCCESS ) {
|
|
|
|
/* should have been successfully parsed earlier! */
|
|
|
|
return rs->sr_err;
|
|
|
|
}
|
|
|
|
freedn = 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
dn = op->o_dn;
|
|
|
|
ndn = op->o_ndn;
|
|
|
|
}
|
2003-02-16 17:22:44 +08:00
|
|
|
}
|
|
|
|
|
2007-05-19 22:08:49 +08:00
|
|
|
isproxy = ber_bvcmp( &ndn, &op->o_ndn );
|
2003-02-16 17:22:44 +08:00
|
|
|
|
2004-11-13 22:43:30 +08:00
|
|
|
Debug( LDAP_DEBUG_ARGS, "==> ldap_back_exop_passwd(\"%s\")%s\n",
|
2007-05-19 22:08:49 +08:00
|
|
|
dn.bv_val, isproxy ? " (proxy)" : "", 0 );
|
2003-02-16 17:22:44 +08:00
|
|
|
|
2004-10-01 19:16:38 +08:00
|
|
|
retry:
|
2007-05-19 22:08:49 +08:00
|
|
|
rc = ldap_passwd( lc->lc_ld, isproxy ? &dn : NULL,
|
2004-04-06 07:47:17 +08:00
|
|
|
qpw->rs_old.bv_val ? &qpw->rs_old : NULL,
|
|
|
|
qpw->rs_new.bv_val ? &qpw->rs_new : NULL,
|
2004-11-13 22:43:30 +08:00
|
|
|
op->o_ctrls, NULL, &msgid );
|
2003-03-12 02:09:38 +08:00
|
|
|
|
2004-11-13 22:43:30 +08:00
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
2007-08-22 20:07:27 +08:00
|
|
|
/* TODO: set timeout? */
|
2009-09-08 15:56:43 +08:00
|
|
|
/* by now, make sure no timeout is used (ITS#6282) */
|
2010-11-23 18:10:45 +08:00
|
|
|
struct timeval tv = { -1, 0 };
|
2009-09-08 15:56:43 +08:00
|
|
|
if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, &tv, &res ) == -1 ) {
|
2004-11-13 22:43:30 +08:00
|
|
|
ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER, &rc );
|
2006-04-08 22:45:19 +08:00
|
|
|
rs->sr_err = rc;
|
2004-07-05 07:35:18 +08:00
|
|
|
|
2003-02-16 17:22:44 +08:00
|
|
|
} else {
|
2006-09-03 19:02:15 +08:00
|
|
|
/* only touch when activity actually took place... */
|
|
|
|
if ( li->li_idle_timeout && lc ) {
|
|
|
|
lc->lc_time = op->o_time;
|
|
|
|
}
|
|
|
|
|
2004-11-13 22:43:30 +08:00
|
|
|
/* sigh. parse twice, because parse_passwd
|
|
|
|
* doesn't give us the err / match / msg info.
|
2003-02-16 17:22:44 +08:00
|
|
|
*/
|
2004-11-13 22:43:30 +08:00
|
|
|
rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err,
|
|
|
|
(char **)&rs->sr_matched,
|
2006-05-17 05:45:31 +08:00
|
|
|
&text,
|
2007-08-22 20:07:27 +08:00
|
|
|
NULL, &rs->sr_ctrls, 0 );
|
2006-01-03 00:20:39 +08:00
|
|
|
|
2004-11-13 22:43:30 +08:00
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
|
|
|
if ( rs->sr_err == LDAP_SUCCESS ) {
|
|
|
|
struct berval newpw;
|
2006-01-03 00:20:39 +08:00
|
|
|
|
|
|
|
/* this never happens because
|
|
|
|
* the frontend is generating
|
|
|
|
* the new password, so when
|
|
|
|
* the passwd exop is proxied,
|
|
|
|
* it never delegates password
|
|
|
|
* generation to the remote server
|
|
|
|
*/
|
2004-11-13 22:43:30 +08:00
|
|
|
rc = ldap_parse_passwd( lc->lc_ld, res,
|
2006-01-03 00:20:39 +08:00
|
|
|
&newpw );
|
2004-11-13 22:43:30 +08:00
|
|
|
if ( rc == LDAP_SUCCESS &&
|
|
|
|
!BER_BVISNULL( &newpw ) )
|
|
|
|
{
|
2003-03-30 17:03:54 +08:00
|
|
|
rs->sr_type = REP_EXTENDED;
|
2004-11-13 22:43:30 +08:00
|
|
|
rs->sr_rspdata = slap_passwd_return( &newpw );
|
|
|
|
free( newpw.bv_val );
|
2003-02-16 17:22:44 +08:00
|
|
|
}
|
2004-11-13 22:43:30 +08:00
|
|
|
|
2003-02-16 17:22:44 +08:00
|
|
|
} else {
|
2003-03-30 17:03:54 +08:00
|
|
|
rc = rs->sr_err;
|
2003-02-16 17:22:44 +08:00
|
|
|
}
|
|
|
|
}
|
2004-11-13 22:43:30 +08:00
|
|
|
ldap_msgfree( res );
|
2003-02-16 17:22:44 +08:00
|
|
|
}
|
|
|
|
}
|
2006-04-08 22:45:19 +08:00
|
|
|
|
2004-11-13 22:43:30 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
2004-04-06 01:36:53 +08:00
|
|
|
rs->sr_err = slap_map_api2result( rs );
|
2004-10-01 19:16:38 +08:00
|
|
|
if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) {
|
|
|
|
do_retry = 0;
|
2005-11-19 23:00:50 +08:00
|
|
|
if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
|
2004-11-13 22:43:30 +08:00
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
}
|
2006-05-28 03:54:27 +08:00
|
|
|
|
|
|
|
if ( LDAP_BACK_QUARANTINE( li ) ) {
|
2006-06-08 07:25:38 +08:00
|
|
|
ldap_back_quarantine( op, rs );
|
2006-05-28 03:54:27 +08:00
|
|
|
}
|
|
|
|
|
2006-05-17 05:45:31 +08:00
|
|
|
if ( text ) rs->sr_text = text;
|
2006-01-02 16:19:35 +08:00
|
|
|
send_ldap_extended( op, rs );
|
|
|
|
/* otherwise frontend resends result */
|
|
|
|
rc = rs->sr_err = SLAPD_ABANDON;
|
2006-05-28 03:54:27 +08:00
|
|
|
|
|
|
|
} else if ( LDAP_BACK_QUARANTINE( li ) ) {
|
2006-06-08 07:25:38 +08:00
|
|
|
ldap_back_quarantine( op, rs );
|
2003-02-16 17:22:44 +08:00
|
|
|
}
|
2004-10-01 19:16:38 +08:00
|
|
|
|
2012-02-08 21:18:29 +08:00
|
|
|
ldap_pvt_thread_mutex_lock( &li->li_counter_mutex );
|
|
|
|
ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_EXTENDED ], 1 );
|
|
|
|
ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex );
|
|
|
|
|
2007-05-19 22:08:49 +08:00
|
|
|
if ( freedn ) {
|
|
|
|
op->o_tmpfree( dn.bv_val, op->o_tmpmemctx );
|
|
|
|
op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx );
|
|
|
|
}
|
|
|
|
|
2005-11-03 19:58:06 +08:00
|
|
|
/* these have to be freed anyway... */
|
|
|
|
if ( rs->sr_matched ) {
|
|
|
|
free( (char *)rs->sr_matched );
|
2005-11-04 05:48:46 +08:00
|
|
|
rs->sr_matched = NULL;
|
2005-11-03 19:58:06 +08:00
|
|
|
}
|
2006-04-08 22:45:19 +08:00
|
|
|
|
2007-08-22 20:07:27 +08:00
|
|
|
if ( rs->sr_ctrls ) {
|
|
|
|
ldap_controls_free( rs->sr_ctrls );
|
|
|
|
rs->sr_ctrls = NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-17 05:45:31 +08:00
|
|
|
if ( text ) {
|
|
|
|
free( text );
|
2005-11-04 05:48:46 +08:00
|
|
|
rs->sr_text = NULL;
|
2005-11-03 19:58:06 +08:00
|
|
|
}
|
|
|
|
|
2007-05-19 22:08:49 +08:00
|
|
|
/* in case, cleanup handler */
|
|
|
|
if ( lc == NULL ) {
|
|
|
|
*lcp = NULL;
|
2005-06-30 00:38:09 +08:00
|
|
|
}
|
|
|
|
|
2003-02-16 17:22:44 +08:00
|
|
|
return rc;
|
|
|
|
}
|
2006-01-02 16:19:35 +08:00
|
|
|
|
|
|
|
static int
|
|
|
|
ldap_back_exop_generic(
|
|
|
|
Operation *op,
|
2007-05-19 22:08:49 +08:00
|
|
|
SlapReply *rs,
|
|
|
|
ldapconn_t **lcp )
|
2006-01-02 16:19:35 +08:00
|
|
|
{
|
2006-05-28 03:54:27 +08:00
|
|
|
ldapinfo_t *li = (ldapinfo_t *) op->o_bd->be_private;
|
|
|
|
|
2007-05-19 22:08:49 +08:00
|
|
|
ldapconn_t *lc = *lcp;
|
2006-01-02 16:19:35 +08:00
|
|
|
LDAPMessage *res;
|
|
|
|
ber_int_t msgid;
|
|
|
|
int rc;
|
|
|
|
int do_retry = 1;
|
2007-05-19 22:08:49 +08:00
|
|
|
char *text = NULL;
|
2006-01-02 16:19:35 +08:00
|
|
|
|
|
|
|
Debug( LDAP_DEBUG_ARGS, "==> ldap_back_exop_generic(%s, \"%s\")\n",
|
|
|
|
op->ore_reqoid.bv_val, op->o_req_dn.bv_val, 0 );
|
2010-12-31 07:19:02 +08:00
|
|
|
assert( lc != NULL );
|
|
|
|
assert( rs->sr_ctrls == NULL );
|
2006-01-02 16:19:35 +08:00
|
|
|
|
|
|
|
retry:
|
|
|
|
rc = ldap_extended_operation( lc->lc_ld,
|
|
|
|
op->ore_reqoid.bv_val, op->ore_reqdata,
|
|
|
|
op->o_ctrls, NULL, &msgid );
|
|
|
|
|
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
2007-08-22 20:07:27 +08:00
|
|
|
/* TODO: set timeout? */
|
2009-09-08 15:56:43 +08:00
|
|
|
/* by now, make sure no timeout is used (ITS#6282) */
|
2010-11-23 18:10:45 +08:00
|
|
|
struct timeval tv = { -1, 0 };
|
2009-09-08 15:56:43 +08:00
|
|
|
if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, &tv, &res ) == -1 ) {
|
2006-01-02 16:19:35 +08:00
|
|
|
ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER, &rc );
|
2006-04-08 22:45:19 +08:00
|
|
|
rs->sr_err = rc;
|
2006-01-02 16:19:35 +08:00
|
|
|
|
|
|
|
} else {
|
2006-09-03 19:02:15 +08:00
|
|
|
/* only touch when activity actually took place... */
|
|
|
|
if ( li->li_idle_timeout && lc ) {
|
|
|
|
lc->lc_time = op->o_time;
|
|
|
|
}
|
|
|
|
|
2006-01-02 16:19:35 +08:00
|
|
|
/* sigh. parse twice, because parse_passwd
|
|
|
|
* doesn't give us the err / match / msg info.
|
|
|
|
*/
|
|
|
|
rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err,
|
|
|
|
(char **)&rs->sr_matched,
|
2006-05-20 07:33:15 +08:00
|
|
|
&text,
|
2007-08-22 20:07:27 +08:00
|
|
|
NULL, &rs->sr_ctrls, 0 );
|
2006-01-02 16:19:35 +08:00
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
|
|
|
if ( rs->sr_err == LDAP_SUCCESS ) {
|
|
|
|
rc = ldap_parse_extended_result( lc->lc_ld, res,
|
|
|
|
(char **)&rs->sr_rspoid, &rs->sr_rspdata, 0 );
|
|
|
|
if ( rc == LDAP_SUCCESS ) {
|
|
|
|
rs->sr_type = REP_EXTENDED;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
rc = rs->sr_err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ldap_msgfree( res );
|
|
|
|
}
|
|
|
|
}
|
2006-04-08 22:45:19 +08:00
|
|
|
|
2006-01-02 16:19:35 +08:00
|
|
|
if ( rc != LDAP_SUCCESS ) {
|
|
|
|
rs->sr_err = slap_map_api2result( rs );
|
|
|
|
if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) {
|
|
|
|
do_retry = 0;
|
|
|
|
if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
}
|
2006-05-28 03:54:27 +08:00
|
|
|
|
|
|
|
if ( LDAP_BACK_QUARANTINE( li ) ) {
|
2006-06-08 07:25:38 +08:00
|
|
|
ldap_back_quarantine( op, rs );
|
2006-05-28 03:54:27 +08:00
|
|
|
}
|
|
|
|
|
2006-05-17 05:45:31 +08:00
|
|
|
if ( text ) rs->sr_text = text;
|
2006-01-02 16:19:35 +08:00
|
|
|
send_ldap_extended( op, rs );
|
|
|
|
/* otherwise frontend resends result */
|
|
|
|
rc = rs->sr_err = SLAPD_ABANDON;
|
2006-05-28 03:54:27 +08:00
|
|
|
|
|
|
|
} else if ( LDAP_BACK_QUARANTINE( li ) ) {
|
2006-06-08 07:25:38 +08:00
|
|
|
ldap_back_quarantine( op, rs );
|
2006-01-02 16:19:35 +08:00
|
|
|
}
|
|
|
|
|
2012-02-08 21:18:29 +08:00
|
|
|
ldap_pvt_thread_mutex_lock( &li->li_counter_mutex );
|
|
|
|
ldap_pvt_mp_add( li->li_ops_completed[ SLAP_OP_EXTENDED ], 1 );
|
|
|
|
ldap_pvt_thread_mutex_unlock( &li->li_counter_mutex );
|
|
|
|
|
2006-01-02 16:19:35 +08:00
|
|
|
/* these have to be freed anyway... */
|
|
|
|
if ( rs->sr_matched ) {
|
|
|
|
free( (char *)rs->sr_matched );
|
|
|
|
rs->sr_matched = NULL;
|
|
|
|
}
|
2006-04-08 22:45:19 +08:00
|
|
|
|
2007-08-22 20:07:27 +08:00
|
|
|
if ( rs->sr_ctrls ) {
|
|
|
|
ldap_controls_free( rs->sr_ctrls );
|
|
|
|
rs->sr_ctrls = NULL;
|
|
|
|
}
|
|
|
|
|
2006-05-17 05:45:31 +08:00
|
|
|
if ( text ) {
|
|
|
|
free( text );
|
2006-01-02 16:19:35 +08:00
|
|
|
rs->sr_text = NULL;
|
|
|
|
}
|
|
|
|
|
2007-05-19 22:08:49 +08:00
|
|
|
/* in case, cleanup handler */
|
|
|
|
if ( lc == NULL ) {
|
|
|
|
*lcp = NULL;
|
2006-01-02 16:19:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|