added fallback for iconv

This commit is contained in:
Roland Gruber 2018-11-23 18:31:47 +01:00
parent 8852dd170d
commit 2d3f584bb4
3 changed files with 19 additions and 3 deletions

View File

@ -1635,6 +1635,22 @@ function printJsIncludes($prefix) {
}
}
/**
* Converts an UTF-8 string to UTF16LE.
*
* @param string $input UTF-8 value
*/
function convertUtf8ToUtf16Le($input) {
if (($input == null) || (strlen($input) == 0)) {
return $input;
}
$output = iconv('UTF-8', 'UTF-16LE', $input);
if (($output === false) || ($output == '')) {
$output = mb_convert_encoding($input, 'UTF-8', 'UTF-16LE');
}
return $output;
}
/**
* LAM exception with title and message.
*

View File

@ -3,7 +3,7 @@
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2004 - 2006 Roland Gruber
Copyright (C) 2004 - 2018 Roland Gruber
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
@ -349,7 +349,7 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
* @return string hash value
*/
public function nthash($password = "") {
return strtoupper(hash('md4', iconv("UTF-8","UTF-16LE",$password)));
return strtoupper(hash('md4', convertUtf8ToUtf16Le($password)));
}
/**

View File

@ -3177,7 +3177,7 @@ class windowsUser extends baseModule implements passwordService {
* @param String $password password
*/
public static function pwdAttributeValue($password) {
return iconv('UTF-8', 'UTF-16LE', '"' . $password . '"');
return convertUtf8ToUtf16Le('"' . $password . '"');
}
/**