Showing
3 changed files
with
15 additions
and
4 deletions
| ... | @@ -34,6 +34,17 @@ class Ldap | ... | @@ -34,6 +34,17 @@ class Ldap |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | + * Set the version number for the given ldap connection. | ||
| 38 | + * @param $ldapConnection | ||
| 39 | + * @param $version | ||
| 40 | + * @return bool | ||
| 41 | + */ | ||
| 42 | + public function setVersion($ldapConnection, $version) | ||
| 43 | + { | ||
| 44 | + return $this->setOption($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, $version); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** | ||
| 37 | * Search LDAP tree using the provided filter. | 48 | * Search LDAP tree using the provided filter. |
| 38 | * @param resource $ldapConnection | 49 | * @param resource $ldapConnection |
| 39 | * @param string $baseDn | 50 | * @param string $baseDn | ... | ... |
| ... | @@ -122,7 +122,7 @@ class LdapService | ... | @@ -122,7 +122,7 @@ class LdapService |
| 122 | 122 | ||
| 123 | // Set any required options | 123 | // Set any required options |
| 124 | if ($this->config['version']) { | 124 | if ($this->config['version']) { |
| 125 | - $this->ldap->setOption($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, $this->config['version']); | 125 | + $this->ldap->setVersion($ldapConnection, $this->config['version']); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | $this->ldapConnection = $ldapConnection; | 128 | $this->ldapConnection = $ldapConnection; | ... | ... |
| ... | @@ -22,7 +22,7 @@ class LdapTest extends \TestCase | ... | @@ -22,7 +22,7 @@ class LdapTest extends \TestCase |
| 22 | public function test_login() | 22 | public function test_login() |
| 23 | { | 23 | { |
| 24 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); | 24 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); |
| 25 | - $this->mockLdap->shouldReceive('setOption')->once(); | 25 | + $this->mockLdap->shouldReceive('setVersion')->once(); |
| 26 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(4) | 26 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(4) |
| 27 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) | 27 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) |
| 28 | ->andReturn(['count' => 1, 0 => [ | 28 | ->andReturn(['count' => 1, 0 => [ |
| ... | @@ -49,7 +49,7 @@ class LdapTest extends \TestCase | ... | @@ -49,7 +49,7 @@ class LdapTest extends \TestCase |
| 49 | public function test_login_works_when_no_uid_provided_by_ldap_server() | 49 | public function test_login_works_when_no_uid_provided_by_ldap_server() |
| 50 | { | 50 | { |
| 51 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); | 51 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); |
| 52 | - $this->mockLdap->shouldReceive('setOption')->once(); | 52 | + $this->mockLdap->shouldReceive('setVersion')->once(); |
| 53 | $ldapDn = 'cn=test-user,dc=test' . config('services.ldap.base_dn'); | 53 | $ldapDn = 'cn=test-user,dc=test' . config('services.ldap.base_dn'); |
| 54 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2) | 54 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2) |
| 55 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) | 55 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) |
| ... | @@ -73,7 +73,7 @@ class LdapTest extends \TestCase | ... | @@ -73,7 +73,7 @@ class LdapTest extends \TestCase |
| 73 | public function test_initial_incorrect_details() | 73 | public function test_initial_incorrect_details() |
| 74 | { | 74 | { |
| 75 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); | 75 | $this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId); |
| 76 | - $this->mockLdap->shouldReceive('setOption')->once(); | 76 | + $this->mockLdap->shouldReceive('setVersion')->once(); |
| 77 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2) | 77 | $this->mockLdap->shouldReceive('searchAndGetEntries')->times(2) |
| 78 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) | 78 | ->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array')) |
| 79 | ->andReturn(['count' => 1, 0 => [ | 79 | ->andReturn(['count' => 1, 0 => [ | ... | ... |
-
Please register or sign in to post a comment