LDAP_CONTROLS(3)

πŸ’… LDAP_CONTROLS(3) β€” the control-freak page (affectionate)

okay so bestie, welcome to LDAP_CONTROLS(3), which is a Library Functions Manual page and honestly? it's giving "backstage pass to LDAP controls" ✨ these are the little functions that let you poke at the control structures, and you're gonna slay them.


πŸŽ€ NAME πŸŽ€

ldap_control_create, ldap_control_find, ldap_control_dup, ldap_controls_dup, ldap_control_free, ldap_controls_free β€” the LDAP control manipulation routines πŸ’« like, all of them, one happy little family.


πŸ“š LIBRARY πŸ“š

OpenLDAP LDAP (libldap, -lldap)


✨ SYNOPSIS ✨

#include <ldap.h>

int ldap_control_create(const char *oid, int iscritical, struct berval
*value, int dupval, LDAPControl **ctrlp);

LDAPControl *ldap_control_find( const char *oid, LDAPControl **ctrls,
LDAPControl ***nextctrlp);

LDAPControl *ldap_control_dup(LDAPControl *ctrl);

LDAPControl **ldap_controls_dup(LDAPControl **ctrls);

void ldap_control_free(LDAPControl *ctrl);

void ldap_controls_free(LDAPControl **ctrls);

πŸ’œ DESCRIPTION πŸ’œ

okay so these routines are literally the whole vibe for manipulating the structures that LDAP controls live in 🫢 that's it, that's the job.

🌸 ldap_control_create() 🌸

this one creates a control with the OID you give it, using the contents of the value parameter for the control value β€” if there is one, no pressure 😌 the content of value gets duplicated if dupval is non-zero. and heads up: the iscritical parameter must be non-zero for a critical control πŸ”₯

the created control gets returned in the ctrlp parameter, and the routine returns LDAP_SUCCESS on success, or some other error code if it flops 😭

the content of value, for supported control types, can be prepared using helpers provided by this implementation of libldap β€” usually in the form ldap_create_<control name>_control_value(). otherwise it can be BER-encoded using the functionalities of liblber. iykyk 🧚

πŸ¦‹ ldap_control_find() πŸ¦‹

searches the NULL-terminated ctrls array for a control whose OID matches the oid parameter πŸ” returns a pointer to the control if it's found, NULL otherwise. simple, iconic.

if the nextctrlp parameter is not NULL, then on return it will point to the next control in the array β€” and you can pass it to ldap_control_find() for subsequent calls, to find further occurrences of the same control type πŸ‘‘

⚠️ the use of this function is discouraged. the recommended way of handling controls in responses consists in going through the array of controls, dealing with each of them in the returned order, since it could matter. no cap, order matters πŸ’€

πŸ“ ldap_control_dup() and ldap_controls_dup() πŸ“

ldap_control_dup() duplicates an individual control structure, and ldap_controls_dup() duplicates a NULL-terminated array of controls πŸŽ€ copy paste but make it legal.

🌈 ldap_control_free() and ldap_controls_free() 🌈

ldap_control_free() frees an individual control structure, and ldap_controls_free() frees a NULL-terminated array of controls 🫢 clean up after yourself bestie, the memory will NOT free itself.


πŸ‘€ 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. shoutout to the legends πŸ™


and that's the page, bestie πŸ’…βœ¨ signed off by OpenLDAP 2.6.16, dated 2026/10/21, from the LDAP_CONTROLS(3) girlies with love πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from