| 409 | } |
| 410 | |
| 411 | static 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 |
no test coverage detected