diff --git a/html/includes/authentication/active_directory.inc.php b/html/includes/authentication/active_directory.inc.php
index e6dda6b7e0..a4b83b73f2 100644
--- a/html/includes/authentication/active_directory.inc.php
+++ b/html/includes/authentication/active_directory.inc.php
@@ -295,7 +295,9 @@ function get_dn($samaccountname) {
}
function get_cn($dn) {
+ $dn = str_replace('\\,','~C0mmA~',$dn);
preg_match('/[^,]*/', $dn, $matches, PREG_OFFSET_CAPTURE, 3);
+ $matches[0][0] = str_replace('~C0mmA~',',',$matches[0][0]);
return $matches[0][0];
}