]> git.sur5r.net Git - openldap/blob - servers/ldapd/delete.c
Update for Alpha3 from -devel as of OPENLDAP_DEVEL_981116.
[openldap] / servers / ldapd / delete.c
1 /*
2  * Copyright (c) 1990 Regents of the University of Michigan.
3  * All rights reserved.
4  *
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.
11  */
12
13 #include "portable.h"
14
15 #include <stdio.h>
16 /* ac/socket.h must precede ISODE #includes or p_type must be #undeffed
17  * after it is included.  (Because ISODE uses p_type as a field name, and
18  * SunOS 5.5:sys/vtype.h defines it (and ac/socket.h indirectly includes it) */
19 #include <ac/socket.h>
20
21 #include <quipu/commonarg.h>
22 #include <quipu/attrvalue.h>
23 #include <quipu/ds_error.h>
24 #include <quipu/remove.h>
25 #include <quipu/dap2.h>
26 #include <quipu/dua.h>
27
28 #include "lber.h"
29 #include "ldap.h"
30 #include "common.h"
31
32 #ifdef HAVE_COMPAT20
33 #define DELTAG  (ldap_compat == 20 ? OLD_LDAP_RES_DELETE : LDAP_RES_DELETE)
34 #else
35 #define DELTAG  LDAP_RES_DELETE
36 #endif
37
38 /*
39  * do_delete - Initiate an X.500 remove entry operation.  Returns 1 if
40  * the operation was initiated successfully, and thus a response will be
41  * coming back from the DSA.  Returns 0 if there was trouble and thus no
42  * DSA response is expected.
43  */
44
45 int
46 do_delete( 
47     Sockbuf     *clientsb,
48     struct msg  *m,
49     BerElement  *ber
50 )
51 {
52         char                            *dn;
53         int                             rc;
54         struct ds_removeentry_arg       ra;
55         static CommonArgs               common = default_common_args;
56
57         Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );
58
59         /*
60          * Parse the delete request.  It looks like this:
61          *      DelRequest := DistinguishedName
62          */
63
64 #if ISODEPACKAGE == IC
65 #if ICRELEASE > 2
66         DAS_RemoveEntryArgument_INIT( &ra );
67 #endif
68 #endif
69
70         if ( ber_scanf( ber, "a", &dn ) == LBER_ERROR ) {
71                 Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
72                 send_ldap_msgresult( clientsb, DELTAG, m,
73                     LDAP_PROTOCOL_ERROR, NULL, "" );
74                 return( 0 );
75         }
76
77         Debug( LDAP_DEBUG_ARGS, "do_delete: dn (%s)\n", dn, 0, 0 );
78
79         ra.rma_object = ldap_str2dn( dn );
80         free( dn );
81         if ( ra.rma_object == NULLDN ) {
82                 Debug( LDAP_DEBUG_ANY, "ldap_str2dn failed\n", 0, 0, 0 );
83                 send_ldap_msgresult( clientsb, DELTAG, m,
84                     LDAP_INVALID_DN_SYNTAX, NULL, "" );
85                 return( 0 );
86         }
87
88         ra.rma_common = common; /* struct copy */
89
90         rc = initiate_dap_operation( OP_REMOVEENTRY, m, &ra );
91
92         dn_free( ra.rma_object );
93
94         if ( rc != 0 ) {
95                 send_ldap_msgresult( clientsb, DELTAG, m, rc, NULL, "" );
96                 return( 0 );
97         }
98
99         return( 1 );
100 }
101
102 void
103 delete_result(
104     Sockbuf     *sb,
105     struct msg  *m
106 )
107 {
108         send_ldap_msgresult( sb, DELTAG, m, LDAP_SUCCESS, NULL, "" );
109
110         return;
111 }