1 /* delete.c - ldbm backend delete routine */
8 #include <sys/socket.h>
10 #include "back-ldbm.h"
11 #include "proto-back-ldbm.h"
13 extern Attribute *attr_find();
23 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
27 Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_delete: %s\n", dn, 0, 0);
29 /* get entry with writer lock */
30 if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
31 Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: no such object %s\n",
33 send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
34 if ( matched != NULL ) {
40 Debug (LDAP_DEBUG_TRACE,
41 "rdwr_Xchk: readers_reading: %d writer_writing: %d\n",
42 e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0);
44 /* check for deleted */
46 if ( has_children( be, e ) ) {
47 Debug(LDAP_DEBUG_ARGS, "<=- ldbm_back_delete: non leaf %s\n",
49 send_ldap_result( conn, op, LDAP_NOT_ALLOWED_ON_NONLEAF, "",
54 if ( ! access_allowed( be, conn, op, e, "entry", NULL, op->o_dn,
56 Debug(LDAP_DEBUG_ARGS,
57 "<=- ldbm_back_delete: insufficient access %s\n",
59 send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS, "", "" );
63 Debug (LDAP_DEBUG_TRACE,
64 "rdwr_Xchk: readers_reading: %d writer_writing: %d\n",
65 e->e_rdwr.readers_reading, e->e_rdwr.writer_writing, 0);
67 /* XXX delete from parent's id2children entry XXX */
69 /* delete from dn2id mapping */
70 if ( dn2id_delete( be, e->e_dn ) != 0 ) {
71 Debug(LDAP_DEBUG_ARGS,
72 "<=- ldbm_back_delete: operations error %s\n",
74 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
78 /* delete from disk and cache */
79 if ( id2entry_delete( be, e ) != 0 ) {
80 Debug(LDAP_DEBUG_ARGS,
81 "<=- ldbm_back_delete: operations error %s\n",
83 send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
87 /* free entry and writer lock */
88 cache_return_entry_w( &li->li_cache, e );
90 send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
95 /* free entry and writer lock */
96 cache_return_entry_w( &li->li_cache, e );