本文整理汇总了PHP中AuthLDAP类的典型用法代码示例。如果您正苦于以下问题:PHP AuthLDAP类的具体用法?PHP AuthLDAP怎么用?PHP AuthLDAP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AuthLDAP类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getAvailableValues
public function getAvailableValues()
{
if (!empty($this->fields['values'])) {
$ldap_values = json_decode($this->fields['values']);
$ldap_dropdown = new RuleRightParameter();
if (!$ldap_dropdown->getFromDB($ldap_values->ldap_attribute)) {
return array();
}
$attribute = array($ldap_dropdown->fields['value']);
$config_ldap = new AuthLDAP();
if (!$config_ldap->getFromDB($ldap_values->ldap_auth)) {
return array();
}
if (!function_exists('warning_handler')) {
function warning_handler($errno, $errstr, $errfile, $errline, array $errcontext)
{
if (0 === error_reporting()) {
return false;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
}
set_error_handler("warning_handler", E_WARNING);
try {
$tab_values = array();
$ds = $config_ldap->connect();
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$cookie = '';
do {
if (AuthLDAP::isLdapPageSizeAvailable($config_ldap)) {
ldap_control_paged_result($ds, $config_ldap->fields['pagesize'], true, $cookie);
}
$result = ldap_search($ds, $config_ldap->fields['basedn'], $ldap_values->ldap_filter, $attribute);
$entries = ldap_get_entries($ds, $result);
array_shift($entries);
foreach ($entries as $id => $attr) {
if (isset($attr[$attribute[0]]) && !in_array($attr[$attribute[0]][0], $tab_values)) {
$tab_values[$id] = $attr[$attribute[0]][0];
}
}
if (AuthLDAP::isLdapPageSizeAvailable($config_ldap)) {
ldap_control_paged_result_response($ds, $result, $cookie);
}
} while ($cookie !== null && $cookie != '');
if ($this->fields['show_empty']) {
$tab_values = array('' => '-----') + $tab_values;
}
asort($tab_values);
return $tab_values;
} catch (Exception $e) {
return array();
}
restore_error_handler();
} else {
return array();
}
}
开发者ID:CHCI74,项目名称:formcreator,代码行数:57,代码来源:ldapselect-field.class.php
示例2: getAdditionalMenuOptions
/**
* @see CommonGLPI::getAdditionalMenuOptions()
*
* @since version 0.85
**/
static function getAdditionalMenuOptions()
{
if (Session::haveRight('user', User::UPDATEAUTHENT)) {
$options['ldap']['title'] = AuthLDAP::getTypeName(Session::getPluralNumber());
$options['ldap']['page'] = "/front/ldap.group.php";
return $options;
}
return false;
}
开发者ID:korial29,项目名称:glpi,代码行数:14,代码来源:group.class.php
示例3: showAdvancedOptions
/**
* @since version 0.84 (before in entitydata.class)
*
* @param $entity Entity object
**/
static function showAdvancedOptions(Entity $entity)
{
global $DB;
$con_spotted = false;
$ID = $entity->getField('id');
if (!$entity->can($ID, READ)) {
return false;
}
// Entity right applied (could be User::UPDATEAUTHENT)
$canedit = $entity->can($ID, UPDATE);
if ($canedit) {
echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>" . __('Values for the generic rules for assignment to entities') . "</th></tr>";
echo "<tr class='tab_bg_1'><td colspan='2' class='center'>" . __('These parameters are used as actions in generic rules for assignment to entities') . "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Information in inventory tool (TAG) representing the entity') . "</td>";
echo "<td>";
Html::autocompletionTextField($entity, "tag", array('size' => 100));
echo "</td></tr>";
if (Toolbox::canUseLdap()) {
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('LDAP directory information attribute representing the entity') . "</td>";
echo "<td>";
Html::autocompletionTextField($entity, "ldap_dn", array('size' => 100));
echo "</td></tr>";
}
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Mail domain surrogates entity') . "</td>";
echo "<td>";
Html::autocompletionTextField($entity, "mail_domain", array('size' => 100));
echo "</td></tr>";
if (Toolbox::canUseLdap()) {
echo "<tr><th colspan='2'>" . __('Values used in the interface to search users from a LDAP directory') . "</th></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('LDAP directory of an entity') . "</td>";
echo "<td>";
AuthLDAP::dropdown(array('value' => $entity->fields['authldaps_id'], 'emptylabel' => __('Default server'), 'condition' => "`is_active` = '1'"));
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('LDAP filter associated to the entity (if necessary)') . "</td>";
echo "<td>";
Html::autocompletionTextField($entity, 'entity_ldapfilter', array('size' => 100));
echo "</td></tr>";
}
if ($canedit) {
echo "<tr>";
echo "<td class='tab_bg_2 center' colspan='2'>";
echo "<input type='hidden' name='id' value='" . $entity->fields["id"] . "'>";
echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
} else {
echo "</table>";
}
}
开发者ID:korial29,项目名称:glpi,代码行数:63,代码来源:entity.class.php
示例4: getAllDatasFromTable
// Check session dir (usefull when NFS mounted))
if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) {
echo "GLPI_SESSION_DIR_OK\n";
} else {
echo "GLPI_SESSION_DIR_PROBLEM\n";
$ok = false;
}
// Reestablished DB connection
if (($ok_master || $ok_slave) && DBConnection::establishDBConnection(false, false, false)) {
// Check LDAP Auth connections
$ldap_methods = getAllDatasFromTable('glpi_authldaps', '`is_active`=1');
if (count($ldap_methods)) {
echo "Check LDAP servers:";
foreach ($ldap_methods as $method) {
echo " " . $method['name'];
if (AuthLDAP::tryToConnectToServer($method, $method["rootdn"], Toolbox::decrypt($method["rootdn_passwd"], GLPIKEY))) {
echo "_OK";
} else {
echo "_PROBLEM";
$ok = false;
}
echo "\n";
}
} else {
echo "No LDAP server\n";
}
// Check IMAP Auth connections
$imap_methods = getAllDatasFromTable('glpi_authmails', '`is_active`=1');
if (count($imap_methods)) {
echo "Check IMAP servers:";
foreach ($imap_methods as $method) {
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:status.php
示例5: checkBeforeSave
/**
* Validate form fields before add or update a question
*
* @param Array $input Datas used to add the item
*
* @return Array The modified $input array
*
* @param [type] $input [description]
* @return [type] [description]
*/
private function checkBeforeSave($input)
{
// Control fields values :
// - name is required
if (empty($input['name'])) {
Session::addMessageAfterRedirect(__('The title is required', 'formcreator'), false, ERROR);
return array();
}
// - field type is required
if (empty($input['fieldtype'])) {
Session::addMessageAfterRedirect(__('The field type is required', 'formcreator'), false, ERROR);
return array();
}
// - section is required
if (empty($input['plugin_formcreator_sections_id'])) {
Session::addMessageAfterRedirect(__('The section is required', 'formcreator'), false, ERROR);
return array();
}
// Values are required for GLPI dropdowns, dropdowns, multiple dropdowns, checkboxes, radios, LDAP
$itemtypes = array('select', 'multiselect', 'checkboxes', 'radios', 'ldap');
if (empty($input['values']) && in_array($input['fieldtype'], $itemtypes)) {
Session::addMessageAfterRedirect(__('The field value is required:', 'formcreator') . ' ' . $input['name'], false, ERROR);
return array();
}
// Fields are differents for dropdown lists, so we need to replace these values into the good ones
if ($input['fieldtype'] == 'dropdown') {
if (empty($input['dropdown_values'])) {
Session::addMessageAfterRedirect(__('The field value is required:', 'formcreator') . ' ' . $input['name'], false, ERROR);
return array();
}
$input['values'] = $input['dropdown_values'];
$input['default_values'] = isset($input['dropdown_default_value']) ? $input['dropdown_default_value'] : '';
}
// Fields are differents for GLPI object lists, so we need to replace these values into the good ones
if ($input['fieldtype'] == 'glpiselect') {
if (empty($input['glpi_objects'])) {
Session::addMessageAfterRedirect(__('The field value is required:', 'formcreator') . ' ' . $input['name'], false, ERROR);
return array();
}
$input['values'] = $input['glpi_objects'];
$input['default_values'] = isset($input['dropdown_default_value']) ? $input['dropdown_default_value'] : '';
}
// A description field should have a description
if ($input['fieldtype'] == 'description' && empty($input['description'])) {
Session::addMessageAfterRedirect(__('A description field should have a description:', 'formcreator') . ' ' . $input['name'], false, ERROR);
return array();
}
// format values for numbers
if ($input['fieldtype'] == 'integer' || $input['fieldtype'] == 'float') {
$input['default_values'] = !empty($input['default_values']) ? (double) str_replace(',', '.', $input['default_values']) : null;
$input['range_min'] = !empty($input['range_min']) ? (double) str_replace(',', '.', $input['range_min']) : null;
$input['range_max'] = !empty($input['range_max']) ? (double) str_replace(',', '.', $input['range_max']) : null;
}
// LDAP fields validation
if ($input['fieldtype'] == 'ldapselect') {
// Fields are differents for dropdown lists, so we need to replace these values into the good ones
if (!empty($input['ldap_auth'])) {
$config_ldap = new AuthLDAP();
$config_ldap->getFromDB($input['ldap_auth']);
$ldap_dropdown = new RuleRightParameter();
$ldap_dropdown->getFromDB($input['ldap_attribute']);
$attribute = array($ldap_dropdown->fields['value']);
// Set specific error handler too catch LDAP errors
if (!function_exists('warning_handler')) {
function warning_handler($errno, $errstr, $errfile, $errline, array $errcontext)
{
if (0 === error_reporting()) {
return false;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
}
set_error_handler("warning_handler", E_WARNING);
try {
$ds = $config_ldap->connect();
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_control_paged_result($ds, 1);
$sn = ldap_search($ds, $config_ldap->fields['basedn'], $input['ldap_filter'], $attribute);
$entries = ldap_get_entries($ds, $sn);
} catch (Exception $e) {
Session::addMessageAfterRedirect(__('Cannot recover LDAP informations!', 'formcreator'), false, ERROR);
}
restore_error_handler();
$input['values'] = json_encode(array('ldap_auth' => $input['ldap_auth'], 'ldap_filter' => $input['ldap_filter'], 'ldap_attribute' => strtolower($input['ldap_attribute'])));
}
}
// Add leading and trailing regex marker automaticaly
if (!empty($input['regex'])) {
if (substr($input['regex'], 0, 1) != '/') {
if (substr($input['regex'], 0, 1) != '^') {
//.........这里部分代码省略.........
开发者ID:CHCI74,项目名称:formcreator,代码行数:101,代码来源:question.class.php
示例6: searchUser
static function searchUser(AuthLDAP $authldap)
{
global $LANG;
if (self::connectToServer($authldap->getField('host'), $authldap->getField('port'), $authldap->getField('rootdn'), decrypt($authldap->getField('rootdn_passwd'), GLPIKEY), $authldap->getField('use_tls'), $authldap->getField('deref_option'))) {
self::showLdapUsers();
} else {
echo "<div class='center b'>" . $LANG['ldap'][6] . "<br>";
}
}
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:9,代码来源:authldap.class.php
示例7: showLdapDebug
/**
* Display information from LDAP server for user
**/
private function showLdapDebug()
{
if ($this->fields['authtype'] != Auth::LDAP) {
return false;
}
echo "<div class='spaced'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='4'>" . __('LDAP directory') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>" . __('User DN') . "</td>";
echo "<td>" . $this->fields['user_dn'] . "</td></tr>\n";
if ($this->fields['user_dn']) {
echo "<tr class='tab_bg_2'><td>" . __('User information') . "</td><td>";
$config_ldap = new AuthLDAP();
$ds = false;
if ($config_ldap->getFromDB($this->fields['auths_id'])) {
$ds = $config_ldap->connect();
}
if ($ds) {
$info = AuthLdap::getUserByDn($ds, $this->fields['user_dn'], array('*', 'createTimeStamp', 'modifyTimestamp'));
if (is_array($info)) {
Html::printCleanArray($info);
} else {
_e('No item to display');
}
} else {
_e('Connection failed');
}
echo "</td></tr>\n";
}
echo "</table></div>";
}
开发者ID:geldarr,项目名称:hack-space,代码行数:34,代码来源:user.class.php
示例8: getMenuContent
/**
* @see CommonGLPI::getMenuContent()
*
* @since version 0.85
**/
static function getMenuContent()
{
$menu = array();
if (Config::canUpdate()) {
$menu['title'] = __('Authentication');
$menu['page'] = '/front/setup.auth.php';
$menu['options']['ldap']['title'] = AuthLDAP::getTypeName(Session::getPluralNumber());
$menu['options']['ldap']['page'] = '/front/authldap.php';
$menu['options']['ldap']['links']['search'] = '/front/authldap.php';
$menu['options']['ldap']['links']['add'] = '' . '/front/authldap.form.php';
$menu['options']['imap']['title'] = AuthMail::getTypeName(Session::getPluralNumber());
$menu['options']['imap']['page'] = '/front/authmail.php';
$menu['options']['imap']['links']['search'] = '/front/authmail.php';
$menu['options']['imap']['links']['add'] = '' . '/front/authmail.form.php';
$menu['options']['others']['title'] = __('Others');
$menu['options']['others']['page'] = '/front/auth.others.php';
$menu['options']['settings']['title'] = __('Setup');
$menu['options']['settings']['page'] = '/front/auth.settings.php';
}
if (count($menu)) {
return $menu;
}
return false;
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:29,代码来源:auth.class.php
示例9: define
// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
header_nocache();
if (!isset($_POST['id'])) {
exit;
}
if (!isset($_REQUEST['glpi_tab'])) {
exit;
}
checkRight('config', 'r');
$authldap = new AuthLDAP();
if ($_POST['id'] > 0 && $authldap->can($_POST['id'], 'r')) {
switch ($_REQUEST['glpi_tab']) {
case -1:
$authldap->showFormUserConfig($_POST['id'], $_POST['target']);
$authldap->showFormGroupsConfig($_POST['id'], $_POST['target']);
$authldap->showFormAdvancedConfig($_POST['id'], $_POST['target']);
$authldap->showFormReplicatesConfig($_POST['id'], $_POST['target']);
Log::showForItem($authldap);
break;
case 2:
$authldap->showFormUserConfig($_POST['id'], $_POST['target']);
break;
case 3:
$authldap->showFormGroupsConfig($_POST['id'], $_POST['target']);
break;
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:authldap.tabs.php
示例10: Config
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("config", UPDATE);
$config = new Config();
$config_ldap = new AuthLDAP();
if (!isset($_GET['id'])) {
$_GET['id'] = "";
}
//LDAP Server add/update/delete
if (isset($_POST["update"])) {
$config_ldap->update($_POST);
Html::back();
} else {
if (isset($_POST["add"])) {
//If no name has been given to this configuration, then go back to the page without adding
if ($_POST["name"] != "") {
if ($newID = $config_ldap->add($_POST)) {
if (AuthLdap::testLDAPConnection($newID)) {
Session::addMessageAfterRedirect(__('Test successful'));
} else {
开发者ID:glpi-project,项目名称:glpi,代码行数:31,代码来源:authldap.form.php
示例11: header
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
*/
$AJAX_INCLUDE = 1;
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkRight('user', User::UPDATEAUTHENT);
if ($_POST["authtype"] > 0) {
$name = 'massiveaction';
if (isset($_POST['name'])) {
$name = $_POST['name'];
}
switch ($_POST["authtype"]) {
case Auth::DB_GLPI:
echo "<input type='hidden' name='auths_id' value='0'>";
break;
case Auth::LDAP:
case Auth::EXTERNAL:
AuthLDAP::dropdown(array('name' => "auths_id", 'condition' => "`is_active` = 1"));
break;
case Auth::MAIL:
AuthMail::dropdown(array('name' => "auths_id", 'condition' => "`is_active` = 1"));
break;
}
echo " <input type='submit' name='{$name}' class='submit' value=\"" . _sx('button', 'Post') . "\">";
}
开发者ID:glpi-project,项目名称:glpi,代码行数:31,代码来源:dropdownMassiveActionAuthMethods.php
示例12: plugin_moreldap_item_add_or_update_user
function plugin_moreldap_item_add_or_update_user($user)
{
//Ignore users without auths_id
if (!isset($user->input["auths_id"])) {
return;
}
// We update LDAP field only if LDAP directory is defined
if (isset($user->input["locations_id"])) {
return;
}
// default : store locations outside of any entity
$entityID = -1;
$pluginAuthLDAP = new PluginMoreldapAuthLDAP();
$authsId = isset($user->input["auths_id"]) ? $user->input["auths_id"] : $user->fields["auths_id"];
if ($authsId > 0 && $pluginAuthLDAP->getFromDBByQuery("WHERE `id`='{$authsId}'")) {
// The target entity for the locations to be created
$entityID = $pluginAuthLDAP->fields['entities_id'];
// find from config all attributes to read from LDAP
$fields = array();
$locationHierarchy = explode('>', $pluginAuthLDAP->fields['location']);
foreach ($locationHierarchy as $locationSubAttribute) {
$locationSubAttribute = trim($locationSubAttribute);
if (strlen($locationSubAttribute) > 0) {
$fields[] = $locationSubAttribute;
}
}
// LDAP query to read the needed attributes for the user
$ldap_connection = 0;
if (!isset($user->input["_ldap_conn"]) || !isset($user->fields["_ldap_conn"])) {
$ldap = new AuthLDAP();
$ldap->getFromDB($authsId);
$ldap_connection = $ldap->connect();
} else {
$ldap_connection = isset($user->input["_ldap_conn"]) ? $user->input["_ldap_conn"] : $user->fields["_ldap_conn"];
}
$userdn = isset($user->input["user_dn"]) ? $user->input["user_dn"] : $user->fields["user_dn"];
$userdn = str_replace('\\\\', '\\', $userdn);
$sr = @ldap_read($ldap_connection, $userdn, "objectClass=*", $fields);
if (!is_resource($sr) || ldap_errno($ldap_connection) > 0) {
return;
}
$v = AuthLDAP::get_entries_clean($ldap_connection, $sr);
//Find all locations needed to create the deepest one
$locationPath = array();
$incompleteLocation = false;
foreach ($fields as $locationSubAttribute) {
$locationSubAttribute = strtolower($locationSubAttribute);
if (isset($v[0][$locationSubAttribute][0])) {
$locationPath[] = $v[0][$locationSubAttribute][0];
} else {
// A LDAP attribute is not defined for the user. Cannot build the completename
// Therefore we must giveup importing this location
$incompleteLocation = true;
}
}
// TODO : test if location import is enabled earlier in this function
if ($pluginAuthLDAP->fields['location_enabled'] == 'Y') {
if ($incompleteLocation == false) {
$location = new Location();
$locationAncestor = 0;
$locationCompleteName = array();
$allLocationsExist = true;
// Assume we created or found all locations
// while ($locatinItem = array_shift($locationPath) && $allLocationsExist) {
foreach ($locationPath as $locationItem) {
if ($allLocationsExist) {
$locationCompleteName[] = $locationItem;
$locationItem = Toolbox::addslashes_deep(array('entities_id' => $entityID, 'name' => $locationItem, 'locations_id' => $locationAncestor, 'completename' => implode(' > ', $locationCompleteName), 'is_recursive' => $pluginAuthLDAP->fields['is_recursive'], 'comment' => __("Created by MoreLDAP", "moreldap")));
$locationAncestor = $location->findID($locationItem);
if ($locationAncestor == -1) {
// The location does not exists yet
$locationAncestor = $location->add($locationItem);
}
if ($locationAncestor == false) {
// If a location could not be imported and does not exist
// then give up importing children items
$allLocationsExist = false;
}
}
}
if ($allLocationsExist) {
// All locations exist to match the path described un LDAP
$locations_id = $locationAncestor;
$myuser = new User();
// new var to prevent user->input erasing (object are always passed by "reference")
$myuser->update(array('id' => $user->getID(), 'locations_id' => $locations_id));
}
}
} else {
// If the location retrieval is disabled, enablig this line will erase the location for the user.
// $fields['locations_id'] = 0;
}
}
}
开发者ID:pluginsGLPI,项目名称:moreldap,代码行数:94,代码来源:hook.php
示例13: Copyright
based on GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2014 by the INDEPNET Development Team.
-------------------------------------------------------------------------
LICENSE
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
*/
include '../inc/includes.php';
Session::checkRight("config", READ);
Html::header(AuthLDAP::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], 'config', 'auth', 'ldap');
Search::show('AuthLDAP');
Html::footer();
开发者ID:kipman,项目名称:glpi,代码行数:31,代码来源:authldap.php
示例14: Copyright
Copyright (C) 2003-2013 by the INDEPNET Development Team.
http://indepnet.net/ http://glpi-project.org
-------------------------------------------------------------------------
LICENSE
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
*/
include '../inc/includes.php';
Session::checkRight("config", "r");
Html::header(AuthLDAP::getTypeName(2), $_SERVER['PHP_SELF'], 'config', 'extauth', 'ldap');
Search::show('AuthLDAP');
Html::footer();
开发者ID:gaforeror,项目名称:glpi,代码行数:31,代码来源:authldap.php
示例15: addMessageAfterRedirect
addMessageAfterRedirect($LANG['login'][22]);
} else {
addMessageAfterRedirect($LANG['login'][23], false, ERROR);
}
glpi_header($CFG_GLPI["root_doc"] . "/front/authldap.php?next=extauth_ldap&id=" . $newID);
}
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["delete"])) {
$config_ldap->delete($_POST);
$_SESSION['glpi_authconfig'] = 1;
$config_ldap->redirectToList();
} else {
if (isset($_POST["test_ldap"])) {
$ldap = new AuthLDAP();
$ldap->getFromDB($_POST["id"]);
if (AuthLdap::testLDAPConnection($_POST["id"])) {
$_SESSION["LDAP_TEST_MESSAGE"] = $LANG['login'][22] . " (" . $LANG['ldap'][21] . " : " . $ldap->fields["name"] . ")";
} else {
$_SESSION["LDAP_TEST_MESSAGE"] = $LANG['login'][23] . " (" . $LANG['ldap'][21] . " : " . $ldap->fields["name"] . ")";
}
glpi_header($_SERVER['HTTP_REFERER']);
} else {
if (isset($_POST["test_ldap_replicate"])) {
foreach ($_POST["test_ldap_replicate"] as $replicate_id => $value) {
$replicate = new AuthLdapReplicate();
$replicate->getFromDB($replicate_id);
if (AuthLdap::testLDAPConnection($_POST["id"], $replicate_id)) {
$_SESSION["LDAP_TEST_MESSAGE"] = $LANG['login'][22] . " (" . $LANG['ldap'][19] . " : " . $replicate->fields["name"] . ")";
} else {
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:authldap.form.php
示例16: displayValue
public static function displayValue($value, $values)
{
if (!empty($values)) {
$ldap_values = json_decode($values);
$ldap_dropdown = new RuleRightParameter();
$ldap_dropdown->getFromDB($ldap_values->ldap_attribute);
$attribute = array($ldap_dropdown->fields['value']);
$config_ldap = new AuthLDAP();
$config_ldap->getFromDB($ldap_values->ldap_auth);
$ds = $config_ldap->connect();
$sn = ldap_search($ds, $config_ldap->fields['basedn'], $ldap_values->ldap_filter, $attribute);
$entries = ldap_get_entries($ds, $sn);
array_shift($entries);
$tab_values = array();
foreach ($entries as $id => $attr) {
if (isset($attr[$attribute[0]]) && !in_array($attr[$attribute[0]][0], $tab_values)) {
$tab_values[$id] = $attr[$attribute[0]][0];
}
}
sort($tab_values);
}
return $value != '' ? $tab_values[$value] : '';
}
开发者ID:nicholaseduardo,项目名称:formcreator,代码行数:23,代码来源:ldapselect-field.class.php
示例17: searchUser
/**
* @param $authldap AuthLDAP object
**/
static function searchUser(AuthLDAP $authldap)
{
if (self::connectToServer($authldap->getField('host'), $authldap->getField('port'), $authldap->getField('rootdn'), Toolbox::decrypt($authldap->getField('rootdn_passwd'), GLPIKEY), $authldap->getField('use_tls'), $authldap->getField('deref_option'))) {
self::showLdapUsers();
} else {
echo "<div class='center b firstbloc'>" . __('Unable to connect to the LDAP directory');
}
}
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:11,代码来源:authldap.class.php
示例18: update0803to083
//.........这里部分代码省略.........
$migration->addField("glpi_users", "personal_token_date", "datetime");
$migration->addField("glpi_tickets", "is_deleted", "bool");
$migration->addKey("glpi_tickets", "is_deleted");
$migration->addField("glpi_contracts", "template_name", 'string');
$migration->addField("glpi_contracts", "is_template", 'bool');
$migration->displayMessage(sprintf(__('Change of the database layout - %s'), 'Give consumable to groups'));
if ($migration->addField("glpi_consumables", "itemtype", "VARCHAR(100) DEFAULT NULL", array("after" => "date_out", "update" => "'User'"))) {
$migration->dropKey("glpi_consumables", 'users_id');
$migration->changeField("glpi_consumables", 'users_id', 'items_id', 'integer');
$migration->addKey("glpi_consumables", array('itemtype', 'items_id'), 'item');
}
$migration->displayMessage(sprintf(__('Change of the database layout - %s'), 'Several emails for users'));
// Several email per users
if (!TableExists('glpi_useremails')) {
$query = "CREATE TABLE `glpi_useremails` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `users_id` int(11) NOT NULL DEFAULT '0',\n `is_default` TINYINT( 1 ) NOT NULL DEFAULT 0,\n `is_dynamic` TINYINT( 1 ) NOT NULL DEFAULT 0,\n `email` varchar( 255 ) NULL DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `unicity` (`users_id`,`email`),\n KEY `email` (`email`),\n KEY `is_default` (`is_default`),\n KEY `is_dynamic` (`is_dynamic`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
$DB->queryOrDie($query, "0.83 add table glpi_useremails");
}
// Manage migration : populate is_default=1
// and is_dynamic depending of authldap config / authtype / auths_id
if (FieldExists("glpi_users", 'email', false)) {
$query = "SELECT *\n FROM `glpi_users`\n WHERE `email` <> '' AND `email` IS NOT NULL";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) > 0) {
while ($data = $DB->fetch_assoc($result)) {
$is_dynamic = 0;
$ldap_servers = array();
// manage is_dynamic :
if ($data['authtype'] == Auth::MAIL) {
$is_dynamic = 1;
} else {
if (Auth::isAlternateAuth($data["authtype"]) && $data['auths_id'] > 0 || $data['authtype'] == Auth::LDAP) {
if (!isset($ldap_servers[$data['auths_id']])) {
$ldap_servers[$data['auths_id']] = 0;
$ldap = new AuthLDAP();
if ($ldap->getFromDB($data['auths_id'])) {
if (!empty($ldap->fields['email_field'])) {
$ldap_servers[$data['auths_id']] = 1;
}
}
}
$is_dynamic = $ldap_servers[$data['auths_id']];
}
}
$query2 = "INSERT INTO `glpi_useremails`\n (`users_id`, `is_default`, `is_dynamic`, `email`)\n VALUES ('" . $data['id'] . "','1','{$is_dynamic}','" . addslashes($data['email']) . "')";
$DB->queryOrDie($query2, "0.83 move emails to glpi_useremails");
}
}
}
// Drop email field from glpi_users
$migration->dropField("glpi_users", 'email');
}
// check unicity for users email : unset rule and display warning
foreach ($DB->request("glpi_fieldunicities", "`itemtype` = 'User' AND `fields` LIKE '%email%'") as $data) {
$query = "UPDATE `glpi_fieldunicities`\n SET `is_active` = '0'\n WHERE `id` = '" . $data['id'] . "'";
$DB->query($query);
echo "<div class='red'><p>A unicity check use email for users. ";
echo "Due to new feature permit several email per users, this rule have been disabled.</p></div>";
}
// multiple manager in groups
$migration->changeField("glpi_authldaps", 'email_field', 'email1_field', 'string');
$migration->addField("glpi_authldaps", 'email2_field', 'string');
$migration->addField("glpi_authldaps", 'email3_field', 'string');
$migration->addField("glpi_authldaps", 'email4_field', 'string');
$migration->displayMessage(sprintf(__('Change of the database layout - %s'), 'Multiple managers for groups'));
/// migration : multiple group managers
$migration->addField("glpi_groups_users", "is_manager", 'bool');
开发者ID:btry,项目名称:glpi,代码行数:67,代码来源:update_0803_083.php
示例19: prepareInputDataForProcess
/**
* Get the attributes needed for processing the rules
*
* @see RuleCollection::prepareInputDataForProcess()
*
* @param $input input datas
* @param $params extra parameters given
*
* @return an array of attributes
**/
function prepareInputDataForProcess($input, $params)
{
$rule_parameters = array();
//LDAP type method
if ($params["type"] == "LDAP") {
//Get all the field to retrieve to be able to process rule matching
$rule_fields = $this->getFieldsToLookFor();
//Get all the datas we need from ldap to process the rules
$sz = @ldap_read($params["connection"], $params["userdn"], "objectClass=*", $rule_fields);
$rule_input = AuthLDAP::get_entries_clean($params["connection"], $sz);
if (count($rule_input)) {
if (isset($input)) {
$groups = $input;
} else {
$groups = array();
}
$rule_input = $rule_input[0];
//Get all the ldap fields
$fields = $this->getFieldsForQuery();
foreach ($fields as $field) {
switch (Toolbox::strtoupper($field)) {
case "LDAP_SERVER":
$rule_parameters["LDAP_SERVER"] = $params["ldap_server"];
break;
|
请发表评论