diff --git a/README.md b/README.md index 0e6ea14691837d42ed7dca7ba7b2ca30c9940acd..7b58f6804a2639af8eaf94711e632d4ceea92022 100644 --- a/README.md +++ b/README.md @@ -38,5 +38,6 @@ $ cp -n vendor/unicaen/zimbra/config/unicaen-ldap.local.php.dist config/autoload 'username' => "uid=xxxx,ou=system,dc=unicaen,dc=fr", 'password' => "xxxx", 'accountFilterFormat' => "(&(objectClass=supannPerson)(supannAliasLogin=%s))", + 'useStartTls' => false ] ``` \ No newline at end of file diff --git a/config/unicaen-ldap.local.php.dist b/config/unicaen-ldap.local.php.dist index dd8d54c08dc1722477cf66af54d26956d4591998..572a02ae6708df2ac27e51f545f3ddedfb6d6ba5 100644 --- a/config/unicaen-ldap.local.php.dist +++ b/config/unicaen-ldap.local.php.dist @@ -10,5 +10,6 @@ return [ 'username' => "uid=xxxxxxxxx,ou=xxxxxxxxxx,dc=domain,dc=fr", 'password' => "xxxxxxxxxxxx", 'accountFilterFormat' => "(&(objectClass=posixAccount)(supannAliasLogin=%s))", + 'useStartTls' => false ] ]; diff --git a/src/UnicaenLdap/Entity/Base/People.php b/src/UnicaenLdap/Entity/Base/People.php index 2a4c390220b88b7d987b1a87a86ef3856bbfe507..5170c27b301f57d1436c353a8c57a2a3dd663eca 100644 --- a/src/UnicaenLdap/Entity/Base/People.php +++ b/src/UnicaenLdap/Entity/Base/People.php @@ -2215,7 +2215,7 @@ class People extends Entity $uni = ''; $value = (string)$value; for ($i = 0; $i < strlen($value); $i++) { - $a = ord($value{$i}) << 8; + $a = ord($value[$i]) << 8; $uni .= sprintf('%X', $a); } $nthash = hash("md4", pack('H*', $uni), true); @@ -2238,7 +2238,7 @@ class People extends Entity $uni = ''; $value = (string)$value; for ($i = 0; $i < strlen($value); $i++) { - $a = ord($value{$i}) << 8; + $a = ord($value[$i]) << 8; $uni .= sprintf('%X', $a); } $nthash = hash("md4", pack('H*', $uni), true); diff --git a/src/UnicaenLdap/Options/ModuleOptions.php b/src/UnicaenLdap/Options/ModuleOptions.php index de4eb67ebc14b919891189065a425445a4ada419..1b8f4344a15e055ebb1cbe284ee510871efd9e60 100644 --- a/src/UnicaenLdap/Options/ModuleOptions.php +++ b/src/UnicaenLdap/Options/ModuleOptions.php @@ -67,6 +67,11 @@ class ModuleOptions extends AbstractOptions */ protected $accountFilterFormat; + /** + * @var bool + */ + protected $useStartTls; + public function getIterator() { return new \ArrayIterator($this); @@ -244,7 +249,25 @@ class ModuleOptions extends AbstractOptions */ public function setAccountFilterFormat($accountFilterFormat) { - $this->accountFilterFormat = (boolean)$accountFilterFormat; + $this->accountFilterFormat = (string)$accountFilterFormat; + return $this; + } + + /** + * @return bool + */ + public function getUseStartTls(): ?bool + { + return $this->useStartTls; + } + + /** + * @param bool $useStartTls + * @return $this + */ + public function setUseStartTls(bool $useStartTls): ModuleOptions + { + $this->useStartTls = $useStartTls; return $this; } @@ -257,11 +280,12 @@ class ModuleOptions extends AbstractOptions { return array( 'host' => $this->getHost(), - 'port' => $this->getPort(), + 'port' => $this->getPort(), 'username' => $this->getUsername(), 'password' => $this->getPassword(), 'bindRequiresDn' => $this->getBindRequiresDn(), 'baseDn' => $this->getBaseDn(), + 'useStartTls' => $this->getUseStartTls(), ); } } \ No newline at end of file diff --git a/src/UnicaenLdap/Service/AbstractService.php b/src/UnicaenLdap/Service/AbstractService.php index a741996879f908564b91d8f9eb2e1f1b0f230366..a604b5f886bdad313b8e5b75ea4e1be755e75bed 100644 --- a/src/UnicaenLdap/Service/AbstractService.php +++ b/src/UnicaenLdap/Service/AbstractService.php @@ -303,8 +303,10 @@ abstract class AbstractService implements $filter = $ouFilter . ")$filter)"; } $resource = $this->getLdap()->getResource(); + ErrorHandler::start(E_WARNING); if (null === $attributes) $search = ldap_search($resource, $basedn, $filter); else $search = ldap_search($resource, $basedn, $filter, $attributes); + ErrorHandler::stop(); if ($search === false) { throw new Exception('searching: ' . $filter); } diff --git a/tests/func/config/autoload/unicaen-ldap.local.php b/tests/func/config/autoload/unicaen-ldap.local.php index c573b208b8ccb6ff96dec55b4839f67a1e4eaa70..5d34e74c77e7e29df724770b823dfdd02db2973c 100644 --- a/tests/func/config/autoload/unicaen-ldap.local.php +++ b/tests/func/config/autoload/unicaen-ldap.local.php @@ -10,5 +10,6 @@ return array( 'username' => "uid=applidev,ou=system,dc=unicaen,dc=fr", 'password' => "***REMOVED***", 'accountFilterFormat' => "(&(objectClass=posixAccount)(supannAliasLogin=%s))", + 'useStartTls' => false ) ); \ No newline at end of file