本文整理汇总了PHP中AuthLdap类的典型用法代码示例。如果您正苦于以下问题:PHP AuthLdap类的具体用法?PHP AuthLdap怎么用?PHP AuthLdap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AuthLdap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: pdfLdapForm
static function pdfLdapForm(PluginPdfSimplePDF $pdf, Group $item)
{
if (Session::haveRight("config", "r") && AuthLdap::useAuthLdap()) {
$pdf->setColumnsSize(100);
$pdf->displayTitle(__('LDAP directory link'));
$pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('User attribute containing its groups') . '</b>', $item->getField('ldap_field')));
$pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Attribute value') . '</b>', $item->getField('ldap_value')));
$pdf->displayText('<b>' . sprintf(__('%1$s: %2$s'), __('Group DN') . '</b>', $item->getField('ldap_group_dn')));
$pdf->displaySpace();
}
}
开发者ID:geldarr,项目名称:hack-space,代码行数:11,代码来源:group.class.php
示例2: buildLdapFilter
/**
* @param $authldap AuthLDAP object
**/
private static function buildLdapFilter(AuthLdap $authldap)
{
//Build search filter
$counter = 0;
$filter = '';
if (!empty($_SESSION['ldap_import']['criterias']) && $_SESSION['ldap_import']['interface'] == self::SIMPLE_INTERFACE) {
foreach ($_SESSION['ldap_import']['criterias'] as $criteria => $value) {
if ($value != '') {
$begin = 0;
$end = 0;
if (($length = strlen($value)) > 0) {
if ($value[0] == '^') {
$begin = 1;
}
if ($value[$length - 1] == '$') {
$end = 1;
}
}
if ($begin || $end) {
// no Toolbox::substr, to be consistent with strlen result
$value = substr($value, $begin, $length - $end - $begin);
}
$counter++;
$filter .= '(' . $authldap->fields[$criteria] . '=' . ($begin ? '' : '*') . $value . ($end ? '' : '*') . ')';
}
}
} else {
$filter = "(" . $authldap->getField("login_field") . "=*)";
}
//If time restriction
$begin_date = isset($_SESSION['ldap_import']['begin_date']) && !empty($_SESSION['ldap_import']['begin_date']) ? $_SESSION['ldap_import']['begin_date'] : NULL;
$end_date = isset($_SESSION['ldap_import']['end_date']) && !empty($_SESSION['ldap_import']['end_date']) ? $_SESSION['ldap_import']['end_date'] : NULL;
$filter .= self::addTimestampRestrictions($begin_date, $end_date);
$ldap_condition = $authldap->getField('condition');
//Add entity filter and filter filled in directory's configuration form
return "(&" . (isset($_SESSION['ldap_import']['entity_filter']) ? $_SESSION['ldap_import']['entity_filter'] : '') . " {$filter} {$ldap_condition})";
}
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:40,代码来源:authldap.class.php
示例3: useAuthExt
/**
* Is an external authentication used ?
*
* @return boolean
**/
static function useAuthExt()
{
//Get all the ldap directories
if (AuthLdap::useAuthLdap()) {
return true;
}
if (AuthMail::useAuthMail()) {
return true;
}
if (!empty($CFG_GLPI["x509_email_field"])) {
return true;
}
// Existing auth method
if (!empty($CFG_GLPI["ssovariables_id"])) {
return true;
}
// Using CAS server
if (!empty($CFG_GLPI["cas_host"])) {
return true;
}
return false;
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:27,代码来源:auth.class.php
示例4: isEntityDirectoryConfigured
/**
* @since version 0.84 (before in entitydata.class)
*
* @param $entities_id
**/
static function isEntityDirectoryConfigured($entities_id)
{
$entity = new self();
if ($entity->getFromDB($entities_id) && $entity->getField('authldaps_id') > 0) {
return true;
}
//If there's a directory marked as default
if (AuthLdap::getDefault()) {
return true;
}
return false;
}
开发者ID:korial29,项目名称:glpi,代码行数:17,代码来源:entity.class.php
示例5: showLDAPForm
/**
* @param $ID
**/
function showLDAPForm($ID)
{
$options = array();
$this->initForm($ID, $options);
echo "<form name='groupldap_form' id='groupldap_form' method='post' action='" . $this->getFormURL() . "'>";
echo "<div class='spaced'><table class='tab_cadre_fixe'>";
if (Group::canUpdate() && Session::haveRight("user", User::UPDATEAUTHENT) && AuthLdap::useAuthLdap()) {
echo "<tr class='tab_bg_1'>";
echo "<th colspan='2' class='center'>" . __('In users') . "</th></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Attribute of the user containing its groups') . "</td>";
echo "<td>";
Html::autocompletionTextField($this, "ldap_field");
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Attribute value') . "</td>";
echo "<td>";
Html::autocompletionTextField($this, "ldap_value");
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<th colspan='2' class='center'>" . __('In groups') . "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Group DN') . "</td>";
echo "<td>";
Html::autocompletionTextField($this, "ldap_group_dn");
echo "</td></tr>";
}
$options = array('colspan' => 1, 'candel' => false);
$this->showFormButtons($options);
}
开发者ID:korial29,项目名称:glpi,代码行数:34,代码来源:group.class.php
示例6: unset
}
if (!isset($_SESSION["ldap_server"])) {
if (isset($_POST["ldap_server"])) {
$_SESSION["ldap_server"] = $_POST["ldap_server"];
} else {
Html::redirect($CFG_GLPI["root_doc"] . "/front/ldap.php");
}
}
if (!AuthLdap::testLDAPConnection($_SESSION["ldap_server"])) {
unset($_SESSION["ldap_server"]);
echo "<div class='center b'>" . __('Unable to connect to the LDAP directory') . "<br>";
echo "<a href='" . $_SERVER['PHP_SELF'] . "?next=listservers'>" . __('Back') . "</a></div>";
} else {
if (!isset($_SESSION["ldap_group_filter"])) {
$_SESSION["ldap_group_filter"] = '';
}
if (!isset($_SESSION["ldap_group_filter2"])) {
$_SESSION["ldap_group_filter2"] = '';
}
if (isset($_GET["order"])) {
$_SESSION["ldap_sortorder"] = $_GET["order"];
}
if (!isset($_SESSION["ldap_sortorder"])) {
$_SESSION["ldap_sortorder"] = "ASC";
}
AuthLdap::displayLdapFilter($_SERVER['PHP_SELF'], false);
AuthLdap::showLdapGroups($_SERVER['PHP_SELF'], $_GET['start'], 0, $_SESSION["ldap_group_filter"], $_SESSION["ldap_group_filter2"], $_SESSION["glpiactive_entity"], $_SESSION["ldap_sortorder"]);
}
}
}
Html::footer();
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:ldap.group.import.php
示例7: search
function search($query)
{
$userlist = array();
$ldapinfo = array();
$combined_userlist = array();
foreach (preg_split('/\\n/', $this->getConfig()->get('basedn')) as $i => $dn) {
$dn = trim($dn);
$servers = $this->getConfig()->get('servers');
$serversa = preg_split('/\\s+/', $servers);
$sd = $this->getConfig()->get('shortdomain');
$sda = preg_split('/;|,/', $sd);
$bind_dn = $this->getConfig()->get('bind_dn');
$bind_dna = preg_split('/\\n/', $bind_dn);
$bind_pw = $this->getConfig()->get('bind_pw');
$bind_pwa = preg_split('/;|,/', $bind_pw);
$ldapinfo[] = array('dn' => trim($dn), 'sd' => trim($sda[$i]), 'servers' => trim($serversa[$i]), 'bind_dn' => trim($bind_dna[$i]), 'bind_pw' => trim($bind_pwa[$i]));
}
foreach ($ldapinfo as $data) {
$ldap = new AuthLdap();
$ldap->serverType = 'ActiveDirectory';
$ldap->server = preg_split('/;|,/', $data['servers']);
$ldap->dn = $data['dn'];
$ldap->searchUser = $data['bind_dn'];
$ldap->searchPassword = $data['bind_pw'];
if ($ldap->connect()) {
$filter = "(&(objectCategory=person)(objectClass=user)(|(sAMAccountName={q}*)(firstName={q}*)(lastName={q}*)(displayName={q}*)))";
if ($userlist = $ldap->getUsers($query, array('sAMAccountName', 'sn', 'givenName', 'displayName', 'mail', 'telephoneNumber', 'distinguishedName'), $filter)) {
//echo 'userlist: ' . json_encode($userlist);
$temp_userlist = $this->multi_re_key($userlist, array('sAMAccountName', 'givenName', 'sn', 'displayName', 'mail', 'telephoneNumber', 'distinguishedName'), array('username', 'first', 'last', 'full', 'email', 'phone', 'dn'));
$combined_userlist = array_merge($combined_userlist, $temp_userlist);
}
} else {
$conninfo[] = array(false, $data['sd'] . " error: " . $ldap->ldapErrorCode . " - " . $ldap->ldapErrorText);
}
}
return $combined_userlist;
}
开发者ID:philbertphotos,项目名称:osticket-ldap-auth,代码行数:37,代码来源:auth.php
示例8: syncEntity
/**
* @param $pid
* @param $data
* @param $server
* @param $prof
* @param $verb
* @param $mail
**/
function syncEntity($pid, $data, $server, $prof, $verb, $mail)
{
global $DB, $LANG, $CFG_GLPI;
// Re-establish DB connexion - mandatory in each forked process
if (!DBConnection::switchToMaster()) {
echo " {$pid}: lost DB connection\n";
return 0;
}
// Server from entity (if not given from option)
if ($data['authldaps_id'] > 0) {
$server = $data['authldaps_id'];
}
$entity = new Entity();
if ($entity->getFromDB($id = $data['id'])) {
$tps = microtime(true);
if ($verb) {
echo " {$pid}: Synchonizing entity '" . $entity->getField('completename') . "' ({$id}, mail={$mail})\n";
}
$sql = "SELECT DISTINCT glpi_users.*\n FROM glpi_users\n INNER JOIN glpi_profiles_users\n ON (glpi_profiles_users.users_id = glpi_users.id\n AND glpi_profiles_users.entities_id = {$id}";
if ($prof > 0) {
$sql .= " AND glpi_profiles_users.profiles_id = {$prof}";
}
$sql .= ")\n WHERE glpi_users.authtype = " . Auth::LDAP;
if ($server > 0) {
$sql .= " AND glpi_users.auths_id = {$server}";
}
$users = array();
$results = array(AuthLDAP::USER_IMPORTED => 0, AuthLDAP::USER_SYNCHRONIZED => 0, AuthLDAP::USER_DELETED_LDAP => 0);
$req = $DB->request($sql);
$i = 0;
$nb = $req->numrows();
foreach ($req as $row) {
$i++;
$result = AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $row['name']), AuthLDAP::ACTION_SYNCHRONIZE, $row['auths_id']);
if ($result) {
$results[$result['action']] += 1;
$users[$row['id']] = $row['name'];
if ($result['action'] == AuthLDAP::USER_SYNCHRONIZED) {
if ($verb) {
echo " {$pid}: User '" . $row['name'] . "' synchronized ({$i}/{$nb})\n";
}
} else {
if ($verb) {
echo " {$pid}: User '" . $row['name'] . "' deleted\n";
}
}
} else {
if ($verb) {
echo " {$pid}: Problem with LDAP for user '" . $row['name'] . "'\n";
}
}
}
$tps = microtime(true) - $tps;
printf(" %d: Entity '%s' - Synchronized: %d, Deleted from LDAP: %d, Time: %.2f\"\n", $pid, $entity->getField('completename'), $results[AuthLDAP::USER_SYNCHRONIZED], $results[AuthLDAP::USER_DELETED_LDAP], $tps);
if ($mail) {
$report = '';
$user = new User();
foreach ($users as $id => $name) {
if ($user->getFromDB($id)) {
$logs = Log::getHistoryData($user, 0, $_SESSION['glpilist_limit'], "`date_mod`='" . $_SESSION['glpi_currenttime'] . "'");
if (count($logs)) {
$report .= "\n{$name} (" . $user->getName() . ")\n";
foreach ($logs as $log) {
$report .= "\t";
if ($log['field']) {
$report .= $log['field'] . ": ";
}
$report .= Html::clean($log['change']) . "\n";
}
}
} else {
$report .= "\n" . $name . "\n\t deleted\n";
}
}
if ($report) {
$report = "Synchronization of already imported users\n " . "Entité: " . $entity->getField('completename') . "\n " . "Date: " . Html::convDateTime($_SESSION['glpi_currenttime']) . "\n " . $report;
$entdata = new Entity();
$mmail = new NotificationMail();
$mmail->AddCustomHeader("Auto-Submitted: auto-generated");
$mmail->From = $CFG_GLPI["admin_email"];
$mmail->FromName = "GLPI";
$mmail->Subject = "[GLPI] LDAP directory link";
$mmail->Body = $report . "\n--\n" . $CFG_GLPI["mailing_signature"];
if ($mail & 1 && $entdata->getFromDB($entity->getField('id')) && $entdata->fields['admin_email']) {
$mmail->AddAddress($entdata->fields['admin_email']);
} else {
if ($mail & 1 && $verb) {
echo " {$pid}: No address found for email entity\n";
}
$mail = $mail & 2;
}
if ($mail & 2 && $CFG_GLPI['admin_email']) {
//.........这里部分代码省略.........
开发者ID:glpi-project,项目名称:glpi,代码行数:101,代码来源:ldapsync.php
示例9: AuthLdap
<?php
include '../../../inc/includes.php';
Session::checkRight("config", "w");
$authldap = new AuthLdap();
$authldap->getFromDB($_POST['value']);
$filter = "(" . $authldap->getField("login_field") . "=*)";
$ldap_condition = $authldap->getField('condition');
echo "(& {$filter} {$ldap_condition})";
开发者ID:nicholaseduardo,项目名称:formcreator,代码行数:9,代码来源:ldap_filter.php
示例10: foreach
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
$ids[] = $key;
}
}
$softdictionnayrule->replayRulesOnExistingDB(0, 0, $ids);
break;
case "force_user_ldap_update":
checkRight("user", "w");
$user = new User();
$ids = array();
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
$user->getFromDB($key);
if ($user->fields["authtype"] == Auth::LDAP || $user->fields["authtype"] == Auth::EXTERNAL) {
AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $user->fields["name"]), 1, $user->fields["auths_id"]);
}
}
}
break;
case "add_transfer_list":
if (!isset($_SESSION['glpitransfer_list'])) {
$_SESSION['glpitransfer_list'] = array();
}
if (!isset($_SESSION['glpitransfer_list'][$_POST["itemtype"]])) {
$_SESSION['glpitransfer_list'][$_POST["itemtype"]] = array();
}
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
$_SESSION['glpitransfer_list'][$_POST["itemtype"]][$key] = $key;
}
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:massiveaction.php
示例11: unset
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
Session::checkRight("user", User::IMPORTEXTAUTHUSERS);
Html::header(__('LDAP directory link'), $_SERVER['PHP_SELF'], "admin", "user", "ldap");
if (isset($_SESSION["ldap_sortorder"])) {
unset($_SESSION["ldap_sortorder"]);
}
AuthLdap::manageValuesInSession(array(), true);
echo "<div class='center'><table class='tab_cadre'>";
echo "<tr><th>" . __('Bulk import users from a LDAP directory') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center b'>" . "<a href='ldap.import.php?mode=1&action=show'>" . __('Synchronizing already imported users') . "</a></td></tr>";
echo "<tr class='tab_bg_1'><td class='center b'>" . "<a href='ldap.import.php?mode=0&action=show'>" . __('Import new users') . "</a></td> </tr>";
echo "</table></div>";
Html::footer();
开发者ID:jose-martins,项目名称:glpi,代码行数:30,代码来源:ldap.php
示例12: isEntityDirectoryConfigured
static function isEntityDirectoryConfigured($entities_id)
{
$entitydatas = new EntityData();
if ($entitydatas->getFromDB($entities_id) && $entitydatas->getField('authldaps_id') != NOT_AVAILABLE) {
return true;
}
//If there's a directory marked as default
if (AuthLdap::getDefault()) {
return true;
}
return false;
}
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:12,代码来源:entitydata.class.php
示例13: showLDAPForm
function showLDAPForm($target, $ID)
{
global $LANG;
if (!haveRight("group", "r")) {
return false;
}
if ($ID > 0) {
$this->check($ID, 'r');
} else {
// Create item
$this->check(-1, 'w');
}
echo "<form name='groupldap_form' id='groupldap_form' method='post' action='{$target}'>";
echo "<div class='spaced'><table class='tab_cadre_fixe'>";
if (haveRight("config", "r") && AuthLdap::useAuthLdap()) {
echo "<tr class='tab_bg_1'>";
echo "<td colspan='2' class='center'>" . $LANG['setup'][256] . " : </td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['setup'][260] . " : </td>";
echo "<td>";
autocompletionTextField($this, "ldap_field");
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['setup'][601] . " : </td>";
echo "<td>";
autocompletionTextField($this, "ldap_value");
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='2' class='center'>" . $LANG['setup'][257] . " : </td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['setup'][261] . " : </td>";
echo "<td>";
autocompletionTextField($this, "ldap_group_dn");
echo "</td></tr>";
}
$options = array('colspan' => 1, 'candel' => false);
$this->showFormButtons($options);
echo "</table></div></form>";
}
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:40,代码来源:group.class.php
示例14: Auth
}
echo "\n";
}
} else {
echo "No OCS server\n";
}
}
// Check Auth connections
$auth = new Auth();
$auth->getAuthMethods();
$ldap_methods = $auth->authtypes["ldap"];
if (count($ldap_methods)) {
echo "Check LDAP servers:";
foreach ($ldap_methods as $method) {
echo " " . $method['name'];
if (AuthLdap::tryToConnectToServer($method, $method["rootdn"], decrypt($method["rootdn_passwd"], GLPIKEY))) {
echo "_OK";
} else {
echo "_PROBLEM";
$ok = false;
}
echo "\n";
}
} else {
echo "No LDAP server\n";
}
// TODO Check mail server : cannot open a mail connexion / only ping server ?
// TODO check CAS url / check url using socket ?
}
echo "\n";
if ($ok) {
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:status.php
示例15: header
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
if (strpos($_SERVER['PHP_SELF'], "ldapdaterestriction.php")) {
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
if (!defined('GLPI_ROOT')) {
die("Can not acces directly to this file");
}
Session::checkLoginUser();
AuthLdap::showDateRestrictionForm($_POST);
开发者ID:jose-martins,项目名称:glpi,代码行数:29,代码来源:ldapdaterestriction.php
示例16: array
if (isset($_POST["change_auth_method"])) {
Session::checkRight('user', User::UPDATEAUTHENT);
if (isset($_POST["auths_id"])) {
User::changeAuthMethod(array($_POST["id"]), $_POST["authtype"], $_POST["auths_id"]);
}
Html::back();
} else {
if (isset($_GET["ext_auth"])) {
Html::header(User::getTypeName(Session::getPluralNumber()), '', "admin", "user");
User::showAddExtAuthForm();
Html::footer();
} else {
if (isset($_POST['add_ext_auth_ldap'])) {
Session::checkRight("user", User::IMPORTEXTAUTHUSERS);
if (isset($_POST['login']) && !empty($_POST['login'])) {
AuthLdap::importUserFromServers(array('name' => $_POST['login']));
}
Html::back();
} else {
if (isset($_POST['add_ext_auth_simple'])) {
if (isset($_POST['login']) && !empty($_POST['login'])) {
Session::checkRight("user", User::IMPORTEXTAUTHUSERS);
$input = array('name' => $_POST['login'], '_extauth' => 1, 'add' => 1);
$user->check(-1, CREATE, $input);
$newID = $user->add($input);
Event::log($newID, "users", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["login"]));
}
Html::back();
} else {
Session::checkRight("user", READ);
Html::header(User::getTypeName(Session::getPluralNumber()), '', "admin", "user");
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:user.form.php
示例17: methodStatus
/**
* This method return GLPI status (same as status.php)
*
* @param $params array of option : ignored
* @param $protocol the communication protocol used
*
* @return an response ready to be encode
**/
static function methodStatus($params, $protocol)
{
global $DB;
if (isset($params['help'])) {
return array('help' => 'bool,optional');
}
$resp = array();
$ok_master = true;
$ok_slave = true;
$ok = true;
// Check slave server connection
if (DBConnection::isDBSlaveActive()) {
$DBslave = DBConnection::getDBSlaveConf();
if (is_array($DBslave->dbhost)) {
$hosts = $DBslave->dbhost;
} else {
$hosts = array($DBslave->dbhost);
}
foreach ($hosts as $num => $name) {
$diff = DBConnection::getReplicateDelay($num);
if ($diff > 1000000000) {
$resp['slavedb_' . $num] = "offline";
$ok_slave = false;
} else {
if ($diff) {
$resp['slavedb_' . $num] = $diff;
if ($diff > HOUR_TIMESTAMP) {
$ok_slave = false;
}
} else {
$resp['slavedb_' . $num] = "ok";
}
}
}
} else {
$resp['slavedb'] = "not configured";
}
// Check main server connection
if (DBConnection::establishDBConnection(false, true, false)) {
$resp['maindb'] = "ok";
} else {
$resp['slavedb'] = "offline";
$ok_master = false;
}
// Slave and master ok;
$ok = $ok_slave && $ok_master;
// Check session dir (usefull when NFS mounted))
if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) {
$resp['sessiondir'] = "ok";
} else {
$resp['sessiondir'] = "not writable";
$ok = false;
}
// Reestablished DB connection
if (($ok_master || $ok_slave) && DBConnection::establishDBConnection(false, false, false)) {
// Check Auth connections
$auth = new Auth();
$auth->getAuthMethods();
$ldap_methods = $auth->authtypes["ldap"];
if (count($ldap_methods)) {
foreach ($ldap_methods as $method) {
if ($method['is_active']) {
if (AuthLdap::tryToConnectToServer($method, $method["rootdn"], Toolbox::decrypt($method["rootdn_passwd"], GLPIKEY))) {
$resp['LDAP_' . $method['name']] = "ok";
} else {
$resp['LDAP_' . $method['name']] = "offline";
$ok = false;
}
}
}
}
}
if ($ok) {
$resp['glpi'] = "ok";
} else {
$resp['glpi'] = "error";
}
return $resp;
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:87,代码来源:methodcommon.class.php
示例18: AuthLDAP
if ($_SESSION['ldap_import']['action'] == 'show') {
$_REQUEST['target'] = $_SERVER['PHP_SELF'];
$authldap = new AuthLDAP();
$authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
AuthLdap::showUserImportForm($authldap);
if (isset($_SESSION['ldap_import']['authldaps_id']) && $_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && isset($_SESSION['ldap_import']['criterias']) && !empty($_SESSION['ldap_import']['criterias'])) {
echo "<br />";
AuthLdap::searchUser($authldap);
}
} else {
if (isset($_SESSION["ldap_process"])) {
if ($count = count($_SESSION["ldap_process"])) {
$percent = min(100, round(100 * ($_SESSION["ldap_process_count"] - $count) / $_SESSION["ldap_process_count"], 0));
displayProgressBar(400, $percent);
$key = array_pop($_SESSION["ldap_process"]);
AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $key), $_SESSION['ldap_import']["mode"], $_SESSION['ldap_import']["authldaps_id"], true);
glpi_header($_SERVER['PHP_SELF']);
} else {
unset($_SESSION["ldap_process"]);
displayProgressBar(400, 100);
echo "<div class='center b'>" . $LANG['ocsng'][8] . "<br>";
echo "<a href='" . $_SERVER['PHP_SELF'] . "'>" . $LANG['buttons'][13] . "</a></div>";
unset($_SESSION["authldaps_id"]);
unset($_SESSION["mode"]);
unset($_SESSION["interface"]);
$_SESSION['ldap_import']['action'] = 'show';
refreshDropdownPopupInMainWindow();
}
} else {
if (count($_POST['toprocess']) > 0) {
$_SESSION["ldap_process_count"] = 0;
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:ldap.import.php
示例19: import
/**
* Function to import or synchronise all the users from an ldap directory
*
* @param $options array
**/
function import(array $options)
{
global $CFG_GLPI;
$results = array(AuthLDAP::USER_IMPORTED => 0, AuthLDAP::USER_SYNCHRONIZED => 0, AuthLDAP::USER_DELETED_LDAP => 0);
//The ldap server id is passed in the script url (parameter server_id)
$limitexceeded = false;
$actions_to_do = array();
switch ($options['action']) {
case AuthLDAP::ACTION_IMPORT:
$actions_to_do = array(AuthLDAP::ACTION_IMPORT);
break;
case AuthLDAP::ACTION_SYNCHRONIZE:
$actions_to_do = array(AuthLDAP::ACTION_SYNCHRONIZE);
break;
case AuthLDAP::ACTION_ALL:
$actions_to_do = array(AuthLDAP::ACTION_IMPORT, AuthLDAP::ACTION_ALL);
break;
}
foreach ($actions_to_do as $action_to_do) {
$options['mode'] = $action_to_do;
$options['authldaps_id'] = $options['ldapservers_id'];
$users = AuthLdap::getAllUsers($options, $results, $limitexceeded);
$contact_ok = true;
if (is_array($users)) {
foreach ($users as $user) {
$result = AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $user["user"]), $action_to_do, $options['ldapservers_id']);
if ($result) {
$results[$result['action']] += 1;
}
echo ".";
}
} else {
if (!$users) {
$contact_ok = false;
}
}
}
if ($limitexceeded) {
echo "\nLDAP Server size limit exceeded";
if ($CFG_GLPI['user_deleted_ldap']) {
echo ": user deletion disabled\n";
}
echo "\n";
}
if ($contact_ok) {
echo "\nImported: " . $results[AuthLDAP::USER_IMPORTED] . "\n";
echo "Synchronized: " . $results[AuthLDAP::USER_SYNCHRONIZED] . "\n";
echo "Deleted from LDAP: " . $results[AuthLDAP::USER_DELETED_LDAP] . "\n";
} else {
echo "Cannot contact LDAP server!\n";
}
echo "\n\n";
}
开发者ID:jose-martins,项目名称:glpi,代码行数:58,代码来源:ldap_mass_sync.php
示例20: AuthLDAP
if (!defined('GLPI_ROOT')) {
include '../inc/includes.php';
}
Session::checkRight("import_externalauth_users", 'w');
// Need REQUEST to manage initial walues and posted ones
AuthLdap::manageValuesInSession($_REQUEST);
if (isset($_SESSION['ldap_import']['popup']) && $_SESSION['ldap_import']['popup']) {
Html::popHeader(__('LDAP directory link'), $_SERVER['PHP_SELF']);
} else {
Html::header(__('LDAP directory link'), $_SERVER['PHP_SELF'], "admin", "user", "ldap");
}
if (isset($_GET['start'])) {
$_SESSION['ldap_import']['start'] = $_GET['start'];
}
if (isset($_GET['order'])) {
$_SESSION['ldap_import']['order'] = $_GET['order'];
}
if ($_SESSION['ldap_import']['action'] == 'show') {
$authldap = new AuthLDAP();
$authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
AuthLdap::showUserImportForm($authldap);
if (isset($_SESSION['ldap_import']['authldaps_id']) && $_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && isset($_SESSION['ldap_import']['criterias']) && !empty($_SESSION['ldap_import']['criterias'])) {
echo "<br />";
AuthLdap::searchUser($authldap);
}
}
if (isset($_SESSION['ldap_import']['popup']) && $_SESSION['ldap_import']['popup']) {
Html::ajaxFooter();
} else {
Html::footer();
}
开发者ID:gaforeror,项目名称:glpi,代码行数:31,代码来源:ldap.import.php
注:本文中的AuthLdap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论