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, themod_valuesfield should be set toNULLπ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
- fedora 44: openldap-devel 2.6.16-1.fc44 Β· OLDAP-2.8
- fedora 44: openldap-devel 2.6.16-1.fc44 Β· OLDAP-2.8
- Copyright 1998-2026 The OpenLDAP Foundation All Rights Reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms