2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * Copyright (c) 1995 Regents of the University of Michigan.
9 * Redistribution and use in source and binary forms are permitted
10 * provided that this notice is preserved and that due credit is given
11 * to the University of Michigan at Ann Arbor. The name of the University
12 * may not be used to endorse or promote products derived from this
13 * software without specific prior written permission. This software
14 * is provided ``as is'' without express or implied warranty.
21 #include <ac/string.h>
22 #include <ac/socket.h>
36 Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );
38 if( op->o_bind_in_progress ) {
39 Debug( LDAP_DEBUG_ANY, "do_delete: SASL bind in progress.\n",
41 send_ldap_result( conn, op, LDAP_SASL_BIND_IN_PROGRESS,
42 NULL, "SASL bind in progress", NULL, NULL );
43 return LDAP_SASL_BIND_IN_PROGRESS;
47 * Parse the delete request. It looks like this:
49 * DelRequest := DistinguishedName
52 if ( ber_scanf( op->o_ber, "a", &ndn ) == LBER_ERROR ) {
53 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
54 send_ldap_disconnect( conn, op,
55 LDAP_PROTOCOL_ERROR, "decoding error" );
59 if( dn_normalize_case( ndn ) == NULL ) {
60 Debug( LDAP_DEBUG_ANY, "do_delete: invalid dn (%s)\n", ndn, 0, 0 );
61 send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
62 "invalid DN", NULL, NULL );
67 if( ( rc = get_ctrls( conn, op, 1 ) ) != LDAP_SUCCESS ) {
69 Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
73 Debug( LDAP_DEBUG_ARGS, "do_delete: dn (%s)\n", ndn, 0, 0 );
74 Debug( LDAP_DEBUG_STATS, "DEL dn=\"%s\"\n", ndn, 0, 0 );
77 * We could be serving multiple database backends. Select the
78 * appropriate one, or send a referral to our "referral server"
79 * if we don't hold it.
81 if ( (be = select_backend( ndn )) == NULL ) {
82 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
83 NULL, NULL, default_referral, NULL );
88 if ( global_readonly || be->be_readonly ) {
89 Debug( LDAP_DEBUG_ANY, "do_delete: database is read-only\n",
92 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
93 NULL, "database is read-only", NULL, NULL );
94 return LDAP_UNWILLING_TO_PERFORM;
97 /* deref suffix alias if appropriate */
98 ndn = suffix_alias( be, ndn );
101 * do the delete if 1 && (2 || 3)
102 * 1) there is a delete function implemented in this backend;
103 * 2) this backend is master for what it holds;
104 * 3) it's a replica and the dn supplied is the update_ndn.
106 if ( be->be_delete ) {
107 /* do the update here */
108 #ifndef SLAPD_MULTIMASTER
109 if ( be->be_update_ndn == NULL ||
110 strcmp( be->be_update_ndn, op->o_ndn ) == 0 )
113 if ( (*be->be_delete)( be, conn, op, ndn ) == 0 ) {
114 #ifdef SLAPD_MULTIMASTER
115 if (be->be_update_ndn == NULL ||
116 strcmp( be->be_update_ndn, op->o_ndn ))
119 replog( be, op, ndn, NULL );
122 #ifndef SLAPD_MULTIMASTER
124 send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
125 be->be_update_refs ? be->be_update_refs : default_referral, NULL );
130 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
131 NULL, "Function not implemented", NULL, NULL );