typedef int (*CertSearchFn_t)(void *cert, LDAP *ld,
void *certmap_info, const char *basedn,
const char *dn, const char *filter,
const char **attrs, LDAPMessage **res);
LDAPU_SUCCESS
upon successful completion. LDAPU_FAILED
if no unexpected error occurs but the search finds no matching entries. LDAPU_CERT_SEARCH_FUNCTION_FAILED
in all other cases.
ldapu_cert_to_ldap_entry()
after calling the mapping function. The base DN and filter returned by the mapping function are passed to this function, which uses these values to search the directory for the certificate subject. The default search function works as follows:
certmap.conf
file contains the CmapLdapAttr
property, the server uses the following filter and searches all entries under the base DN:
(<value_of_CmapLdapAttr>=<subjectDN>)
For example, suppose your schema specifies that entries for users have the
attribute certSubjectDN
, which contains the subject name of the user's
certificate.
In the certmap.conf
file, you add the following statement:
issuerName:CmapLdapAttr certSubjectDN
When evaluating a certificate with the subject DN cn=Barbara
Jensen,o=Ace Industry,c=US
, the default search function uses the
following search filter to search for a matching entry:
(certSubjectDN=cn=Barbara Jensen, o=Ace Industry, c=US)
CmapLdapAttr
in the certmap.conf
file), the server uses the dn
and filter
arguments to search the directory:
filter
argument is NULL, the default filter used is (objectclass=*)
.dn
argument is not NULL, the server attempts to find a matching entry by performing a base-level search with the dn
argument as the base DN and filter
as the search filter. dn
argument is not NULL, the server attempts to find a matching entry by performing a subtree search with the dn
argument as the base DN and filter
as the search filter. dn
argument is NULL, the server attempts to find a matching entry by performing a subtree search with the basedn
argument as the base DN for the search and filter
as the search filter. static int my_cert_search_fn( void *cert, LDAP *ld, void *certmap_info,
const char *basedn, const char *dn, const char *filter,
const char **attrs, LDAPMessage **res)
{
int count, rv;
CertSearchFn_t searchfn;
...
/* Get the default search function. */
searchfn = ldapu_get_cert_searchfn(NULL);
/* Call the default search function. */
rv = (*searchfn)(cert, ld, certmap_info, basedn, dn, filter,
certmap_attrs, res);
/* Determine the number of matching entries found. */
if (rv == LDAPU_SUCCESS ) {
count = ldap_count_entries(ld, res);
...
/* Log the count of matching entries. */
...
}
...