Skip to content

Instantly share code, notes, and snippets.

@mallardduck
Created December 2, 2015 17:55
Show Gist options
  • Save mallardduck/850e4dd8be43e1487069 to your computer and use it in GitHub Desktop.
Save mallardduck/850e4dd8be43e1487069 to your computer and use it in GitHub Desktop.
/**
* Retrieve a user by their unique identifier.
*
* @param mixed $identifier
* @return \Illuminate\Auth\UserInterface|null
*/
public function retrieveById($identifier)
{
if ($entries = $this->searchLdap($identifier)) {
if (Config::get('l4-openldap::use_db')) {
$ldap_value = $entries[0][Config::get('l4-openldap::ldap_field')][0];
$user = $this->db_conn->table(Config::get('l4-openldap::db_table'))->where(Config::get('l4-openldap::db_field'), '=', $ldap_value)->first();
if (Config::get('l4-openldap::eloquent')) {
return $this->createModel()->newQuery()->find($user->id);
} else {
return new GenericUser(get_object_vars($user));
}
} else {
return $this->createGenericUserFromLdap($entries[0]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment