Permalink
Browse files

Fix ldap UserID with spec chars breaks ldapsearch

  • Loading branch information...
1 parent 35a2c19 commit 5c65dbd3e2a3a15fd63ed4ba15d9196781d4622b @c12simple c12simple committed Sep 22, 2016
@@ -988,6 +988,13 @@ public function getLdapGroupListFromDN()
*/
public function sanitize($s, $level = InputFilter::SANITIZE_HTML)
{
- return $s;
+ $preg = '/[\\/<>\?\*\\\\|;:,+"\]\[]/';
+ /**
+ * These are illegal characters and can break ldap searching.
+ * when we create new user on Windows AD, these illegal characters will be replaced by '_'.
+ * Give a try by replacement of '_'
+ */
+ $newS = preg_replace($preg, '_', $s);
+ return $newS;
}
}
@@ -568,7 +568,7 @@ public function sanitize($s, $level = InputFilter::SANITIZE_HTML)
* Override only for ldap.
*/
if ($this->masterSlaveMode) {
- if ($this->masterName == 'ldap') {
+ if (($this->masterName == 'ldap') || ($this->masterName == 'ldapv2')) {
return $this->drivers[$this->masterName]->sanitize($s, $level);
}
}

0 comments on commit 5c65dbd

Please sign in to comment.