Platform SDK: Active Directory, ADSI, and Directory Services

ldap_delete

The ldap_delete function deletes an entry from the directory tree.

ULONG ldap_delete(
  LDAP* ld,
  PCHAR dn
);

Parameters

ld
[in] The session handle.
dn
[in] The distinguished name of the entry to delete.

Return Values

If the function succeeds, it returns the message ID of the delete operation.

If the function fails, the return value is –1 and the function sets the session error parameters in the LDAP data structure.

Remarks

Call ldap_delete to remove a leaf entry from the directory tree. (Note that LDAP does not support deletion of entire subtrees in a single operation.) As an asynchronous function, ldap_delete returns a message ID for the operation. Call ldap_result with the message ID to get the result of the operation. To cancel an asynchronous delete operation before it has completed, call ldap_abandon.

If you prefer to have the function return the results directly, use the synchronous routine ldap_delete_s. Use ldap_delete_ext or ldap_delete_ext_s if you need support for LDAP 3 server and client controls.

Multithreading: Calls to ldap_delete are not thread-safe because the function returns a message ID rather than the return code. In order to determine whether the call returned an error value, you have to retrieve the return code from the connection block. It is possible for another thread to overwrite the return code before you retrieve it. Use ldap_delete_ext or ldap_delete_ext_s, both of which are thread safe.

Note  When connecting to an LDAP 2 server, the application must perform a bind operation (by calling one of the ldap_bind or ldap_simple_bind routines) before attempting any other operations.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 SP4 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Winldap.h.
  Library: Use Wldap32.lib.
  Unicode: Declared as Unicode and ANSI prototypes.

See Also

Functions, ldap_abandon, ldap_bind, ldap_delete_ext, ldap_delete_ext_s, ldap_delete_s, ldap_result, ldap_simple_bind, LDAPSortKey, LDAP, Modifying a Directory Entry