ldap_modify_ext() instead.
#include <ldap.h>
int ldap_modify( LDAP *ld, const char *dn, LDAPMod **mods );
ld |
Connection handle, which is a pointer to an |
dn | |
mods |
Pointer to a NULL-terminated array of pointers to |
ldap_modify() operation. To check the result of this operation, call ldap_result() and ldap_result2error(). For a list of possible result codes for an LDAP modify operation, see the result code documentation on the ldap_modify_ext_s() function.
ldap_modify() function updates an entry in the directory.
A newer version of this function, ldap_modify_ext(), is available in this release of the LDAP API. ldap_modify() (the older version of the function) is included only for backward-compatibility. If you are writing a new LDAP client, use ldap_modify_ext() instead of ldap_modify().
If you want more information on ldap_modify(), refer to the LDAP C SDK 1.0 Programmer's Guide.
ldap_modify() function to modify the entry for "Barbara Jensen" in the directory. The example makes the following changes to the entry:
homePhone attribute. telephoneNumber attribute. facsimileTelephoneNumber attribute. #include <ldap.h>
...
LDAP *ld;
LDAPMod *list_of_attrs[4];
LDAPMod attribute1, attribute2, attribute3;
LDAPMessage *result;
int msgid, rc;
struct timeval tv;
/* Distinguished name of the entry that you want to modify. */
char *dn = "uid=bjensen, ou=People, o=Airius.com";
/* Values to add or change */
char *homePhone_values[] = { "555-1212", NULL };char *telephoneNumber_values[] = { "869-5309", NULL };...
/* Specify each change in separate LDAPMod structures */
attribute1.mod_type = "homePhone";
attribute1.mod_op = LDAP_MOD_ADD;
attribute1.mod_values = homePhone_values;
attribute2.mod_type = "telephoneNumber";
attribute2.mod_op = LDAP_MOD_REPLACE;
attribute2.mod_values = telephoneNumber_values;
attribute3.mod_type = "facsimileTelephoneNumber";
attribute3.mod_op = LDAP_MOD_DELETE;
attribute3.mod_values = NULL;
/* NOTE: When removing entire attributes, you need to specify a NULL value for the mod_values field. */
/* Add the pointers to these LDAPMod structures to an array */
list_of_attrs[0] = &attribute1;
list_of_attrs[1] = &attribute2;
list_of_attrs[2] = &attribute3;
list_of_attrs[3] = NULL;
...
/* Set up the timeout period to wait for the "modify" operation */
tv.tv_sec = tv.tv_usec = 0;
/* Change the entry */
if ( ( msgid = ldap_modify( ld, dn, list_of_attrs ) ) == -1 ) {ldap_perror( ld, "ldap_modify" );
return( 1 );
}
/* Check to see if the operation has completed */
while ( ( rc = ldap_result( ld, msgid, 0, &tv, &result ) ) == 0 ) {...
/* do other work while waiting for the operation to complete */
...
}
/* Check the result to see if any errors occurred */
ldap_result2error( ld, result, 1 );
ldap_perror( ld, "ldap_modify" );
...
ldap_modify_ext().
Last Updated: 10/01/98 17:06:23