LDAP_MODIFY(3)

πŸ’… LDAP_MODIFY(3) β€” the "go change an entry bestie" page ✨

okay so this is LDAP_MODIFY(3) from the Library Functions Manual, and it lives in the OpenLDAP LDAP library β€” like, you link it with -lldap πŸŽ€. Buckle up, we're doing modify operations.


🌸 NAME 🌸

ldap_modify_ext, ldap_modify_ext_s β€” perform an LDAP modify operation. that's it, that's the whole gig πŸ’–


πŸ¦‹ LIBRARY πŸ¦‹

OpenLDAP LDAP (libldap, -lldap) β€” yes queen, that's your linker flag πŸ‘‘


✨ SYNOPSIS ✨

#include <ldap.h>

int ldap_modify_ext(
       LDAP *ld,
       char *dn,
       LDAPMod *mods[],
       LDAPControl **sctrls,
       LDAPControl **cctrls,
       int *msgidp );

int ldap_modify_ext_s(
       LDAP *ld,
       char *dn,
       LDAPMod *mods[],
       LDAPControl **sctrls,
       LDAPControl **cctrls );

void ldap_mods_free(
       LDAPMod **mods,
       int freemods );

πŸ’œ DESCRIPTION πŸ’œ

so ldap_modify_ext_s() is the one that actually does the LDAP modify operation, and it's the synchronous icon we all know and love πŸ’…. Here's the tea: dn is the DN of the entry you're modifying, and mods is a null-terminated array of modifications to make to that entry 🫢. each element of the mods array is a pointer to an LDAPMod structure, which is literally defined right here:

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

the mod_op field is where you say what kind of modification you're doing, and it should be one of LDAP_MOD_ADD, LDAP_MOD_DELETE, or LDAP_MOD_REPLACE β€” pick one, bestie, no mixing 🌈. the mod_type and mod_values fields specify the attribute type to modify and a null-terminated array of values to add, delete, or replace, respectively ✨.

now, if you need to specify a non-string value (like, say, adding a photo or audio attribute value β€” yes those are a thing 😭), you should set mod_op to the logical OR of the operation as above (e.g., LDAP_MOD_REPLACE) and the constant LDAP_MOD_BVALUES πŸ”₯. in that case, mod_bvalues should be used instead of mod_values, and it should point to a null-terminated array of struct bervals, as defined in <lber.h> 🧚.

here's the vibe check on each op:

  • LDAP_MOD_ADD β€” the given values are added to the entry, creating the attribute if necessary πŸ’–
  • LDAP_MOD_DELETE β€” 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 πŸ’€
  • LDAP_MOD_REPLACE β€” the attribute will have the listed values after the modification, having been created if necessary πŸ‘‘

and no cap: all modifications are performed in the order in which they are listed ⭐.

ldap_mods_free() can be used to free each element of a NULL-terminated array of mod structures 🫢. and if freemods is non-zero, the mods pointer itself is freed as well β€” so like, don't double-free, bestie, i'm begging πŸ™ˆ.

ldap_modify_ext_s() returns a code indicating success or, in the case of failure, indicating the nature of the failure 😭. see ldap_error(3) for details πŸ’œ.

the ldap_modify_ext() operation works the same way as ldap_modify_ext_s(), except that it is asynchronous β€” main character energy, it does not wait 🌸. the integer that msgidp points to is set to the message id of the modify request ⭐. the result of the operation can be obtained by calling ldap_result(3) πŸ‘‘.

both ldap_modify_ext() and ldap_modify_ext_s() allow server and client controls to be passed in via the sctrls and cctrls parameters, respectively ✨.


πŸ’€ DEPRECATED INTERFACES πŸ’€

the ldap_modify() and ldap_modify_s() routines are deprecated in favor of the ldap_modify_ext() and ldap_modify_ext_s() routines, respectively πŸ₯€. they ate, but their time has passed.

deprecated interfaces generally remain in the library 🫢. the macro LDAP_DEPRECATED can be defined to a non-zero value (e.g., -DLDAP_DEPRECATED=1) when compiling a program designed to use deprecated interfaces πŸ”§.

lowkey important: it is recommended that developers writing new programs, or updating old programs, avoid use of deprecated interfaces πŸ™ˆ. over time, it is expected that documentation (and, eventually, support) for deprecated interfaces to be eliminated β€” so like, don't build your whole personality on them πŸ’€

πŸŽ€ SEE ALSO πŸŽ€


πŸ‘‘ ACKNOWLEDGEMENTS πŸ‘‘

OpenLDAP Software is developed and maintained by The OpenLDAP Project <http://www.openldap.org/> 🫢. OpenLDAP Software is derived from the University of Michigan LDAP 3.3 Release 🌸.


okay and that's the whole page, bestie πŸ¦‹ β€” this was OpenLDAP 2.6.16, dated 2026/10/21, and it's literally LDAP_MODIFY(3) and it slayed πŸ’…βœ¨πŸ’–

πŸ“¦ where this page comes from