3 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1990 Regents of the University of Michigan.
14 * A delete request looks like this:
15 * DelRequet ::= DistinguishedName,
22 #include <ac/socket.h>
23 #include <ac/string.h>
29 * ldap_delete_ext - initiate an ldap extended delete operation. Parameters:
32 * dn DN of the object to delete
33 * sctrls Server Controls
34 * cctrls Client Controls
35 * msgidp Message Id Pointer
38 * rc = ldap_delete( ld, dn, sctrls, cctrls, msgidp );
52 LDAP_LOG ( OPERATION, ENTRY, "ldap_delete_ext\n", 0,0,0 );
54 Debug( LDAP_DEBUG_TRACE, "ldap_delete_ext\n", 0, 0, 0 );
58 assert( LDAP_VALID( ld ) );
60 assert( msgidp != NULL );
62 /* check client controls */
63 rc = ldap_int_client_controls( ld, cctrls );
64 if( rc != LDAP_SUCCESS ) return rc;
66 /* create a message to send */
67 if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
68 ld->ld_errno = LDAP_NO_MEMORY;
69 return( ld->ld_errno );
72 if ( ber_printf( ber, "{its", /* '}' */
73 ++ld->ld_msgid, LDAP_REQ_DELETE, dn ) == -1 )
75 ld->ld_errno = LDAP_ENCODING_ERROR;
77 return( ld->ld_errno );
80 /* Put Server Controls */
81 if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
86 if ( ber_printf( ber, /*{*/ "N}" ) == -1 ) {
87 ld->ld_errno = LDAP_ENCODING_ERROR;
89 return( ld->ld_errno );
92 /* send the message */
93 *msgidp = ldap_send_initial_request( ld, LDAP_REQ_DELETE, dn, ber );
105 LDAPControl **sctrls,
106 LDAPControl **cctrls )
112 rc = ldap_delete_ext( ld, dn, sctrls, cctrls, &msgid );
114 if( rc != LDAP_SUCCESS )
115 return( ld->ld_errno );
117 if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
118 return( ld->ld_errno );
120 return( ldap_result2error( ld, res, 1 ) );
123 * ldap_delete - initiate an ldap (and X.500) delete operation. Parameters:
126 * dn DN of the object to delete
129 * msgid = ldap_delete( ld, dn );
132 ldap_delete( LDAP *ld, LDAP_CONST char *dn )
137 * A delete request looks like this:
138 * DelRequet ::= DistinguishedName,
142 LDAP_LOG ( OPERATION, ENTRY, "ldap_delete\n", 0,0,0 );
144 Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 );
147 return ldap_delete_ext( ld, dn, NULL, NULL, &msgid ) == LDAP_SUCCESS
153 ldap_delete_s( LDAP *ld, LDAP_CONST char *dn )
155 return ldap_delete_ext_s( ld, dn, NULL, NULL );