Merge pull request #3264 from nextcloud/ldap-deny-long-dns
Gracefully deny users or groups with too long DNs
This commit is contained in:
commit
3a603ab8b4
|
@ -678,6 +678,9 @@ class Access extends LDAPUtility implements IUserTools {
|
||||||
*/
|
*/
|
||||||
public function cacheUserDisplayName($ocName, $displayName, $displayName2 = '') {
|
public function cacheUserDisplayName($ocName, $displayName, $displayName2 = '') {
|
||||||
$user = $this->userManager->get($ocName);
|
$user = $this->userManager->get($ocName);
|
||||||
|
if($user === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$displayName = $user->composeAndStoreDisplayName($displayName, $displayName2);
|
$displayName = $user->composeAndStoreDisplayName($displayName, $displayName2);
|
||||||
$cacheKeyTrunk = 'getDisplayName';
|
$cacheKeyTrunk = 'getDisplayName';
|
||||||
$this->connection->writeToCache($cacheKeyTrunk.$ocName, $displayName);
|
$this->connection->writeToCache($cacheKeyTrunk.$ocName, $displayName);
|
||||||
|
|
|
@ -209,6 +209,17 @@ abstract class AbstractMapping {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function map($fdn, $name, $uuid) {
|
public function map($fdn, $name, $uuid) {
|
||||||
|
if(mb_strlen($fdn) > 255) {
|
||||||
|
\OC::$server->getLogger()->error(
|
||||||
|
'Cannot map, because the DN exceeds 255 characters: {dn}',
|
||||||
|
[
|
||||||
|
'app' => 'user_ldap',
|
||||||
|
'dn' => $fdn,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$row = array(
|
$row = array(
|
||||||
'ldap_dn' => $fdn,
|
'ldap_dn' => $fdn,
|
||||||
'owncloud_name' => $name,
|
'owncloud_name' => $name,
|
||||||
|
|
|
@ -106,7 +106,8 @@ abstract class AbstractMappingTest extends \Test\TestCase {
|
||||||
list($mapper, $data) = $this->initTest();
|
list($mapper, $data) = $this->initTest();
|
||||||
|
|
||||||
// test that mapping will not happen when it shall not
|
// test that mapping will not happen when it shall not
|
||||||
$paramKeys = array('', 'dn', 'name', 'uuid');
|
$tooLongDN = 'uid=joann,ou=Secret Small Specialized Department,ou=Some Tremendously Important Department,ou=Another Very Important Department,ou=Pretty Meaningful Derpartment,ou=Quite Broad And General Department,ou=The Topmost Department,dc=hugelysuccessfulcompany,dc=com';
|
||||||
|
$paramKeys = array('', 'dn', 'name', 'uuid', $tooLongDN);
|
||||||
foreach($paramKeys as $key) {
|
foreach($paramKeys as $key) {
|
||||||
$failEntry = $data[0];
|
$failEntry = $data[0];
|
||||||
if(!empty($key)) {
|
if(!empty($key)) {
|
||||||
|
|
Loading…
Reference in New Issue