Skip to content

Commit 6bf21d8

Browse files
committed
Update code to use the attribute converter hub
1 parent 7c84721 commit 6bf21d8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/User/Manager.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use OC\Cache\CappedMemoryCache;
2929
use OC\ServerNotAvailableException;
3030
use OCA\User_LDAP\Access;
31+
use OCA\User_LDAP\Attributes\ConverterHub;
3132
use OCA\User_LDAP\Connection;
3233
use OCA\User_LDAP\Exceptions\DoesNotExistOnLDAPException;
3334
use OCA\User_LDAP\FilesystemHelper;
@@ -567,10 +568,10 @@ public function findUsersByUsername($uid) {
567568

568569
$escapedUid = $this->access->escapeFilterPart($uid);
569570
$attrFilters = [];
571+
$converterHub = ConverterHub::getDefaultConverterHub();
570572
foreach ($usernameAttrs as $attr) {
571-
if ($attr === 'objectguid' || $attr === 'guid') {
572-
// needs special formatting because we need to send as binary data
573-
$attrFilters[] = "{$attr}=" . $this->access->formatGuid2ForFilterUser($uid);
573+
if ($converterHub->hasConverter($attr)) {
574+
$attrFilters[] = "{$attr}=" . $converterHub->str2filter($attr, $uid);
574575
} else {
575576
$attrFilters[] = "{$attr}={$escapedUid}";
576577
}
@@ -609,11 +610,13 @@ public function findUsersByUsername($uid) {
609610
*/
610611
private function getValueFromEntry($ldapEntry, $attrs) {
611612
$chosenValue = null;
613+
$converterHub = ConverterHub::getDefaultConverterHub();
614+
612615
foreach ($attrs as $attr) {
613616
if (isset($ldapEntry[$attr][0])) {
614617
$chosenValue = $ldapEntry[$attr][0];
615-
if ($attr === 'objectguid' || $attr === 'guid') {
616-
$chosenValue = Access::binGUID2str($chosenValue);
618+
if ($converterHub->hasConverter($attr)) {
619+
$chosenValue = $converterHub->bin2str($attr, $chosenValue);
617620
}
618621
break;
619622
}

0 commit comments

Comments
 (0)