Platform SDK: Active Directory, ADSI, and Directory Services

ldap_modify

The ldap_modify function changes an existing entry.

ULONG ldap_modify(
  LDAP* ld, 
  PCHAR dn, 
  LDAPMod* mods[] 
);

Parameters

ld
[in] The session handle.
dn
[in] The name of the entry to modify.
mods
[in] A null-terminated array of modifications to make to the entry.

Return Values

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

If the function fails, it returns –1 and sets the session error parameters in the LDAP data structure.

Remarks

The ldap_modify function initiates an asynchronous operation to modify an existing entry. If values are being added to or replaced in the entry, the function creates the attribute, if necessary. If values are being deleted, and no values remain, the function removes the attribute. All modifications are performed in the order in which they are listed.

As an asynchronous function, ldap_modify 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 operation before it has completed, call ldap_abandon.

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

Multithreading: A call to ldap_modify is 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's possible for another thread to overwrite the return code before you retrieve it. Use ldap_modify_ext, ldap_modify_s, or ldap_modify_ext_s, all 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, ldap_abandon, ldap_bind, ldap_modify_ext, ldap_modify_ext_s, ldap_modify_s, ldap_result, ldap_simple_bind, Modifying a Directory Entry