2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1999-2006 The OpenLDAP Foundation.
5 * Portions Copyright 2001-2003 Pierangelo Masarati.
6 * Portions Copyright 1999-2003 Howard Chu.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by the Howard Chu for inclusion
19 * in OpenLDAP Software and subsequently enhanced by Pierangelo
27 #include <ac/string.h>
28 #include <ac/socket.h>
31 #include "../back-ldap/back-ldap.h"
32 #include "back-meta.h"
35 meta_back_delete( Operation *op, SlapReply *rs )
37 metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
39 metaconn_t *mc = NULL;
41 struct berval mdn = BER_BVNULL;
46 LDAPControl **ctrls = NULL;
48 mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR );
49 if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) {
53 assert( mc->mc_conns[ candidate ].msc_ld != NULL );
56 * Rewrite the compare dn, if needed
58 mt = mi->mi_targets[ candidate ];
64 if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
65 send_ldap_result( op, rs );
70 if ( ldap_back_proxy_authz_ctrl( &mc->mc_conns[ candidate ].msc_bound_ndn,
71 mt->mt_version, &mt->mt_idassert, op, rs, &ctrls ) != LDAP_SUCCESS )
78 rs->sr_err = ldap_delete_ext( mc->mc_conns[ candidate ].msc_ld,
79 mdn.bv_val, ctrls, NULL, &msgid );
80 if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) {
82 if ( meta_back_retry( op, rs, &mc, candidate, LDAP_BACK_SENDERR ) ) {
87 } else if ( rs->sr_err == LDAP_SUCCESS ) {
88 struct timeval tv, *tvp = NULL;
89 LDAPMessage *res = NULL;
92 if ( mt->mt_timeout[ LDAP_BACK_OP_DELETE ] != 0 ) {
93 tv.tv_sec = mt->mt_timeout[ LDAP_BACK_OP_DELETE ];
98 rs->sr_err = LDAP_OTHER;
100 rc = ldap_result( mc->mc_conns[ candidate ].msc_ld,
101 msgid, LDAP_MSG_ALL, tvp, &res );
104 rs->sr_err = LDAP_OTHER;
108 (void)meta_back_cancel( mc, op, rs, msgid, candidate, LDAP_BACK_DONTSEND );
109 rs->sr_err = op->o_protocol >= LDAP_VERSION3 ?
110 LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR;
113 case LDAP_RES_DELETE:
114 /* FIXME: matched? referrals? response controls? */
115 rc = ldap_parse_result( mc->mc_conns[ candidate ].msc_ld,
116 res, &rs->sr_err, NULL, NULL, NULL, NULL, 1 );
117 if ( rc != LDAP_SUCCESS ) {
130 (void)ldap_back_proxy_authz_ctrl_free( op, &ctrls );
133 rs->sr_err = meta_back_op_result( mc, op, rs, candidate );
136 send_ldap_result( op, rs );
138 if ( META_BACK_TGT_QUARANTINE( mt ) ) {
139 meta_back_quarantine( op, rs, candidate );
144 if ( mdn.bv_val != op->o_req_dn.bv_val ) {
151 meta_back_release_conn( op, mc );