$extusername = $textlib->convert(stripslashes($userobject->username), 'utf-8', $this->config->ldapencoding);
$extpassword = $textlib->convert(stripslashes($plainpass), 'utf-8', $this->config->ldapencoding);
+ switch ($this->config->passtype) {
+ case 'md5':
+ $extpassword = '{MD5}' . base64_encode(pack('H*', md5($extpassword)));
+ break;
+ case 'sha1':
+ $extpassword = '{SHA}' . base64_encode(pack('H*', sha1($extpassword)));
+ break;
+ case 'plaintext':
+ default:
+ break; // plaintext
+ }
+
$ldapconnection = $this->ldap_connect();
$attrmap = $this->ldap_attributes();
$extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->ldapencoding);
$extpassword = $textlib->convert(stripslashes($newpassword), 'utf-8', $this->config->ldapencoding);
+ switch ($this->config->passtype) {
+ case 'md5':
+ $extpassword = '{MD5}' . base64_encode(pack('H*', md5($extpassword)));
+ break;
+ case 'sha1':
+ $extpassword = '{SHA}' . base64_encode(pack('H*', sha1($extpassword)));
+ break;
+ case 'plaintext':
+ default:
+ break; // plaintext
+ }
+
$ldapconnection = $this->ldap_connect();
$user_dn = $this->ldap_find_userdn($ldapconnection, $extusername);
if (!isset($config->forcechangepassword))
{$config->forcechangepassword = 0; }
if (!isset($config->stdchangepassword))
- {$config->stdchangepassword = 0; }
+ {$config->forcechangepassword = 0; }
+ if (!isset($config->passtype))
+ {$config->passtype = 'plaintext'; }
if (!isset($config->changepasswordurl))
{$config->changepasswordurl = ''; }
if (!isset($config->removeuser))
set_config('auth_user_create', $config->auth_user_create, 'auth/ldap');
set_config('forcechangepassword', $config->forcechangepassword, 'auth/ldap');
set_config('stdchangepassword', $config->stdchangepassword, 'auth/ldap');
+ set_config('passtype', $config->passtype, 'auth/ldap');
set_config('changepasswordurl', $config->changepasswordurl, 'auth/ldap');
set_config('removeuser', $config->removeuser, 'auth/ldap');
{$config->forcechangepassword = 0; }
if (!isset($config->stdchangepassword))
{$config->stdchangepassword = 0; }
+ if (!isset($config->passtype))
+ {$config->passtype = 'plaintext';}
if (!isset($config->changepasswordurl))
{$config->changepasswordurl = ''; }
if (!isset($config->removeuser))
</td>
</tr>
+<tr valign="top" class="required">
+ <td align="right"><label for="menupasstype"><?php print_string('auth_ldap_passtype_key', 'auth') ?></label></td>
+ <td>
+ <?php
+ $passtype = array();
+ $passtype['plaintext'] = get_string('plaintext', 'auth');
+ $passtype['md5'] = get_string('md5', 'auth');
+ $passtype['sha1'] = get_string('sha1', 'auth');
+ choose_from_menu($passtype, 'passtype', $config->passtype, '');
+
+ ?>
+ </td>
+ <td><?php print_string('auth_ldap_passtype', 'auth') ?></td>
+</tr>
+
<tr valign="top">
<td align="right"><label for="changepasswordurl"><?php print_string('auth_ldap_changepasswordurl_key','auth') ?></label></td>
<td>
$string['auth_ldap_memberattribute_isdn'] = 'Optional: Overrides handling of member attribute values, either 0 or 1';
$string['auth_ldap_objectclass'] = 'Optional: Overrides objectClass used to name/search users on ldap_user_type. Usually you dont need to chage this.';
$string['auth_ldap_opt_deref'] = 'Determines how aliases are handled during search. Select one of the following values: \"No\" (LDAP_DEREF_NEVER) or \"Yes\" (LDAP_DEREF_ALWAYS)';
+$string['auth_ldap_passtype'] = 'Specify the format of new or changed passwords in LDAP server.';
$string['auth_ldap_passwdexpire_settings'] = 'LDAP password expiration settings.';
$string['auth_ldap_preventpassindb'] = 'Select yes to prevent passwords from being stored in Moodle\'s DB.';
$string['auth_ldap_search_sub'] = 'Search users from subcontexts.';
$string['auth_ldap_memberattribute_key'] = 'Member attribute';
$string['auth_ldap_memberattribute_isdn_key'] = 'Member attribute uses dn';
$string['auth_ldap_objectclass_key'] = 'Object class';
+$string['auth_ldap_passtype_key'] = 'Password format';
$string['auth_ldap_changepasswordurl_key'] = 'Password-change URL';
$string['auth_ldap_expiration_key'] = 'Expiration';
$string['auth_ldap_expiration_warning_key'] = 'Expiration warning';