Skip to content

Commit

Permalink
[BUGFIX] fix getOneByField function which replaces, get one by uid
Browse files Browse the repository at this point in the history
  • Loading branch information
kaystrobach committed Nov 5, 2014
1 parent 39aca18 commit 6d0314b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
16 changes: 4 additions & 12 deletions Classes/KayStrobach/Ldap/Service/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,16 @@ public function ls($baseDn = NULL, $filter = '(objectClass=*)', $attributes = ar
}

/**
* @param string $uid
* @param string $value
* @param string $field
* @param bool $silentFail
* @throws OperationException
* @return \KayStrobach\Ldap\Service\Ldap\Entry|null
*/
public function getOneObjectByUid($uid, $silentFail = TRUE) {
public function getOneObjectByField($value, $field = 'uid', $silentFail = TRUE) {
$attributes = array('uid', 'dn', 'dn', 'givenname', 'sn', 'mail', 'uidnumber', 'employeetype', 'ou', 'displayName');
try {
$accounts = $this->search(NULL, '(uid=' . $uid . ')', $attributes);
$accounts = $this->search(NULL, '(' . $field . '=' . $value . ')', $attributes);
$count = $accounts->count();
if ($count === 1) {
$accounts->next();
Expand All @@ -287,15 +288,6 @@ public function getOneObjectByUid($uid, $silentFail = TRUE) {
return NULL;
}

/**
* @param $baseDn
* @param $filter
*/
public function ensureUnique($baseDn, $filter) {
$this->checkConnection();
$this->search($baseDn, $filter);
}

/**
* Queries the LDAP for the highest uid and adds one after wards ...
*
Expand Down
11 changes: 3 additions & 8 deletions Classes/KayStrobach/Ldap/Service/LdapInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,13 @@ public function search($baseDn = NULL, $filter = '(objectClass=*)', $attributes
public function ls($baseDn = NULL, $filter = '(objectClass=*)', $attributes = array('uid', 'dn', 'dn'), $valuesOnly = 0, $sizeLimit = NULL, $timeLimit = NULL, $deref = NULL);

/**
* @param string $uid
* @param string $value
* @param string $field
* @param bool $silentFail
* @throws OperationException
* @return \KayStrobach\Ldap\Service\Ldap\Entry|null
*/
public function getOneObjectByUid($uid, $silentFail = TRUE);

/**
* @param $baseDn
* @param $filter
*/
public function ensureUnique($baseDn, $filter);
public function getOneObjectByField($value, $field = 'uid', $silentFail = TRUE);

/**
* Queries the LDAP for the highest uid and adds one after wards ...
Expand Down

0 comments on commit 6d0314b

Please sign in to comment.