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 withldap_value_free(3). π§ IfreferralspisNULL, then no referrals are returned β sorry bestie. And if no referrals were returned,*referralspis set toNULL.serverctrlspβ gets filled in with an allocated array of controls, copied straight out of the parsed message. Free this one withldap_controls_free(3)β different free function, don't mix them up, that's the trap. π IfserverctrlspisNULL, no controls are returned. And if no controls were returned,*serverctrlspis set toNULL.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 withldap_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 π₯
ldap(3)ldap_first_reference(3)ldap_first_message(3)ldap_result(3)ldap_get_values(3)ldap_controls_free(3)
π 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
- 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