LDAP_ADD(3)

✨ LDAP_ADD β€” the ldap_add_ext, ldap_add_ext_s manual, but make it make sense ✨

okay so bestie, you're reading the LDAP_ADD(3) page from the Library Functions Manual β€” yes that one, the library functions girlies πŸ’…. Sit down, hydrate, and let's get into it, because adding entries to a directory should NOT be this much of a vibe check.

🌸 LIBRARY 🌸

OpenLDAP LDAP (libldap, -lldap) β€” periodt, that's the library, that's the flag, no notes 🫢


πŸŽ€ SYNOPSIS πŸŽ€

like, literally just include the header first, always:

#include <ldap.h>

then the async bestie:

int ldap_add_ext(
       LDAP *ld,
       const char *dn,
       LDAPMod **attrs,
       LDAPControl **sctrls,
       LDAPControl **cctrls,
       int *msgidp );

and the synchronous one:

int ldap_add_ext_s(
       LDAP *ld,
       const char *dn,
       LDAPMod **attrs,
       LDAPControl *sctrls,
       LDAPControl *cctrls );
⚠️ yes, <hotpink>*sctrls has one star in the _s version and <hotpink>**sctrls has two in the async one. do NOT come for me, that's just how it is, copy it exactly, iykyk 😭

πŸ¦‹ DESCRIPTION πŸ¦‹

so ldap_add_ext_s() is THE routine for actually performing an LDAP add operation β€” main character energy, it does the thing and waits for the answer. it takes:

  • dn β€” the DN of the entry you wanna add πŸ‘‘
  • attrs β€” a null-terminated array of the entry's attributes πŸ“

the LDAPMod structure is what represents attributes, ngl. its mod_type and mod_values fields get used exactly as described over in ldap_modify_ext(3) (go read that one, i'm not re-explaining it), and the ldap_op field? only used if you need to specify the LDAP_MOD_BVALUES option. otherwise, set it to zero. that's the whole rule. zero. 😌

πŸ’€ the big one: all entries except the one specified by the last component in the given DN must already exist. like, the parent has to be there already or it's not happening, no cap.

ldap_add_ext_s() returns a code indicating success or β€” when it goes wrong β€” a code indicating the nature of the failure. see ldap_error(3) for more details. πŸ’–

now the async girlie: ldap_add_ext() works just like ldap_add_ext_s(), except it's asynchronous. it returns the message id of the request it initiated (that's your msgidp, bestie πŸŽ€). want the actual result of the operation? go call ldap_result(3). she'll tell you. ✨


πŸ™ˆ DEPRECATED INTERFACES πŸ™ˆ

okay so this is the part where we gently say goodbye πŸ‘‹

  • ldap_add() and ldap_add_s() are deprecated in favor of ldap_add_ext() and ldap_add_ext_s() respectively. like, one-for-one swap, no drama.

deprecated interfaces generally remain in the library (they're not gone, they're just resting πŸ’…). 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.

🫢 recommendation from me to you: if you're writing new programs, or updating old ones, avoid the deprecated interfaces. over time, it is expected that documentation (and, eventually, support) for deprecated interfaces gets eliminated. so like... don't build your whole personality on them, babes. ⭐

🌈 SEE ALSO 🌈

go touch these pages, they're iconic:


🧚 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. absolute legends, fr fr πŸ‘‘


mwah, that's the whole page πŸ’œ this was OpenLDAP 2.6.16, dated 2026/10/21, page LDAP_ADD(3) β€” screenshot it, cite it, go add some entries responsibly πŸŽ€βœ¨

πŸ“¦ where this page comes from