FusionDirectory
 All Data Structures Files Functions Variables
class_password-methods-sasl.inc
Go to the documentation of this file.
1 <?php
2 /*
3  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
4  Copyright (C) 2011-2017 FusionDirectory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20 
31 {
32  // uid, or exop specified field value
33  var $uid = '';
34  var $realm = '';
35  var $exop = '';
36 
43  function __construct($dn = '', $userTab = NULL)
44  {
45  global $config;
46  $this->realm = trim($config->get_cfg_value('saslRealm', ''));
47  $this->exop = trim($config->get_cfg_value('saslExop', ''));
48 
49  if ($dn == '' || $dn == 'new') {
50  return;
51  }
52 
53  $attr = (empty($this->exop) ? 'uid' : $this->exop);
54 
55  if (($userTab !== NULL) && isset($userTab->$attr)) {
56  $this->uid = $userTab->$attr;
57  } else {
58  $ldap = $config->get_ldap_link();
59  $ldap->cd($config->current['BASE']);
60  $ldap->cat($dn, array($attr));
61  if ($ldap->count() == 1) {
62  $attrs = $ldap->fetch();
63  $this->uid = $attrs[$attr][0];
64  } else {
65  msg_dialog::display(_('Error'), sprintf(_('Cannot change password, unknown user "%s"'), $dn), ERROR_DIALOG);
66  }
67  }
68  }
69 
75  function is_available()
76  {
77  if (empty($this->realm) && empty($this->exop)) {
78  return FALSE;
79  }
80  return TRUE;
81  }
82 
88  function generate_hash($pwd)
89  {
90  if (empty($this->exop)) {
91  if (empty($this->realm)) {
92  msg_dialog::display(_('Error'), _('You need to fill saslRealm or saslExop in the configuration screen in order to use SASL'), ERROR_DIALOG);
93  }
94  return '{SASL}'.$this->uid.'@'.$this->realm;
95  } else {
96  // may not be the uid, see saslExop option
97  return '{SASL}'.$this->uid;
98  }
99  }
100 
101  function checkPassword($pwd, $hash)
102  {
103  // We do not store passwords, can’t know if they’re the same
104  return FALSE;
105  }
106 
110  static function get_hash_name()
111  {
112  return 'sasl';
113  }
114 
120  function need_password()
121  {
122  global $config;
123  return ($config->get_cfg_value('forceSaslPasswordAsk', 'FALSE') == 'TRUE');
124  }
125 }
126 ?>
generate_hash($pwd)
Generate template hash.
__construct($dn= '', $userTab=NULL)
passwordMethodsasl Constructor
This class contains all the functions for sasl password methods.
static get_hash_name()
Get the hash name.
This class contains all the basic function for password methods.
static display($s_title, $s_message, $i_type=INFO_DIALOG)
Display a message dialog.