Skip to content

Commit

Permalink
#379 make sure that wildcards are resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Oct 31, 2024
1 parent 7102d13 commit a561d6d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
11 changes: 9 additions & 2 deletions lam/lib/modules/courierMailAccount.inc
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,20 @@ class courierMailAccount extends baseModule {
return $attrs;
}

/**
* {@inheritdoc}
*/
public function getWildcardTargetAttributeNames(): array {
return ['homeDirectory', 'mailbox'];
}

/**
* {@inheritDoc}
*/
public function display_html_attributes() {
$return = new htmlResponsiveRow();
if ($this->isExtensionEnabled()) {
$this->getAccountContainer()->replaceWildcardsInArray(['homeDirectory', 'mailbox'], $this->attributes);
$this->getAccountContainer()->replaceWildcardsInArray($this->getWildcardTargetAttributeNames(), $this->attributes);
if ($this->isUnixDisabled($this->getAccountContainer()->get_type()->getModules())) {
// home directory
$this->addSimpleInputTextField($return, 'homeDirectory', _('Home directory'), true);
Expand Down Expand Up @@ -334,7 +341,7 @@ class courierMailAccount extends baseModule {
if (!$this->isExtensionEnabled()) {
return [];
}
$this->getAccountContainer()->replaceWildcardsInPOST(['homeDirectory', 'mailbox']);
$this->getAccountContainer()->replaceWildcardsInPOST($this->getWildcardTargetAttributeNames());
$errors = [];
// check new mailbox
$this->attributes['mailbox'][0] = $_POST['mailbox'];
Expand Down
11 changes: 9 additions & 2 deletions lam/lib/modules/inetLocalMailRecipient.inc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ class inetLocalMailRecipient extends baseModule {
}
}

/**
* {@inheritdoc}
*/
public function getWildcardTargetAttributeNames(): array {
return ['mailLocalAddress', 'mailRoutingAddress'];
}

/**
* Returns the HTML meta data for the main account page.
*
Expand All @@ -194,7 +201,7 @@ class inetLocalMailRecipient extends baseModule {
function display_html_attributes() {
$return = new htmlResponsiveRow();
if (in_array('inetLocalMailRecipient', $this->attributes['objectClass'])) {
$this->getAccountContainer()->replaceWildcardsInArray(['mailLocalAddress', 'mailRoutingAddress'], $this->attributes);
$this->getAccountContainer()->replaceWildcardsInArray($this->getWildcardTargetAttributeNames(), $this->attributes);
// mail routing address
$this->addSimpleInputTextField($return, 'mailRoutingAddress', _('Routing address'));
// mail server
Expand Down Expand Up @@ -237,7 +244,7 @@ class inetLocalMailRecipient extends baseModule {
return [];
}
$errors = [];
$this->getAccountContainer()->replaceWildcardsInPOST(['mailLocalAddress', 'mailRoutingAddress']);
$this->getAccountContainer()->replaceWildcardsInPOST($this->getWildcardTargetAttributeNames());
$this->attributes['mailRoutingAddress'] = [];
$this->attributes['mailLocalAddress'] = [];
$this->attributes['mailHost'] = [];
Expand Down
15 changes: 10 additions & 5 deletions lam/lib/modules/posixAccount.inc
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
}
$modules = $this->getAccountContainer()->get_type()->getModules();
// get default changes
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
$return = parent::save_attributes();
// add information about clear text password and password status change
$return[$this->getAccountContainer()->dn_orig]['info']['userPasswordClearText'][0] = $this->clearTextPassword;
$pwdAttrName = $this->getPasswordAttrName($modules);
Expand Down Expand Up @@ -1091,8 +1091,7 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
* @return array list of info/error messages
*/
function process_attributes() {
$keysToReplace = ['cn', 'gecos', 'homeDirectory'];
$this->getAccountContainer()->replaceWildcardsInPOST($keysToReplace);
$this->getAccountContainer()->replaceWildcardsInPOST($this->getWildcardTargetAttributeNames());
$modules = $this->getAccountContainer()->get_type()->getModules();
$typeId = $this->getAccountContainer()->get_type()->getId();
$errors = [];
Expand Down Expand Up @@ -1695,6 +1694,13 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
return $return;
}

/**
* {@inheritdoc}
*/
public function getWildcardTargetAttributeNames(): array {
return ['cn', 'gecos', 'homeDirectory'];
}

/**
* Returns the HTML meta data for the main account page.
*
Expand All @@ -1706,8 +1712,7 @@ class posixAccount extends baseModule implements passwordService, AccountStatusP
$modules = $this->getAccountContainer()->get_type()->getModules();
$typeId = $this->getAccountContainer()->get_type()->getId();
if (!$this->isOptional($modules) || $this->skipObjectClass() || (isset($this->attributes['objectClass']) && in_array('posixAccount', $this->attributes['objectClass']))) {
$keysToReplace = ['cn', 'gecos', 'homeDirectory'];
$this->getAccountContainer()->replaceWildcardsInArray($keysToReplace, $this->attributes);
$this->getAccountContainer()->replaceWildcardsInArray($this->getWildcardTargetAttributeNames(), $this->attributes);
$homeDirAttr = $this->getHomedirAttrName($modules);
$groupList = $this->findGroups($modules); // list of all group names
$groups = [];
Expand Down
19 changes: 11 additions & 8 deletions lam/lib/modules/windowsUser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1342,17 +1342,23 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
return $return;
}

/**
* {@inheritdoc}
*/
public function getWildcardTargetAttributeNames(): array {
return ['cn', 'displayName', 'mail', 'otherMailbox',
'profilePath', 'scriptPath', 'homeDirectory', 'userPrincipalName',
'sAMAccountName'];
}

/**
* Returns the HTML metadata for the main account page.
*
* @return htmlElement HTML meta data
*/
public function display_html_attributes() {
$this->initCache();
$keysToReplace = ['cn', 'displayName', 'mail', 'otherMailbox',
'profilePath', 'scriptPath', 'homeDirectory', 'userPrincipalName',
'sAMAccountName'];
$this->getAccountContainer()->replaceWildcardsInArray($keysToReplace, $this->attributes);
$this->getAccountContainer()->replaceWildcardsInArray($this->getWildcardTargetAttributeNames(), $this->attributes);
$containerLeft = new htmlResponsiveRow();
if ($this->getAccountContainer()->isNewAccount && !isset($this->attributes['useraccountcontrol'][0])) {
$this->attributes['useraccountcontrol'][0] = self::DEFAULT_ACCOUNT_CONTROL;
Expand Down Expand Up @@ -1744,10 +1750,7 @@ class windowsUser extends baseModule implements passwordService, AccountStatusPr
*/
public function process_attributes() {
$return = [];
$keysToReplace = ['cn', 'displayName', 'mail', 'otherMailbox',
'profilePath', 'scriptPath', 'homeDirectory', 'userPrincipalName',
'sAMAccountName'];
$this->getAccountContainer()->replaceWildcardsInPOST($keysToReplace);
$this->getAccountContainer()->replaceWildcardsInPOST($this->getWildcardTargetAttributeNames());
// user name
$userPrincipalName = $_POST['userPrincipalName'];
if (!get_preg($userPrincipalName, 'username')) {
Expand Down

0 comments on commit a561d6d

Please sign in to comment.