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] A pointer to a null-terminated string that contains 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. To retrieve this value, use LdapGetLastError.

Remarks

Call ldap_delete to remove a leaf entry from the directory tree. Be aware 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.

To have the function return the results directly, use the synchronous routine ldap_delete_s. Use ldap_delete_ext or ldap_delete_ext_s to enable support for LDAP 3 server and client controls.

Multithreading: Calls to ldap_delete are thread-safe, provided that LdapGetLastError is used to retrieve the actual session error code when the function call returns the -1 failure code.

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

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Unicode: Implemented as Unicode and ANSI versions on all platforms.
Header: Declared in Winldap.h.
Library: Use Wldap32.lib.

See Also

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