diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php index ae881f9dc17bd..85fc91590fb2b 100644 --- a/apps/user_ldap/lib/Mapping/AbstractMapping.php +++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php @@ -379,6 +379,11 @@ public function unmap($name) { DELETE FROM `' . $this->getTableName() . '` WHERE `owncloud_name` = ?'); + $dn = array_search($name, $this->cache); + if ($dn !== false) { + unset($this->cache[$dn]); + } + return $this->modify($statement, [$name]); } diff --git a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php index cc2b36fb7df4a..9c25b1d9af61e 100644 --- a/apps/user_ldap/tests/Mapping/AbstractMappingTest.php +++ b/apps/user_ldap/tests/Mapping/AbstractMappingTest.php @@ -127,8 +127,12 @@ public function testUnmap() { [$mapper, $data] = $this->initTest(); foreach ($data as $entry) { + $fdnBefore = $mapper->getDNByName($entry['name']); $result = $mapper->unmap($entry['name']); + $fdnAfter = $mapper->getDNByName($entry['name']); $this->assertTrue($result); + $this->assertSame($fdnBefore, $entry['dn']); + $this->assertFalse($fdnAfter); } $result = $mapper->unmap('notAnEntry');