LDAP_DELETE

Use the LDAP_DELETE API or LDAP routine for conducting an LDAP operation to delete a leaf entry.

  • ldap_delete
  • ldap_delete_s
  • ldap_delete_ext
  • ldap_delete_ext_s

Synopsis

#include ldap.h


int ldap_delete(
       LDAP           **ld,
       const char     *dn)

int ldap_delete_s(
       LDAP           *ld,
       const char     *dn)

int ldap_delete_ext( 
       LDAP           *ld,
       const char     *dn,
       LDAPControl    **serverctrls,
       LDAPControl    **clientctrls,
       int            *msgidp)

int ldap_delete_ext_s( 
       LDAP           *ld,
       const char     *dn,
       LDAPControl    **serverctrls,
       LDAPControl    **clientctrls)

Input parameters

ld
Specifies the LDAP pointer that is returned by a previous call to ldap_init(), ldap_ssl_init() or ldap_open().
dn
Specifies the DN of the entry to be deleted.
serverctrls
Specifies a list of LDAP server controls. This parameter can be set to NULL. For more information about server controls, see LDAP controls.
clientctrls
Specifies a list of LDAP client controls. This parameter can be set to NULL. For more information about client controls, see LDAP controls.

Output parameters

msgidp
This result parameter is set to the message ID of the request if the ldap_delete_ext() call succeeds.

Usage

Note: The entry to delete must be a leaf entry, that is, it must have no children. Deletion of entire subtrees in a single operation is not supported by LDAP.

The ldap_delete_ext() API initiates an asynchronous delete operation and returns the constant LDAP_SUCCESS if the request was successfully sent, or returns another LDAP error code if the request was not successful. If successful, ldap_delete_ext() places the message ID of the request in *msgidp. ldap_result() returns the status of an operation as an error code. The error code indicates whether the operation completed successfully. The ldap_parse_result() API checks the error code.

Similarly, the ldap_delete() API initiates an asynchronous delete operation and returns the message ID of that operation. A subsequent call to ldap_result() can be used to obtain the result of the ldap_delete() operation. If there is an error, ldap_delete() returns -1, setting the session error parameters in the LDAP structure appropriately. These error parameters can be obtained by using ldap_get_errno().

See LDAP_ERROR for more details.

Use the synchronous ldap_delete_s() and ldap_delete_ext_s() APIs to run LDAP delete operations. The results of both operations are output parameters. These routines return either the constant LDAP_SUCCESS if the operation was successful, or another LDAP error code returns if the operation was not successful.

Both the ldap_delete_ext() and ldap_delete_ext_s() APIs both support LDAP V3 server controls and client controls.

Errors

ldap_delete_s() returns an LDAP error code that can be interpreted by calling an ldap_error routine. The ldap_delete() API returns -1 if the request initiation was unsuccessful. It returns the message ID of the request if successful.

See also

ldap_error