Commit fb8cfd6b authored by Côme Bernigaud's avatar Côme Bernigaud Committed by Benoit Mortier
Browse files

Fixes #4043 SASL method is only available if configuration is filled

Showing with 12 additions and 9 deletions
+12 -9
...@@ -41,16 +41,13 @@ class passwordMethodsasl extends passwordMethod { ...@@ -41,16 +41,13 @@ class passwordMethodsasl extends passwordMethod {
*/ */
function __construct($config, $dn = "") function __construct($config, $dn = "")
{ {
$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; return;
} }
$this->realm = trim($config->get_cfg_value('saslRealm', ""));
$this->exop = trim($config->get_cfg_value('saslExop', ""));
if (empty($this->realm) && empty($this->exop)) {
msg_dialog::display(_("Error"), msgPool::cmdnotfound("saslRealm or saslExop", _("SASL")), ERROR_DIALOG);
}
$attr = (empty($this->exop)?'uid':$this->exop); $attr = (empty($this->exop)?'uid':$this->exop);
$ldap = $config->get_ldap_link(); $ldap = $config->get_ldap_link();
...@@ -71,6 +68,9 @@ class passwordMethodsasl extends passwordMethod { ...@@ -71,6 +68,9 @@ class passwordMethodsasl extends passwordMethod {
*/ */
function is_available() function is_available()
{ {
if (empty($this->realm) && empty($this->exop)) {
return FALSE;
}
return TRUE; return TRUE;
} }
...@@ -82,9 +82,12 @@ class passwordMethodsasl extends passwordMethod { ...@@ -82,9 +82,12 @@ class passwordMethodsasl extends passwordMethod {
function generate_hash($pwd) function generate_hash($pwd)
{ {
if (empty($this->exop)) { if (empty($this->exop)) {
return "{SASL}".$this->uid."@".$this->realm; if (empty($this->realm)) {
msg_dialog::display(_('Error'), _('You need to fill saslRealm or saslExop in the configuration screen in order to use SASL'), ERROR_DIALOG);
}
return '{SASL}'.$this->uid.'@'.$this->realm;
} else { } else {
return "{SASL}".$this->uid; // may not be the uid, see saslExop option return '{SASL}'.$this->uid; // may not be the uid, see saslExop option
} }
} }
...@@ -99,7 +102,7 @@ class passwordMethodsasl extends passwordMethod { ...@@ -99,7 +102,7 @@ class passwordMethodsasl extends passwordMethod {
*/ */
static function get_hash_name() static function get_hash_name()
{ {
return "sasl"; return 'sasl';
} }
/*! /*!
......
  • bmortier @bmortier

    mentioned in issue #1335 (closed)

    By Jonathan Swaelens on 2017-09-02T15:22:38 (imported from GitLab)

    ·

    mentioned in issue #1335 (closed)

    By Jonathan Swaelens on 2017-09-02T15:22:38 (imported from GitLab)

    Toggle commit list
Supports Markdown
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