Get LDAP fields to sync to GLPI data from a glpi_authldaps array
static public getSyncFields ( array $authtype_array ) : array | ||
$authtype_array | array | array Authentication method config array (from table) |
return | array | of "user table field name" => "config value" |
function pre_updateInDB() { global $DB; if (($key = array_search('name', $this->updates)) !== false) { /// Check if user does not exists $query = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `name` = '" . $this->input['name'] . "'\n AND `id` <> '" . $this->input['id'] . "';"; $result = $DB->query($query); if ($DB->numrows($result) > 0) { //To display a message $this->fields['name'] = $this->oldvalues['name']; unset($this->updates[$key]); unset($this->oldvalues['name']); Session::addMessageAfterRedirect(__('Unable to update login. A user already exists.'), false, ERROR); } } /// Security system except for login update if (Session::getLoginUserID() && !Session::haveRight("user", "w") && !strpos($_SERVER['PHP_SELF'], "login.php")) { if (Session::getLoginUserID() === $this->input['id']) { if (isset($this->fields["authtype"])) { // extauth ldap case if ($_SESSION["glpiextauth"] && ($this->fields["authtype"] == Auth::LDAP || Auth::isAlternateAuth($this->fields["authtype"]))) { $authtype = Auth::getMethodsByID($this->fields["authtype"], $this->fields["auths_id"]); if (count($authtype)) { $fields = AuthLDAP::getSyncFields($authtype); foreach ($fields as $key => $val) { if (!empty($val) && ($key2 = array_search($key, $this->updates)) !== false) { unset($this->updates[$key2]); unset($this->oldvalues[$key]); } } } } if (($key = array_search("is_active", $this->updates)) !== false) { unset($this->updates[$key]); unset($this->oldvalues['is_active']); } if (($key = array_search("comment", $this->updates)) !== false) { unset($this->updates[$key]); unset($this->oldvalues['comment']); } } } } }