From 7102d13e8f3e36d12bccd402d2f5c36d4f6f75de Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 31 Oct 2024 07:30:21 +0100 Subject: [PATCH] #379 make sure that wildcards are resolved --- lam/HISTORY | 1 + lam/lib/baseModule.inc | 10 ++++++++++ lam/lib/modules/inetOrgPerson.inc | 28 +++++++++++++++------------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index f141e945b..5ab95b7ce 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -11,6 +11,7 @@ December 2024 9.0 - Fixed bugs: -> Windows: show more than 1000 LDAP entries when paged results is activated in server profile -> WebAuthn: support DNs larger than 64 bytes (358) + -> Wildcard replacements do not work without switching to the module tab (379) 24.09.2024 8.9 diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index c132749be..00a88fccb 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -1228,6 +1228,7 @@ abstract class baseModule { * @return array list of modifications */ public function save_attributes() { + $this->getAccountContainer()->replaceWildcardsInArray($this->getWildcardTargetAttributeNames(), $this->attributes); return $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); } @@ -2365,6 +2366,15 @@ abstract class baseModule { return []; } + /** + * Returns a list of attribute names that may contain wildcards. + * + * @return array list of attribute names + */ + public function getWildcardTargetAttributeNames(): array { + return []; + } + /** * Returns a callable if there should be a custom filtering for the given attribute name. * diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index 12a189908..1463d564e 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -892,7 +892,7 @@ class inetOrgPerson extends baseModule implements passwordService, AccountStatus if (!$this->getAccountContainer()->isNewAccount && !in_array('inetOrgPerson', $this->getAccountContainer()->attributes_orig['objectClass'])) { return []; } - $return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); + $return = parent::save_attributes(); // postalAddress, registeredAddress, facsimileTelephoneNumber and jpegPhoto need special removing if (isset($return[$this->getAccountContainer()->dn_orig]['remove']['postalAddress'])) { $return[$this->getAccountContainer()->dn_orig]['modify']['postalAddress'] = $this->attributes['postalAddress']; @@ -999,12 +999,7 @@ class inetOrgPerson extends baseModule implements passwordService, AccountStatus */ function process_attributes() { $errors = []; - $keysToReplace = ['mail', 'description', 'postalAddress', 'cn', - 'registeredAddress', 'labeledURI']; - if ($this->isUnixActive()) { - $keysToReplace[] = 'uid'; - } - $this->getAccountContainer()->replaceWildcardsInPOST($keysToReplace); + $this->getAccountContainer()->replaceWildcardsInPOST($this->getWildcardTargetAttributeNames()); // add parent object classes if ($this->getAccountContainer()->isNewAccount) { if (!in_array('organizationalPerson', $this->attributes['objectClass'])) { @@ -1218,12 +1213,7 @@ class inetOrgPerson extends baseModule implements passwordService, AccountStatus */ function display_html_attributes() { $this->initCache(); - $keysToReplace = ['mail', 'description', 'postalAddress', 'uid', 'cn', - 'registeredAddress', 'labeledURI']; - if ($this->isUnixActive()) { - $keysToReplace[] = 'uid'; - } - $this->getAccountContainer()->replaceWildcardsInArray($keysToReplace, $this->attributes); + $this->getAccountContainer()->replaceWildcardsInArray($this->getWildcardTargetAttributeNames(), $this->attributes); $container = new htmlResponsiveRow(); $fieldContainer = new htmlResponsiveRow(); $fieldTabletColumns = $this->isBooleanConfigOptionSet('inetOrgPerson_hidejpegPhoto') ? 12 : 8; @@ -3888,6 +3878,18 @@ class inetOrgPerson extends baseModule implements passwordService, AccountStatus return in_array('sambaSamAccount', $modules); } + /** + * {@inheritdoc} + */ + public function getWildcardTargetAttributeNames(): array { + $attributeNames = ['mail', 'description', 'postalAddress', 'uid', 'cn', + 'registeredAddress', 'labeledURI']; + if ($this->isUnixActive()) { + $attributeNames[] = 'uid'; + } + return $attributeNames; + } + /** * {@inheritdoc} */