ldap_modify()--Perform an LDAP Modify Entry Request




Syntax

#include <ldap.h>
 
typedef struct ldapmod {
			int  mod_op;
		        char *mod_type;
        		union {
				char **modv_strvals;
			        struct berval **modv_bvals;
 		       	      } mod_vals;
    		       } LDAPMod;
#define mod_values mod_vals.modv_strvals
#define mod_bvalues mod_vals.modv_bvals

int ldap_modify(
		LDAP 	   *ld,
                char 	   *dn,
                LDAPMod    *mods[])



Threadsafe: Yes

The ldap_modify() is an asynchronous request. The result of the operation can be obtained by a subsequent call to ldap_result().

The mod_op field is used to specify the type of modification to perform and should be one of the following:

LDAP_MOD_ADD (0x00)
LDAP_MOD_DELETE (0x01)
LDAP_MOD_REPLACE (0x02)

This field also indicates the type of values included in the mod_vals union. For binary data, you must also logically OR the operation type with LDAP_MOD_BVALUES (0x80). This indicates that the values are specified in a NULL-terminated array of struct berval structures. Otherwise, the mod_values will be used (i.e. the values are assumed to be a NULL-terminated array of NULL-terminated character strings).

The mod_type field specifies the name of attribute to add, modify or delete.

The mod_vals field specifies a pointer to a NULL-terminated array of values to add, modify or delete respectively. Only one of the mod_values or mod_bvalues variants should be used, with mod_bvalues being selected by ORing the mod_op field with the constant LDAP_MOD_BVALUES. mod_values is a NULL-terminated array of NULL-terminated strings and mod_bvalues is a NULL-terminated array of berval structures that can be used to pass binary values such as images.

For LDAP_MOD_ADD modifications, the given values are added to the entry, creating the attribute if necessary.

For LDAP_MOD_DELETE modifications, the given values are deleted from the entry, removing the attribute if no values remain. If the entire attribute is to be deleted, the mod_values field should be set to NULL.

For LDAP_MOD_REPLACE modifications, the attribute will have the listed values after the modification, having been created if necessary, or removed if the mod_vals field is NULL.

All modifications are performed in the order in which they are listed.

Authorities and Locks

No OS/400 authority is required. All authority checking is done by the LDAP server.

Parameters

ld
(Input) Specifies the LDAP pointer returned by a previous call to ldap_init(),ldap_ssl_init(), or ldap_open().
dn
(Input) Specifies the Distinguished Name of the entry to be modified.
mods
(Input) Specifies a NULL-terminated array of modifications to make to the entry. Each element of the mods array is a pointer to an LDAPMod structure.

Return Value

Message ID of the Operation Initiated
if the request was successful. A subsequent call to ldap_result(), can be used to obtain the result of the modify.
-1
if the request was not successful.

Error Conditions

If ldap_modify() is not successful, ld_errno will be set to indicate the error. See LDAP Client API Error Conditions for possible LDAP error code values. Use ldap_get_errno() function to retrieve the error information.

Error Messages

    The following message may be set from this function.
    CPF3CF2 E  Error(s) occurred during running of ldap_modify API.

Related Information

    ldap_modify_s() -- Synchronous modify to a directory entry.
    ldap_modify_ext() -- Asynchronous modify to a directory entry with controls.
    ldap_modify_ext_s() -- Synchronous modify to a directory entry with controls.
    ldap_modrdn() -- Asynchronously modify the RDN of an entry.
    ldap_modrdn_s() -- Synchronously modify the RDN of an entry.
    ldap_add() -- Asynchronously add an entry.


Top | LDAP APIs List
APIs by category

[Information Center Home Page | Feedback ] [Legal | AS/400 Glossary]