MCPcopy Create free account
hub / github.com/apache/httpd / ldap_determine_binddn

Function ldap_determine_binddn

modules/aaa/mod_authnz_ldap.c:411–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411static const char *ldap_determine_binddn(request_rec *r, const char *user) {
412 authn_ldap_config_t *sec =
413 (authn_ldap_config_t *)ap_get_module_config(r->per_dir_config, &authnz_ldap_module);
414 const char *result = user;
415 ap_regmatch_t regm[AP_MAX_REG_MATCH];
416
417 if (NULL == user || NULL == sec || !sec->bind_regex || !sec->bind_subst) {
418 return result;
419 }
420
421 if (!ap_regexec(sec->bind_regex, user, AP_MAX_REG_MATCH, regm, 0)) {
422 char *substituted = ap_pregsub(r->pool, sec->bind_subst, user, AP_MAX_REG_MATCH, regm);
423 if (NULL != substituted) {
424 result = substituted;
425 }
426 }
427
428 apr_table_set(r->subprocess_env, "LDAP_BINDASUSER", result);
429
430 return result;
431}
432
433
434/* Some LDAP servers restrict who can search or compare, and the hard-coded ID

Callers 1

Calls 3

ap_get_module_configFunction · 0.85
ap_regexecFunction · 0.85
ap_pregsubFunction · 0.85

Tested by

no test coverage detected