typedef int (*CertMapFn_t)(void *cert, LDAP *ld,
void *certmap_info, char **ldapDN, char **filter);
LDAPU_SUCCESS
upon successful completion (the base DN and filter could be determined from the certificate and the certmap.conf
file).LDAPU_CERT_MAP_FUNCTION_FAILED
if an error occurs or if the base DN and filter cannot be determined.
ldapu_cert_to_ldap_entry()
to generate a base DN and a search filter that can be used to search for the certificate subject's entry in the directory.The default certificate mapping function does the following:
DNComps
entry in the certmap.conf
file. The output parameter ldapDN
is the base DN constructed by this function
call.
FilterComps
entry if the certmap.conf
file.The output parameter filter
is the search filter constructed by this
function call.
ldapu_certmap_info_attrval()
function. You can also enter your own name-value pairs in thecertmap.conf
file and access these values by callingldapu_certmap_info_attrval()
.
ldapu_get_cert_subject_dn()
function to get the subject's DN, then parse the DN yourself.
ldapu_get_cert_ava_val()
function to get the values of a specified DN component (for example c, o, ou, cn).#include "certmap.h"
...
/* My function for generating a base DN and filter from a certificate subject DN and the preferences under certmap.conf. */
static int my_cert_mapping_fn( void *cert, LDAP *ld,
void *certmap_info, char **ldapDN, char **filter)
{
char *subjectDN;
int rv;
char *my_val;
CertMapFn_t mapfn;
...
/* You can get the subject DN from the certificate by calling this function. */
rv = ldapu_get_cert_subject_dn( cert, &subjectDN );
/* You can call this function to get any name/value pair from the certmap.conf file (even your own custom pairs). */
ldapu_certmap_info_attrval( certmap_info, my_custom_attr, &my_val );
...
/* If you do not want to completely redefine the certificate mapping function, you can always get and call the default function.
*/
mapfn = ldapu_get_cert_mapfn(NULL);
rv = (*mapfn)(cert, ld, certmap_info, &ldapDN, &filter);
...
if (rv != LDAPU_SUCCESS) {
/* Must return LDAPU_CERT_MAP_FUNCTION_FAILED on error. */
return LDAPU_CERT_MAP_FUNCTION_FAILED;
}
...