2 * Copyright (c) 1995 Regents of the University of Michigan.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of Michigan at Ann Arbor. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
17 #include <ac/string.h>
18 #include <ac/socket.h>
31 Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );
34 * Parse the delete request. It looks like this:
36 * DelRequest := DistinguishedName
39 if ( ber_scanf( op->o_ber, "a", &ndn ) == LBER_ERROR ) {
40 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
41 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
45 Debug( LDAP_DEBUG_ARGS, "do_delete: dn (%s)\n", ndn, 0, 0 );
47 dn_normalize_case( ndn );
49 Debug( LDAP_DEBUG_STATS, "DEL dn=\"%s\"\n", ndn, 0, 0 );
52 * We could be serving multiple database backends. Select the
53 * appropriate one, or send a referral to our "referral server"
54 * if we don't hold it.
56 if ( (be = select_backend( ndn )) == NULL ) {
58 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
63 /* alias suffix if approp */
64 ndn = suffixAlias( ndn, op, be );
67 * do the delete if 1 && (2 || 3)
68 * 1) there is a delete function implemented in this backend;
69 * 2) this backend is master for what it holds;
70 * 3) it's a replica and the dn supplied is the update_ndn.
72 if ( be->be_delete ) {
73 /* do the update here */
74 if ( be->be_update_ndn == NULL ||
75 strcmp( be->be_update_ndn, op->o_ndn ) == 0 )
77 if ( (*be->be_delete)( be, conn, op, ndn ) == 0 ) {
78 replog( be, LDAP_REQ_DELETE, ndn, NULL, 0 );
81 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
85 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
86 "Function not implemented" );