Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'Maks3w/hotfix/ZF-27-LDAP'
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 35 changed files with 169 additions and 189 deletions.
42 changes: 19 additions & 23 deletions src/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,24 @@ class Attribute
/**
* Sets a LDAP attribute.
*
* @param array $data
* @param string $attribName
* @param scalar|array|Traversable $value
* @param boolean $append
* @param array $data
* @param string $attribName
* @param string|array|\Traversable $value
* @param boolean $append
* @return void
*/
public static function setAttribute(array &$data, $attribName, $value, $append = false)
{
$attribName = strtolower($attribName);
$valArray = array();
if (is_array($value) || ($value instanceof \Traversable)) {
foreach ($value as $v)
{
foreach ($value as $v) {
$v = self::valueToLdap($v);
if ($v !== null) {
$valArray[] = $v;
}
}
} elseif ($value !== null) {
} else if ($value !== null) {
$value = self::valueToLdap($value);
if ($value !== null) {
$valArray[] = $value;
Expand Down Expand Up @@ -90,8 +89,7 @@ public static function getAttribute(array $data, $attribName, $index = null)
return array();
}
$retArray = array();
foreach ($data[$attribName] as $v)
{
foreach ($data[$attribName] as $v) {
$retArray[] = self::valueFromLDAP($v);
}
return $retArray;
Expand Down Expand Up @@ -173,8 +171,7 @@ public static function removeFromAttribute(array &$data, $attribName, $value)
}

$valArray = array();
foreach ($value as $v)
{
foreach ($value as $v) {
$v = self::valueToLDAP($v);
if ($v !== null) {
$valArray[] = $v;
Expand Down Expand Up @@ -284,16 +281,16 @@ public static function convertFromLdapDateTimeValue($value)
/**
* Sets a LDAP password.
*
* @param array $data
* @param string $password
* @param string $hashType
* @param string|null $attribName
* @return null
* @param array $data
* @param string $password
* @param string $hashType Optional by default MD5
* @param string $attribName Optional
*/
public static function setPassword(
array &$data, $password, $hashType = self::PASSWORD_HASH_MD5,
$attribName = null
) {
)
{
if ($attribName === null) {
if ($hashType === self::PASSWORD_UNICODEPWD) {
$attribName = 'unicodePwd';
Expand Down Expand Up @@ -360,12 +357,11 @@ public static function createPassword($password, $hashType = self::PASSWORD_HASH
/**
* Sets a LDAP date/time attribute.
*
* @param array $data
* @param string $attribName
* @param integer|array|Traversable $value
* @param boolean $utc
* @param boolean $append
* @return null
* @param array $data
* @param string $attribName
* @param integer|array|\Traversable $value
* @param boolean $utc
* @param boolean $append
*/
public static function setDateTimeAttribute(
array &$data, $attribName, $value, $utc = false,
Expand Down
26 changes: 14 additions & 12 deletions src/Collection/DefaultIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

namespace Zend\Ldap\Collection;

use Zend\Ldap,
Zend\Ldap\Exception;
use Zend\Ldap;
use Zend\Ldap\Exception;

/**
* Zend\Ldap\Collection\DefaultIterator is the default collection iterator implementation
Expand All @@ -41,7 +41,7 @@ class DefaultIterator implements \Iterator, \Countable
/**
* LDAP Connection
*
* @var Ldap\Ldap
* @var \Zend\Ldap\Ldap
*/
protected $ldap = null;

Expand Down Expand Up @@ -76,10 +76,10 @@ class DefaultIterator implements \Iterator, \Countable
/**
* Constructor.
*
* @param Ldap\Ldap $ldap
* @param resource $resultId
* @return void
* @throws Exception\LdapException if no entries was found.
* @param \Zend\Ldap\Ldap $ldap
* @param resource $resultId
* @throws \Zend\Ldap\Exception\LdapException if no entries was found.
* @return DefaultIterator
*/
public function __construct(Ldap\Ldap $ldap, $resultId)
{
Expand Down Expand Up @@ -115,7 +115,7 @@ public function close()
/**
* Gets the current LDAP connection.
*
* @return Ldap\Ldap
* @return \Zend\Ldap\Ldap
*/
public function getLDAP()
{
Expand Down Expand Up @@ -190,7 +190,7 @@ public function count()
* Implements Iterator
*
* @return array|null
* @throws Exception\LdapException
* @throws \Zend\Ldap\Exception\LdapException
*/
public function current()
{
Expand Down Expand Up @@ -239,8 +239,8 @@ public function current()
* Return the result item key
* Implements Iterator
*
* @throws \Zend\Ldap\Exception\LdapException
* @return string|null
* @throws Exception\LdapException if can't get Dn.
*/
public function key()
{
Expand All @@ -263,7 +263,8 @@ public function key()
* Move forward to next result item
* Implements Iterator
*
* @throws Exception\LdapException
* @throws \Zend\Ldap\Exception\LdapException
* @return
*/
public function next()
{
Expand All @@ -289,7 +290,8 @@ public function next()
* Rewind the Iterator to the first result item
* Implements Iterator
*
* @throws Exception\LdapException
*
* @throws \Zend\Ldap\Exception\LdapException
*/
public function rewind()
{
Expand Down
1 change: 1 addition & 0 deletions src/Dn.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public function getRdnString($caseFold = null)
* Get the parent DN $levelUp levels up the tree
*
* @param int $levelUp
* @throws Exception\LdapException
* @return Dn
*/
public function getParentDn($levelUp = 1)
Expand Down
4 changes: 1 addition & 3 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@

namespace Zend\Ldap\Exception;

use Zend\Ldap\Exception;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class BadMethodCallException extends \BadMethodCallException implements Exception
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
{
}
4 changes: 2 additions & 2 deletions src/Exception.php → src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Ldap;
namespace Zend\Ldap\Exception;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception
interface ExceptionInterface
{
}
4 changes: 1 addition & 3 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@

namespace Zend\Ldap\Exception;

use Zend\Ldap\Exception;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidArgumentException extends \InvalidArgumentException implements Exception
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
}
11 changes: 5 additions & 6 deletions src/Exception/LdapException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@

namespace Zend\Ldap\Exception;

use Zend\Ldap\Ldap,
Zend\Ldap\Exception;
use Zend\Ldap\Ldap;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class LdapException extends \Exception implements Exception
class LdapException extends \Exception implements ExceptionInterface
{
const LDAP_SUCCESS = 0x00;
const LDAP_OPERATIONS_ERROR = 0x01;
Expand Down Expand Up @@ -114,9 +113,9 @@ class LdapException extends \Exception implements Exception
const LDAP_X_EXTENSION_NOT_LOADED = 0x7002;

/**
* @param Ldap $ldap A Zend\Ldap\Ldap object
* @param string $str An informtive exception message
* @param int $code An LDAP error code
* @param Ldap $ldap Zend\Ldap\Ldap object
* @param string $str Informative exception message
* @param int $code LDAP error code
*/
public function __construct(Ldap $ldap = null, $str = null, $code = 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Ldap\Filter;
namespace Zend\Ldap\Filter\Exception;

use Zend\Ldap;
use Zend\Ldap\Exception\ExceptionInterface as MainLdapException;

/**
* @category Zend
* @package Zend_Ldap
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception extends Ldap\Exception
interface ExceptionInterface extends MainLdapException
{
}
4 changes: 1 addition & 3 deletions src/Filter/Exception/FilterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@

namespace Zend\Ldap\Filter\Exception;

use Zend\Ldap\Filter\Exception;

/**
* @category Zend
* @package Zend_Ldap
* @subpackage Filter
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class FilterException extends \Exception implements Exception
class FilterException extends \Exception implements ExceptionInterface
{
}
1 change: 1 addition & 0 deletions src/Filter/LogicalFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ abstract class LogicalFilter extends AbstractFilter
*
* @param array $subfilters
* @param string $symbol
* @throws Exception\FilterException
*/
protected function __construct(array $subfilters, $symbol)
{
Expand Down
16 changes: 7 additions & 9 deletions src/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ class Ldap
* Constructor.
*
* @param array|Traversable $options Options used in connecting, binding, etc.
* @return void
* @throws Exception\LdapException if ext/ldap is not installed
* @throws Exception\LdapException
*/
public function __construct($options = array())
{
Expand Down Expand Up @@ -175,9 +174,8 @@ public function getLastError(&$errorCode = null, array &$errorMessages = null)
$message = '';
if ($errorCode > 0) {
$message = '0x' . dechex($errorCode) . ' ';
} else {
$message = '';
}

if (count($errorMessages) > 0) {
$message .= '(' . implode('; ', $errorMessages) . ')';
} else {
Expand All @@ -194,7 +192,7 @@ public function getLastError(&$errorCode = null, array &$errorMessages = null)
* NULL if there has been an anonymous bind
* username of the currently bound user
*
* @return false|null|string
* @return bool|null|string
*/
public function getBoundUser()
{
Expand Down Expand Up @@ -452,14 +450,13 @@ protected function getNetworkTimeout()
}

/**
* @param strint $acctname
* @param string $acctname
* @return string The LDAP search filter for matching directory accounts
*/
protected function getAccountFilter($acctname)
{
$dname = '';
$aname = '';

$this->splitName($acctname, $dname, $aname);
$accountFilterFormat = $this->getAccountFilterFormat();
$aname = Filter\AbstractFilter::escapeValue($aname);
Expand Down Expand Up @@ -1074,8 +1071,8 @@ public function getEntry($dn, array $attributes = array(), $throwOnNotFound = fa
* Prepares an ldap data entry array for insert/update operation
*
* @param array $entry
* @throws Exception\InvalidArgumentException
* @return void
* @throws InvalidArgumentException\LdapException
*/
public static function prepareLdapEntryArray(array &$entry)
{
Expand Down Expand Up @@ -1263,6 +1260,7 @@ public function delete($dn, $recursively = false)
* or {@see copy()}
*
* @param string|Dn $parentDn
* @throws Exception\LdapException
* @return array of DNs
*/
protected function getChildrenDns($parentDn)
Expand Down Expand Up @@ -1338,7 +1336,7 @@ public function move($from, $to, $recursively = false, $alwaysEmulate = false)
/**
* Renames a LDAP entry from one DN to another DN.
*
* This method implicitely moves the entry to another location within the tree.
* This method implicitly moves the entry to another location within the tree.
*
* @param string|Dn $from
* @param string|Dn $to
Expand Down
4 changes: 2 additions & 2 deletions src/Ldif/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ protected function _encode($value)
*
* @link http://www.faqs.org/rfcs/rfc2849.html
*
* @param string $string
* @param boolen $base64
* @param string $string
* @param boolean $base64
* @return string
*/
protected function encodeString($string, &$base64 = null)
Expand Down
Loading

0 comments on commit f50be5f

Please sign in to comment.