Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/adLDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ class adLDAP {
*/
protected $recursiveGroups = true;

/**
* Charset used for internal encoding
*
* @var string
*/
public $charset = 'iso-8859-1';

// You should not need to edit anything below this line
//******************************************************************************************

Expand Down Expand Up @@ -584,6 +591,9 @@ function __construct($options = array()) {
$this->setUseSSO(false);
}
}
if (array_key_exists("charset", $options)) {
$this->charset = strtolower($options["charset"]);
}
}

if ($this->ldapSupported() === false) {
Expand Down Expand Up @@ -919,15 +929,18 @@ public function adldap_schema($attributes) {
*/
protected function encode8Bit(&$item, $key) {
$encode = false;
if (is_string($item)) {
if (is_string($item) && $key != 'password' && $this->charset != 'utf-8') {
for ($i=0; $i<strlen($item); $i++) {
if (ord($item[$i]) >> 7) {
$encode = true;
break;
}
}
}
if ($encode === true && $key != 'password') {
$item = utf8_encode($item);
if ($encode === true) {
$item = function_exists('mb_convert_encoding') ?
mb_convert_encoding($item, 'utf-8', $this->charset) :
utf8_encode($item);
}
}

Expand Down
Loading