Skip to content

Commit

Permalink
Do not assume string/CSV from proxyAddresses field (fixes #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreashaerter committed Apr 2, 2024
1 parent 3a3b607 commit e09bb3e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions identity_from_directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ public function lookup_user_name($args)
}
} elseif ($ad_handle_proxyaddresses &&
preg_match('/^proxyaddresses($|:)/', $key)) {
// parse Active Directory attribute proxyAddresses, CSV string like 'smtp:foo@exmaple.com,bar@example.net'
$proxyaddresses = rcube_utils::explode(',', $ldap_entry[$key]);
// Handle Active Directory attribute proxyAddresses, originally a CSV string
// like 'smtp:foo@exmaple.com,bar@example.net'. Returned as string if there
// is only one, returned as array if there are multiple.
$proxyaddresses = $ldap_entry[$key];
if (!is_array($proxyaddresses)) {
$proxyaddresses = [ $proxyaddresses ];
}
foreach ((array) $proxyaddresses as $alias) {
$alias = trim($alias);
if (empty($alias)) {
continue;
}
$alias = preg_replace('/^smtp:(.+)/', '\1', $alias, 1);
$alias = trim(preg_replace('/^smtp:(.+)/', '\1', $alias, 1));
if (strpos($alias, '@') !== false) {
$args['email_list'][] = rcube_utils::idn_to_ascii($alias);
}
Expand Down

0 comments on commit e09bb3e

Please sign in to comment.