ldap: provide version for "legacy" ldap as well

It displays in version output as WinLDAP and LDAP/1, compared to
OpenLDAP/[version] for the OpenLDAP backend code.

Closes #19808
This commit is contained in:
Daniel Stenberg 2025-12-02 14:13:55 +01:00
parent b30c1b97b9
commit 3e2a946926
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 35 additions and 27 deletions

View file

@ -1331,4 +1331,24 @@ ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
}
#endif /* USE_SSL */
void Curl_ldap_version(char *buf, size_t bufsz)
{
LDAPAPIInfo api;
api.ldapai_info_version = LDAP_API_INFO_VERSION;
if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) == LDAP_OPT_SUCCESS) {
unsigned int patch = (unsigned int)(api.ldapai_vendor_version % 100);
unsigned int major = (unsigned int)(api.ldapai_vendor_version / 10000);
unsigned int minor =
(((unsigned int)api.ldapai_vendor_version - major * 10000)
- patch) / 100;
curl_msnprintf(buf, bufsz, "%s/%u.%u.%u",
api.ldapai_vendor_name, major, minor, patch);
ldap_memfree(api.ldapai_vendor_name);
ber_memvfree((void **)api.ldapai_extensions);
}
else
curl_msnprintf(buf, bufsz, "OpenLDAP");
}
#endif /* !CURL_DISABLE_LDAP && USE_OPENLDAP */