fixed saving accounts with Windows escaping

This commit is contained in:
Roland Gruber 2019-11-09 14:25:06 +01:00
parent 83a0ff71c9
commit d991ec578c
3 changed files with 24 additions and 3 deletions

View File

@ -692,6 +692,19 @@ function escapeRDN($rdn) {
$rdn);
}
/**
* Converts the comma escaping from Windows to OpenLDAP style.
*
* @param string $dn DN
* @return string DN
*/
function convertCommaEscaping($dn) {
return str_replace(
array('\\,'),
array('\\2C'),
$dn);
}
/**
* Connects to an LDAP server using the given URL.
*
@ -1213,6 +1226,7 @@ function extractDNSuffix($dn) {
if ($dn == null) {
return null;
}
$dn = convertCommaEscaping($dn);
return substr($dn, strpos($dn, ',')+1);
}

View File

@ -1937,9 +1937,9 @@ class accountContainer {
}
// Set to true if an real error has happened
$stopprocessing = false;
if (strtolower($this->finalDN) != strtolower($this->dn_orig)) {
if (strtolower($this->finalDN) != convertCommaEscaping(strtolower($this->dn_orig))) {
// move existing DN
if ($this->dn_orig!='') {
if ($this->dn_orig != '') {
$removeOldRDN = false;
if (isset($attributes[$this->finalDN]['modify'])) {
$attributes[$this->finalDN]['modify'] = array_change_key_case($attributes[$this->finalDN]['modify'], CASE_LOWER);

View File

@ -1,7 +1,7 @@
<?php
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2018 Roland Gruber
Copyright (C) 2018 - 2019 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
@ -128,4 +128,11 @@ class AccountTest extends PHPUnit_Framework_TestCase {
$this->assertEquals('http://base/test.php', getCallingURL('http://base'));
}
/**
* Tests convertCommaEscaping().
*/
function testConvertCommaEscaping() {
$this->assertEquals('cn=test\\2C user,ou=People,o=test,c=de', convertCommaEscaping('cn=test\\, user,ou=People,o=test,c=de'));
}
}