LDAP_PARSE_RESULT(3)

πŸ’… ldap_parse_result

okay bestie, grab your iced coffee because this is the ldap_parse_result(3) page from the OpenLDAP library functions manual, and we're about to make result-parsing make sense 🫢


✨ NAME ✨

ldap_parse_result β€” literally the art of parsing results πŸ’–


πŸŽ€ LIBRARY πŸŽ€

OpenLDAP LDAP (libldap, -lldap) β€” that's the one you link against, no cap.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <ldap.h>

int ldap_parse_result( LDAP *ld, LDAPMessage *result,
     int *errcodep, char **matcheddnp, char **errmsgp,
     char ***referralsp, LDAPControl ***serverctrlsp,
     int freeit )

int ldap_parse_sasl_bind_result( LDAP *ld, LDAPMessage *result,
     struct berval **servercredp, int freeit )

int ldap_parse_extended_result( LDAP *ld, LDAPMessage *result,
     char **retoidp, struct berval **retdatap, int freeit )

int ldap_parse_intermediate( LDAP *ld, LDAPMessage *result,
     char **retoidp, struct berval **retdatap,
     LDAPControl ***serverctrlsp, int freeit )

copy these signatures exactly, bestie, they are not vibes-based πŸ™ˆ


🌸 DESCRIPTION 🌸

So these routines exist to pull information out of a result message β€” like, they're the little extractor tools 🧚

They operate on the first result message in a chain of search results (skipping past other message types, iconic behaviour honestly). You feed them a result as returned by a call to ldap_result(3), ldap_search_s(3) or ldap_search_st(3).

Alongside ldap_parse_result(), the routines ldap_parse_sasl_bind_result() and ldap_parse_extended_result() are there to get all the result information from SASL bind and extended operations. And to extract information from intermediate responses, ldap_parse_intermediate() is your girl. πŸ‘‘


πŸ’œ the result parameters

  • errcodep β€” gets filled in with the result code from the result message. straight up.
  • matcheddnp β€” the server might supply a matched DN string in the message, indicating how much of a name in a request was recognized. If supplied, this param gets filled in with that string; else it's NULL. If a string comes back, free it with ldap_memfree(3) β€” don't just leave it lying around 😭
  • errmsgp β€” filled in with the error message field from the parsed message. free this string with ldap_memfree(3) too.
  • referralsp β€” filled in with an allocated array of referral strings from the parsed message. free that array with ldap_memvfree(3). If no referrals were returned, *referralsp is set to NULL.
  • serverctrlsp β€” filled in with an allocated array of controls copied from the parsed message. free the array with ldap_controls_free(3). If no controls were returned, *serverctrlsp is set to NULL.
  • freeit β€” decides whether the parsed message gets freed after the extraction or not. Any non-zero value makes it free the message. You can also use ldap_msgfree(3) to free it later, if that's more your vibe.

πŸ“ SASL bind results

For SASL bind results, the servercredp parameter gets filled in with an allocated berval structure containing the credentials from the server, if present. Free that structure using ber_bvfree(3). πŸ’…


🌈 extended results & intermediate responses

  • retoidp β€” filled in with the dotted-OID text representation of the name of the extended operation response. free the string with ldap_memfree(3). If no OID was returned, *retoidp is set to NULL.
  • retdatap β€” filled in with a pointer to a berval structure containing the data from the extended operation response. free that structure with ber_bvfree(3). If no data were returned, *retdatap is set to NULL.

⭐ the bestie loophole

For all the above result parameters, you can pass NULL values in calls in order to ignore certain fields. yes really. skip the ones you don't care about, self-care 🫢


πŸ’€ ERRORS πŸ’€

Upon success, LDAP_SUCCESS is returned. Otherwise the values of the result parameters are undefined β€” like, genuinely don't touch them, that's the warning, take it seriously πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

ldap(3), ldap_result(3), ldap_search(3), ldap_memfree(3), ldap_memvfree(3), ldap_get_values(3), ldap_controls_free(3), lber-types(3)

go read them, iykyk πŸ’–


πŸ‘‘ 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 that's the whole page, mwah πŸ’‹ this was OpenLDAP 2.6.16, dated 2026/10/21, and it lives at LDAP_PARSE_RESULT(3) β€” go parse some results, bestie, you're gonna slay βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from