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>
22 extern Backend *select_backend();
24 extern char *default_referral;
35 Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );
38 * Parse the delete request. It looks like this:
40 * DelRequest := DistinguishedName
43 if ( ber_scanf( op->o_ber, "a", &dn ) == LBER_ERROR ) {
44 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
45 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
51 Debug( LDAP_DEBUG_ARGS, "do_delete: dn (%s)\n", dn, 0, 0 );
53 Debug( LDAP_DEBUG_STATS, "DEL dn=\"%s\"\n", dn, 0, 0 );
56 * We could be serving multiple database backends. Select the
57 * appropriate one, or send a referral to our "referral server"
58 * if we don't hold it.
60 if ( (be = select_backend( dn )) == NULL ) {
63 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
69 * do the delete if 1 && (2 || 3)
70 * 1) there is a delete function implemented in this backend;
71 * 2) this backend is master for what it holds;
72 * 3) it's a replica and the dn supplied is the updatedn.
74 if ( be->be_delete != NULL ) {
75 /* do the update here */
76 if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
78 if ( (*be->be_delete)( be, conn, op, dn ) == 0 ) {
79 replog( be, LDAP_REQ_DELETE, odn, NULL, 0 );
82 send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
86 send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
87 "Function not implemented" );