Skip to content

Commit

Permalink
Update code to use the attribute converter hub
Browse files Browse the repository at this point in the history
  • Loading branch information
jvillafanez committed Feb 27, 2023
1 parent 7c84721 commit ce4e849
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/User/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,10 @@ public function findUsersByUsername($uid) {

$escapedUid = $this->access->escapeFilterPart($uid);
$attrFilters = [];
$converterHub = ConverterHub::getDefaultConverterHub();
foreach ($usernameAttrs as $attr) {
if ($attr === 'objectguid' || $attr === 'guid') {
// needs special formatting because we need to send as binary data
$attrFilters[] = "{$attr}=" . $this->access->formatGuid2ForFilterUser($uid);
if ($converterHub->hasConverter($attr)) {
$attrFilters[] = "{$attr}=" . $converterHub->str2filter($attr, $uid);
} else {
$attrFilters[] = "{$attr}={$escapedUid}";
}
Expand Down Expand Up @@ -609,11 +609,13 @@ public function findUsersByUsername($uid) {
*/
private function getValueFromEntry($ldapEntry, $attrs) {
$chosenValue = null;
$converterHub = ConverterHub::getDefaultConverterHub();

foreach ($attrs as $attr) {
if (isset($ldapEntry[$attr][0])) {
$chosenValue = $ldapEntry[$attr][0];
if ($attr === 'objectguid' || $attr === 'guid') {
$chosenValue = Access::binGUID2str($chosenValue);
if ($converterHub->hasConverter($attr)) {
$chosenValue = $converterHub->bin2str($attr, $chosenValue);
}
break;
}
Expand Down

0 comments on commit ce4e849

Please sign in to comment.