function ldap_servers_get_user_ldap_data in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 7.2 ldap_servers/ldap_servers.module \ldap_servers_get_user_ldap_data()
- 7 ldap_servers/ldap_servers.module \ldap_servers_get_user_ldap_data()
@todo needs caching element. several modules could potentially call this in the same page request.
Parameters
std object $drupal_user is drupal $user object:
string $sid is a server id:
scalar $ldap_context:
11 calls to ldap_servers_get_user_ldap_data()
- FeedsDrupalUserLdapEntryFetcherResult::getRaw in ldap_feeds/
FeedsDrupalUserLdapEntryFetcher.inc - Overrides parent::getRaw();
- LdapUserConf::ldapAssociateDrupalAccount in ldap_user/
LdapUserConf.class.php - set ldap associations of a drupal account by altering user fields
- LdapUserConf::provisionDrupalAccount in ldap_user/
LdapUserConf.class.php - given a drupal account, query ldap and get all user fields and save user account (note: parameters are in odd order to match synchDrupalAccount handle)
- LdapUserConf::synchToDrupalAccount in ldap_user/
LdapUserConf.class.php - given a drupal account, query ldap and get all user fields and create user account
- LdapUserUnitTests::testUnitTests in ldap_user/
tests/ ldap_user.test - make sure install succeeds and ldap user functions/methods work
1 string reference to 'ldap_servers_get_user_ldap_data'
- LdapUserUnitTests::testUnitTests in ldap_user/
tests/ ldap_user.test - make sure install succeeds and ldap user functions/methods work
File
- ldap_servers/
ldap_servers.module, line 677
Code
function ldap_servers_get_user_ldap_data($drupal_user, $sid = NULL, $ldap_context = NULL) {
if (is_object($drupal_user) && property_exists($drupal_user, 'uid') && ($authname = db_query("SELECT authname FROM {authmap} WHERE uid = :uid AND module = 'ldap_user'", array(
':uid' => $drupal_user->uid,
))
->fetchColumn())) {
$drupal_username = $authname;
}
else {
$drupal_username = is_object($drupal_user) ? $drupal_user->name : $drupal_user;
}
// if no explicit $sid, find most appropriate one
if (!$sid && module_exists('ldap_user')) {
if (property_exists($drupal_user, 'ldap_user_puid_sid') && !empty($drupal_user->ldap_user_puid_sid['und'][0]['value'])) {
$sid = $drupal_user->ldap_user_puid_sid['und'][0]['value'];
}
else {
$ldap_user_conf = ldap_user_conf();
$sid = $ldap_user_conf->drupalAcctProvisionServer;
}
}
elseif (!$sid) {
$ldap_servers = ldap_servers_get_servers(NULL, 'enabled');
if (count($ldap_servers) == 1) {
$sids = array_keys($ldap_servers);
$sid = $sids[0];
}
}
$ldap_server = $sid ? ldap_servers_get_servers($sid, 'enabled', TRUE) : FALSE;
if ($ldap_server === FALSE) {
watchdog('ldap_servers', 'Failed to load server object %sid in _ldap_servers_get_user_ldap_data', array(
'%sid' => $sid,
), WATCHDOG_ERROR);
return FALSE;
}
$ldap_user = $ldap_server
->userUserNameToExistingLdapEntry($drupal_username, $ldap_context);
if ($ldap_user) {
$ldap_user['sid'] = $sid;
}
else {
$ldap_user = FALSE;
}
return $ldap_user;
}