function LdapServer::drupalToLdapNameTransform in Lightweight Directory Access Protocol (LDAP) 7
1 call to LdapServer::drupalToLdapNameTransform()
- LdapServer::user_lookup in ldap_servers/
LdapServer.class.php - Queries LDAP server for the user.
File
- ldap_servers/
LdapServer.class.php, line 531 - Defines server classes and related functions.
Class
- LdapServer
- LDAP Server Class
Code
function drupalToLdapNameTransform($drupal_username, &$watchdog_tokens) {
if ($this->ldapToDrupalUserPhp && module_exists('php')) {
global $name;
$old_name_value = $name;
$name = $drupal_username;
$code = "<?php global \$name; \n" . $this->ldapToDrupalUserPhp . "; \n ?>";
$watchdog_tokens['%code'] = $this->ldapToDrupalUserPhp;
$code_result = php_eval($code);
$watchdog_tokens['%code_result'] = $code_result;
$ldap_username = $code_result;
$watchdog_tokens['%ldap_username'] = $ldap_username;
$name = $old_name_value;
// important because of global scope of $name
if ($this->detailedWatchdogLog) {
watchdog('ldap_server', '%drupal_user_name tansformed to %ldap_username by applying code <code>%code</code>', $watchdog_tokens, WATCHDOG_DEBUG);
}
}
else {
$ldap_username = $drupal_username;
}
return $ldap_username;
}