LDAP_PARSE_REFERENCE(3)

πŸ’… LDAP_PARSE_REFERENCE β€” ok so this is the ldap_parse_reference page, from the Library Functions Manual, bestie ✨

🌸 NAME 🌸

ldap_parse_reference β€” the girl whose whole job is pulling referrals and controls out of a reference message πŸŽ€

πŸ“š LIBRARY πŸ“š

OpenLDAP LDAP (libldap, -lldap) β€” yeah you gotta link the lib, no cap 🫢

✨ SYNOPSIS ✨

#include <ldap.h>

int ldap_parse_reference( LDAP *ld, LDAPMessage *reference,
     char ***referralsp, LDAPControl ***serverctrlsp,
     int freeit )

πŸ’– DESCRIPTION πŸ’–

Okay so ldap_parse_reference() is literally the extraction routine. It takes a reference message and pulls out the referrals and the controls. That's the whole vibe. 🌈

The reference parameter is β€” you guessed it β€” a reference message. Where'd you get it? From one of these icons: ldap_first_reference(3), ldap_next_reference(3), ldap_first_message(3), ldap_next_message(3), or ldap_result(3). Pick your fighter. πŸ‘‘

Now the interesting part, the parameters:

  • referralsp β€” gets filled in with an allocated array of character strings. Those strings are copies of the referrals that were chilling inside the parsed message. When you're done slaying, free the array with ldap_value_free(3). 🧚 If referralsp is NULL, then no referrals are returned β€” sorry bestie. And if no referrals were returned, *referralsp is set to NULL.
  • serverctrlsp β€” gets filled in with an allocated array of controls, copied straight out of the parsed message. Free this one with ldap_controls_free(3) β€” different free function, don't mix them up, that's the trap. πŸ’€ If serverctrlsp is NULL, no controls are returned. And if no controls were returned, *serverctrlsp is set to NULL.
  • freeit β€” the "do we keep the message or nah" switch. It decides whether the parsed message gets freed after the extraction. Any non-zero value makes it free the message. If you're not ready to let go, you can always free it later with ldap_msgfree(3) β€” no rush, main character energy. πŸ¦‹
Lowkey important: the two arrays are allocated and copied β€” you own them, you free them. Don't be out here leaking, it's giving messy. πŸ™ˆ

😭 ERRORS 😭

On success you get LDAP_SUCCESS, iconic, we love a happy ending. πŸ’œ

Otherwise? The values of the referralsp and serverctrlsp parameters are undefined. Not "empty", not "NULL-ish", undefined. So don't go reading them, that's not the vibe check you want to fail. πŸ’€

πŸ”₯ 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. Big ups to them fr fr 🫢


And that's the whole page, bestie β€” this was OpenLDAP 2.6.16, dated 2026/10/21, page LDAP_PARSE_REFERENCE(3). Go forth and free your arrays. Periodt. πŸŽ€πŸ’–

πŸ“¦ where this page comes from