本文整理汇总了PHP中AuthLdap::getServersWithImportByEmailActive方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthLdap::getServersWithImportByEmailActive方法的具体用法?PHP AuthLdap::getServersWithImportByEmailActive怎么用?PHP AuthLdap::getServersWithImportByEmailActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthLdap
的用法示例。
在下文中一共展示了AuthLdap::getServersWithImportByEmailActive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOrImportByEmail
/**
* @param $email (default '')
**/
static function getOrImportByEmail($email = '')
{
global $DB, $CFG_GLPI;
$query = "SELECT `users_id` as id\n FROM `glpi_useremails`\n LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_useremails`.`users_id`)\n WHERE `glpi_useremails`.`email` = '{$email}'\n ORDER BY `glpi_users`.`is_active` DESC";
$result = $DB->query($query);
//User still exists in DB
if ($result && $DB->numrows($result)) {
return $DB->result($result, 0, "id");
} else {
if ($CFG_GLPI["is_users_auto_add"]) {
//Get all ldap servers with email field configured
$ldaps = AuthLdap::getServersWithImportByEmailActive();
//Try to find the user by his email on each ldap server
foreach ($ldaps as $ldap) {
$params['method'] = AuthLdap::IDENTIFIER_EMAIL;
$params['value'] = $email;
$res = AuthLdap::ldapImportUserByServerId($params, AuthLdap::ACTION_IMPORT, $ldap);
if (isset($res['id'])) {
return $res['id'];
}
}
}
}
return 0;
}