delete.c revision 1.1.1.3
1/* $NetBSD: delete.c,v 1.1.1.3 2010/12/12 15:23:05 adam Exp $ */ 2 3/* delete.c - ldap backend delete function */ 4/* OpenLDAP: pkg/ldap/servers/slapd/back-ldap/delete.c,v 1.46.2.7 2010/04/13 20:23:28 kurt Exp */ 5/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 * 7 * Copyright 2003-2010 The OpenLDAP Foundation. 8 * Portions Copyright 1999-2003 Howard Chu. 9 * Portions Copyright 2000-2003 Pierangelo Masarati. 10 * All rights reserved. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted only as authorized by the OpenLDAP 14 * Public License. 15 * 16 * A copy of this license is available in the file LICENSE in the 17 * top-level directory of the distribution or, alternatively, at 18 * <http://www.OpenLDAP.org/license.html>. 19 */ 20/* ACKNOWLEDGEMENTS: 21 * This work was initially developed by the Howard Chu for inclusion 22 * in OpenLDAP Software and subsequently enhanced by Pierangelo 23 * Masarati. 24 */ 25 26#include "portable.h" 27 28#include <stdio.h> 29 30#include <ac/string.h> 31#include <ac/socket.h> 32 33#include "slap.h" 34#include "back-ldap.h" 35 36int 37ldap_back_delete( 38 Operation *op, 39 SlapReply *rs ) 40{ 41 ldapinfo_t *li = (ldapinfo_t *)op->o_bd->be_private; 42 43 ldapconn_t *lc = NULL; 44 ber_int_t msgid; 45 LDAPControl **ctrls = NULL; 46 ldap_back_send_t retrying = LDAP_BACK_RETRYING; 47 int rc = LDAP_SUCCESS; 48 49 if ( !ldap_back_dobind( &lc, op, rs, LDAP_BACK_SENDERR ) ) { 50 return rs->sr_err; 51 } 52 53retry: 54 ctrls = op->o_ctrls; 55 rc = ldap_back_controls_add( op, rs, lc, &ctrls ); 56 if ( rc != LDAP_SUCCESS ) { 57 send_ldap_result( op, rs ); 58 rc = rs->sr_err; 59 goto cleanup; 60 } 61 62 rs->sr_err = ldap_delete_ext( lc->lc_ld, op->o_req_dn.bv_val, 63 ctrls, NULL, &msgid ); 64 rc = ldap_back_op_result( lc, op, rs, msgid, 65 li->li_timeout[ SLAP_OP_DELETE ], 66 ( LDAP_BACK_SENDRESULT | retrying ) ); 67 if ( rs->sr_err == LDAP_UNAVAILABLE && retrying ) { 68 retrying &= ~LDAP_BACK_RETRYING; 69 if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) { 70 /* if the identity changed, there might be need to re-authz */ 71 (void)ldap_back_controls_free( op, rs, &ctrls ); 72 goto retry; 73 } 74 } 75 76cleanup: 77 (void)ldap_back_controls_free( op, rs, &ctrls ); 78 79 if ( lc != NULL ) { 80 ldap_back_release_conn( li, lc ); 81 } 82 83 return rc; 84} 85