Commit 094fca51 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5511 Fixed SASL password method (as long as a field from main tab is used)

parent 1698f8f7
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2011-2016 FusionDirectory
Copyright (C) 2011-2017 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -27,37 +27,43 @@
* \brief This class contains all the functions for sasl password methods
* \see passwordMethod
*/
class passwordMethodsasl extends passwordMethod {
class passwordMethodsasl extends passwordMethod
{
// uid, or exop specified field value
var $uid = "";
var $realm = "";
var $exop = "";
var $uid = '';
var $realm = '';
var $exop = '';
/*!
* \brief passwordMethodsasl Constructor
*
* \param string $dn The DN
* \param object $userTab The user main tab object
*/
function __construct($dn = "")
function __construct($dn = '', $userTab = NULL)
{
global $config;
$this->realm = trim($config->get_cfg_value('saslRealm', ''));
$this->exop = trim($config->get_cfg_value('saslExop', ''));
if ($dn == "" || $dn == "new") {
if ($dn == '' || $dn == 'new') {
return;
}
$attr = (empty($this->exop)?'uid':$this->exop);
$attr = (empty($this->exop) ? 'uid' : $this->exop);
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->cat($dn, array($attr));
if ($ldap->count() == 1) {
$attrs = $ldap->fetch();
$this->uid = $attrs[$attr][0];
if (($userTab !== NULL) && isset($userTab->$attr)) {
$this->uid = $userTab->$attr;
} else {
msg_dialog::display(_("Error"), sprintf(_("Cannot change password, unknown user '%s'"), $dn), ERROR_DIALOG);
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->cat($dn, array($attr));
if ($ldap->count() == 1) {
$attrs = $ldap->fetch();
$this->uid = $attrs[$attr][0];
} else {
msg_dialog::display(_('Error'), sprintf(_('Cannot change password, unknown user "%s"'), $dn), ERROR_DIALOG);
}
}
}
......
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003-2010 Cajus Pollmeier
Copyright (C) 2011-2016 FusionDirectory
Copyright (C) 2011-2017 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -32,15 +31,16 @@ class passwordMethod
{
var $attrs = array();
var $display = FALSE;
var $hash = "";
var $hash = '';
var $lockable = TRUE;
/*!
* \brief Password method contructor
*
* \param string $dn The DN
* \param object $userTab The user main tab object
*/
function __construct($dn = "")
function __construct($dn = '', $userTab = NULL)
{
}
......@@ -127,9 +127,9 @@ class passwordMethod
}
/* Get current password hash */
$attrs = $this->attrs;
$pwd = "";
$ldap = $config->get_ldap_link();
$attrs = $this->attrs;
$pwd = '';
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
if (!empty($dn)) {
$ldap->cat($dn);
......
......@@ -200,7 +200,7 @@ class UserPasswordAttribute extends CompositeAttribute
trigger_error('Unknown password method '.$values[0]);
return $values[3];
}
$test = new $temp[$values[0]]($this->plugin->dn);
$test = new $temp[$values[0]]($this->plugin->dn, $this->plugin);
$test->set_hash($values[0]);
if ($this->plugin->is_template) {
return $test->generate_hash($values[1]).'|'.$values[1];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment