From e3b0d10bf8c5a8c266152f7446e591ea8f07e832 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 7 Nov 2019 21:05:11 +0100 Subject: [PATCH 1/8] hide tabs for edit pages --- lam/lib/adminHeader.inc | 9 +++------ lam/lib/lists.inc | 1 + lam/lib/modules.inc | 11 +++++++++-- lam/templates/tree/treeViewContainer.php | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lam/lib/adminHeader.inc b/lam/lib/adminHeader.inc index 85d258e0..f1fee687 100644 --- a/lam/lib/adminHeader.inc +++ b/lam/lib/adminHeader.inc @@ -193,16 +193,12 @@ jQuery(document).ready(function() { }); -
- '; + echo ''; } diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index eb27dd40..8f170a5b 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -912,6 +912,7 @@ class lamList { */ private function printHeader() { include 'adminHeader.inc'; + \LAM\HEADER\printTypeTabs('../..'); $this->printHeaderContent(); } diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 6aadc869..ec20ffdd 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1314,6 +1314,7 @@ class accountContainer { . getSecurityTokenName() . '\',\'' . getSecurityTokenValue() . '\');'); $leftButtonGroup->addElement($passwordButton); } + // delete button if (!$this->isNewAccount) { $leftButtonGroup->addElement(new htmlSpacer('15px', null)); $deleteButton = new htmlButton('accountContainerDelete', _('Delete')); @@ -1321,7 +1322,13 @@ class accountContainer { $deleteButton->setCSSClasses(array('fullwidth-mobile-only')); $leftButtonGroup->addElement($deleteButton); } - $row->add($leftButtonGroup, 12, 7); + // back to list button + $leftButtonGroup->addElement(new htmlSpacer('15px', null)); + $backToListButton = new htmlButton('accountContainerBackToList', $this->type->getBaseType()->LABEL_BACK_TO_ACCOUNT_LIST); + $backToListButton->setIconClass('backButton'); + $backToListButton->setCSSClasses(array('fullwidth-mobile-only')); + $leftButtonGroup->addElement($backToListButton); + $row->add($leftButtonGroup, 12, 9); $rightGroup = new htmlGroup(); // profile selection @@ -1340,7 +1347,7 @@ class accountContainer { $rightGroup->addElement(new htmlSpacer('1px', null)); $rightGroup->addElement(new htmlHelpLink('401')); } - $row->add($rightGroup, 12, 5, 5, 'text-right'); + $row->add($rightGroup, 12, 3, 3, 'text-right'); parseHtml(null, $row, array(), false, $tabindex, $this->type->getScope()); } diff --git a/lam/templates/tree/treeViewContainer.php b/lam/templates/tree/treeViewContainer.php index 5c6a95e9..17ea39f7 100644 --- a/lam/templates/tree/treeViewContainer.php +++ b/lam/templates/tree/treeViewContainer.php @@ -2,7 +2,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2010 - 2018 Roland Gruber + Copyright (C) 2010 - 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 @@ -40,6 +40,7 @@ enforceUserIsLoggedIn(); setlanguage(); include __DIR__ . '/../../lib/adminHeader.inc'; +\LAM\HEADER\printTypeTabs('../..'); ?>
From 5a12fc7a2ebad44a043aaaa51ad298a37a6bfae2 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 7 Nov 2019 21:14:52 +0100 Subject: [PATCH 2/8] less padding --- lam/style/500_layout.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lam/style/500_layout.css b/lam/style/500_layout.css index 9ec2e82b..df554de4 100644 --- a/lam/style/500_layout.css +++ b/lam/style/500_layout.css @@ -587,7 +587,7 @@ tr.account { } #lamVerticalTabs .ui-tabs-panel { - padding: 1em; + padding: 0em 1em 1em 1em; float: left; } From a3f0c070962b33c4cc2e263370a11e565c5b72c1 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 7 Nov 2019 21:45:12 +0100 Subject: [PATCH 3/8] spacing fixes --- lam/lib/adminHeader.inc | 1 + lam/lib/lists.inc | 1 - lam/lib/modules.inc | 11 ++-------- lam/lib/types/user.inc | 27 ++++++++++++------------ lam/style/500_layout.css | 3 ++- lam/templates/tree/treeViewContainer.php | 1 - 6 files changed, 19 insertions(+), 25 deletions(-) diff --git a/lam/lib/adminHeader.inc b/lam/lib/adminHeader.inc index f1fee687..6a8ed1b7 100644 --- a/lam/lib/adminHeader.inc +++ b/lam/lib/adminHeader.inc @@ -195,6 +195,7 @@ jQuery(document).ready(function() { '; diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index 8f170a5b..eb27dd40 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -912,7 +912,6 @@ class lamList { */ private function printHeader() { include 'adminHeader.inc'; - \LAM\HEADER\printTypeTabs('../..'); $this->printHeaderContent(); } diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index ec20ffdd..288a0391 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1051,10 +1051,9 @@ class accountContainer { $titleBarContainer = new htmlResponsiveRow(); $titleBarContainer->setCSSClasses(array('maxrow')); $titleBarTitleText = new htmlOutputText($this->titleBarTitle, false); - $titleBarContainer->add(new htmlDiv(null, $titleBarTitleText, array('titleBarTitle', 'text-left')), 12); - $titleBarContainer->addVerticalSpacer('0.5rem'); + $titleBarContainer->add(new htmlDiv(null, $titleBarTitleText, array('titleBarTitle', 'text-left')), 12, 12, 4); $titleBarSubtitleText = new htmlOutputText($this->titleBarSubtitle, false); - $titleBarContainer->add(new htmlDiv(null, $titleBarSubtitleText, array('titleBarSubtitle', 'text-left')), 12); + $titleBarContainer->add(new htmlDiv(null, $titleBarSubtitleText, array('titleBarSubtitle', 'responsiveLabel')), 12, 12, 8); $titleBarSuffixRdn = new htmlResponsiveRow(); $titleBarSuffixRdn->add(new htmlHorizontalLine(), 12); // suffix @@ -1322,12 +1321,6 @@ class accountContainer { $deleteButton->setCSSClasses(array('fullwidth-mobile-only')); $leftButtonGroup->addElement($deleteButton); } - // back to list button - $leftButtonGroup->addElement(new htmlSpacer('15px', null)); - $backToListButton = new htmlButton('accountContainerBackToList', $this->type->getBaseType()->LABEL_BACK_TO_ACCOUNT_LIST); - $backToListButton->setIconClass('backButton'); - $backToListButton->setCSSClasses(array('fullwidth-mobile-only')); - $leftButtonGroup->addElement($backToListButton); $row->add($leftButtonGroup, 12, 9); $rightGroup = new htmlGroup(); diff --git a/lam/lib/types/user.inc b/lam/lib/types/user.inc index f7fabada..19957452 100644 --- a/lam/lib/types/user.inc +++ b/lam/lib/types/user.inc @@ -128,6 +128,7 @@ class user extends baseType { * @return String title text */ public function getTitleBarTitle($container) { + $title = $this->buildAccountStatusIcon($container); // get attributes $personalAttributes = null; if ($container->getAccountModule('inetOrgPerson') != null) { @@ -158,37 +159,37 @@ class user extends baseType { // check if first and last name can be shown if (($personalAttributes != null) && isset($personalAttributes['sn'][0]) && !empty($personalAttributes['sn'][0]) && isset($personalAttributes['givenName'][0]) && !empty($personalAttributes['givenName'][0])) { - return htmlspecialchars($personalAttributes['givenName'][0] . ' ' . $personalAttributes['sn'][0]); + return $title . htmlspecialchars($personalAttributes['givenName'][0] . ' ' . $personalAttributes['sn'][0]); } // check if a display name is set if (($sambaAttributes != null) && isset($sambaAttributes['displayName'][0]) && !empty($sambaAttributes['displayName'][0])) { - return htmlspecialchars($sambaAttributes['displayName'][0]); + return $title . htmlspecialchars($sambaAttributes['displayName'][0]); } // check if a common name is set if (($personalAttributes != null) && isset($personalAttributes['cn'][0]) && !empty($personalAttributes['cn'][0])) { - return htmlspecialchars($personalAttributes['cn'][0]); + return $title . htmlspecialchars($personalAttributes['cn'][0]); } if (($unixAttributes != null) && isset($unixAttributes['cn'][0]) && !empty($unixAttributes['cn'][0])) { - return htmlspecialchars($unixAttributes['cn'][0]); + return $title . htmlspecialchars($unixAttributes['cn'][0]); } // check if a user name is set if (($unixAttributes != null) && isset($unixAttributes['uid'][0]) && !empty($unixAttributes['uid'][0])) { - return htmlspecialchars($unixAttributes['uid'][0]); + return $title . htmlspecialchars($unixAttributes['uid'][0]); } if (($personalAttributes != null) && isset($personalAttributes['uid'][0]) && !empty($personalAttributes['uid'][0])) { - return htmlspecialchars($personalAttributes['uid'][0]); + return $title . htmlspecialchars($personalAttributes['uid'][0]); } if (($accountAttributes != null) && isset($accountAttributes['uid'][0]) && !empty($accountAttributes['uid'][0])) { - return htmlspecialchars($accountAttributes['uid'][0]); + return $title . htmlspecialchars($accountAttributes['uid'][0]); } if (($mitKerberosAttributes != null) && isset($mitKerberosAttributes['krbPrincipalName'][0]) && !empty($mitKerberosAttributes['krbPrincipalName'][0])) { - return htmlspecialchars($mitKerberosAttributes['krbPrincipalName'][0]); + return $title . htmlspecialchars($mitKerberosAttributes['krbPrincipalName'][0]); } if ($container->isNewAccount) { - return _("New user"); + return $title . _("New user"); } // fall back to default - return parent::getTitleBarTitle($container); + return $title . parent::getTitleBarTitle($container); } /** @@ -206,10 +207,10 @@ class user extends baseType { $personalAttributes = $container->getAccountModule('windowsUser')->getAttributes(); } if ($personalAttributes == null) { - return $this->buildAccountStatusIcon($container); + return ''; } - $subtitle = $this->buildAccountStatusIcon($container); - $spacer = '        '; + $subtitle = ''; + $spacer = '     '; // check if an email address can be shown if (isset($personalAttributes['mail'][0]) && !empty($personalAttributes['mail'][0])) { $subtitle .= '' . htmlspecialchars($personalAttributes['mail'][0]) . '' . $spacer; diff --git a/lam/style/500_layout.css b/lam/style/500_layout.css index df554de4..b92b8a94 100644 --- a/lam/style/500_layout.css +++ b/lam/style/500_layout.css @@ -226,8 +226,9 @@ textarea { table.lamHeader { background-image: url(lam-images/headerLine.png); - padding: 0px 0px 0.5rem 0px; + padding: 0px; height: 35px; + margin-bottom: 0.5rem; } table.lamTop { diff --git a/lam/templates/tree/treeViewContainer.php b/lam/templates/tree/treeViewContainer.php index 17ea39f7..69a12065 100644 --- a/lam/templates/tree/treeViewContainer.php +++ b/lam/templates/tree/treeViewContainer.php @@ -40,7 +40,6 @@ enforceUserIsLoggedIn(); setlanguage(); include __DIR__ . '/../../lib/adminHeader.inc'; -\LAM\HEADER\printTypeTabs('../..'); ?>
From 714dbaa0fdcc067f680a3f7a8c60c398083f1d84 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 9 Nov 2019 11:08:42 +0100 Subject: [PATCH 4/8] filter by substring match instead of exact match --- lam/HISTORY | 1 + lam/lib/lists.inc | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index 10591170..5abfad56 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,5 +1,6 @@ December 2019 7.0 - Lamdaemon can be configured with directory prefix for homedirs + - Account list filters match on substrings instead of whole value - Fixed bugs: -> Missing CSS for Duo diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index eb27dd40..44528327 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -1080,7 +1080,14 @@ class lamList { if (!$this->isAttributeFilteredByServer($attr)) { continue; } - $text .= '(' . $attr . '=' . $filter . ')'; + $filterExpression = $filter; + if (strpos($filter, '*') !== 0) { + $filterExpression = '*' . $filterExpression; + } + if (strrpos($filter, '*') !== (strlen($filter) - 1)) { + $filterExpression = $filterExpression . '*'; + } + $text .= '(' . $attr . '=' . $filterExpression . ')'; } return $text; } @@ -1113,7 +1120,7 @@ class lamList { continue; } $regex = str_replace(array('*'), array('.*'), $filterValue); - $regex = '/^' . $regex . '$/i'; + $regex = '/' . $regex . '/i'; if (!$this->isFilterMatching($data, $filterAttribute, $regex)) { $toFilter[] = $index; } From 83a0ff71c9cfd08900c16feb76ca50ad8b3552b1 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 9 Nov 2019 14:10:06 +0100 Subject: [PATCH 5/8] #210 removed old workaround that causes issues with spaces in DN --- lam/lib/account.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index a43076eb..982adb6a 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -673,7 +673,6 @@ function get_preg($argument, $regexp) { * @return String escaped DN */ function escapeDN($dn) { - $dn = preg_replace('/[ ]*,[ ]*/', ',', $dn); return str_replace( array(')', '(', ' ', '*'), array('\\29', '\\28', '\\20', '\\2a'), From d991ec578c79c91fe1a76d26e181c29146ad3db9 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 9 Nov 2019 14:25:06 +0100 Subject: [PATCH 6/8] fixed saving accounts with Windows escaping --- lam/lib/account.inc | 14 ++++++++++++++ lam/lib/modules.inc | 4 ++-- lam/tests/lib/accountTest.php | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 982adb6a..b29baf12 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -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); } diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 288a0391..60ac11f9 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -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); diff --git a/lam/tests/lib/accountTest.php b/lam/tests/lib/accountTest.php index 3bef321e..8790ba28 100644 --- a/lam/tests/lib/accountTest.php +++ b/lam/tests/lib/accountTest.php @@ -1,7 +1,7 @@ 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')); + } + } From b0d786c86e5b2c107c05013972127f857bed00f0 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 9 Nov 2019 14:32:35 +0100 Subject: [PATCH 7/8] fixed formatting of DN with escaped commas --- lam/lib/account.inc | 4 +++- lam/tests/lib/accountTest.php | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index b29baf12..25a04091 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -1053,6 +1053,7 @@ function getAbstractDN($dn) { if ($dn == '') { return ''; } + $dn = str_replace('\\,', '\\2C', $dn); $parts = explode(',', $dn); for ($i = 0; $i < sizeof($parts); $i++) { $subparts = explode('=', $parts[$i]); @@ -1060,7 +1061,8 @@ function getAbstractDN($dn) { $parts[$i] = $subparts[1]; } } - return implode(' > ', $parts); + $abstractDn = implode(' > ', $parts); + return str_replace(array('\\2C', '\\,'), array(',', ','), $abstractDn); } /** diff --git a/lam/tests/lib/accountTest.php b/lam/tests/lib/accountTest.php index 8790ba28..769e9a7d 100644 --- a/lam/tests/lib/accountTest.php +++ b/lam/tests/lib/accountTest.php @@ -135,4 +135,13 @@ class AccountTest extends PHPUnit_Framework_TestCase { $this->assertEquals('cn=test\\2C user,ou=People,o=test,c=de', convertCommaEscaping('cn=test\\, user,ou=People,o=test,c=de')); } + /** + * Tests getAbstractDN(). + */ + function testGetAbstractDN() { + $this->assertEquals('test > test > de', getAbstractDN('cn=test,o=test,c=de')); + $this->assertEquals('test,user > test > de', getAbstractDN('cn=test\\,user,o=test,c=de')); + $this->assertEquals('test,user > test > de', getAbstractDN('cn=test\\2Cuser,o=test,c=de')); + } + } From 42fb854601fc5e83e0d0382b24419cf493604767 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 9 Nov 2019 14:35:16 +0100 Subject: [PATCH 8/8] 7.0 --- lam/HISTORY | 1 + 1 file changed, 1 insertion(+) diff --git a/lam/HISTORY b/lam/HISTORY index 5abfad56..ad6f591c 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -3,6 +3,7 @@ December 2019 7.0 - Account list filters match on substrings instead of whole value - Fixed bugs: -> Missing CSS for Duo + -> Editing of DNs with comma on Windows (210) 29.09.2019 6.9 - Group account types can show member+owner count in list view