3 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1990 Regents of the University of Michigan.
13 * Portions Copyright (C) The Internet Society (1997)
14 * ASN.1 fragments are from RFC 2251; see RFC for full legal notices.
18 * A delete request looks like this:
19 * DelRequet ::= DistinguishedName,
26 #include <ac/socket.h>
27 #include <ac/string.h>
33 * ldap_delete_ext - initiate an ldap extended delete operation. Parameters:
36 * dn DN of the object to delete
37 * sctrls Server Controls
38 * cctrls Client Controls
39 * msgidp Message Id Pointer
42 * rc = ldap_delete( ld, dn, sctrls, cctrls, msgidp );
57 LDAP_LOG ( OPERATION, ENTRY, "ldap_delete_ext\n", 0,0,0 );
59 Debug( LDAP_DEBUG_TRACE, "ldap_delete_ext\n", 0, 0, 0 );
63 assert( LDAP_VALID( ld ) );
65 assert( msgidp != NULL );
67 /* check client controls */
68 rc = ldap_int_client_controls( ld, cctrls );
69 if( rc != LDAP_SUCCESS ) return rc;
71 /* create a message to send */
72 if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
73 ld->ld_errno = LDAP_NO_MEMORY;
74 return( ld->ld_errno );
77 LDAP_NEXT_MSGID( ld, id );
78 rc = ber_printf( ber, "{its", /* '}' */
79 id, LDAP_REQ_DELETE, dn );
82 ld->ld_errno = LDAP_ENCODING_ERROR;
84 return( ld->ld_errno );
87 /* Put Server Controls */
88 if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
93 if ( ber_printf( ber, /*{*/ "N}" ) == -1 ) {
94 ld->ld_errno = LDAP_ENCODING_ERROR;
96 return( ld->ld_errno );
99 /* send the message */
100 *msgidp = ldap_send_initial_request( ld, LDAP_REQ_DELETE, dn, ber, id );
112 LDAPControl **sctrls,
113 LDAPControl **cctrls )
119 rc = ldap_delete_ext( ld, dn, sctrls, cctrls, &msgid );
121 if( rc != LDAP_SUCCESS )
122 return( ld->ld_errno );
124 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
125 return( ld->ld_errno );
127 return( ldap_result2error( ld, res, 1 ) );
130 * ldap_delete - initiate an ldap (and X.500) delete operation. Parameters:
133 * dn DN of the object to delete
136 * msgid = ldap_delete( ld, dn );
139 ldap_delete( LDAP *ld, LDAP_CONST char *dn )
144 * A delete request looks like this:
145 * DelRequet ::= DistinguishedName,
149 LDAP_LOG ( OPERATION, ENTRY, "ldap_delete\n", 0,0,0 );
151 Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 );
154 return ldap_delete_ext( ld, dn, NULL, NULL, &msgid ) == LDAP_SUCCESS
160 ldap_delete_s( LDAP *ld, LDAP_CONST char *dn )
162 return ldap_delete_ext_s( ld, dn, NULL, NULL );