return ldap_set_option($ldapConnection, $option, $value);
}
+ /**
+ * Set the version number for the given ldap connection.
+ * @param $ldapConnection
+ * @param $version
+ * @return bool
+ */
+ public function setVersion($ldapConnection, $version)
+ {
+ return $this->setOption($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, $version);
+ }
+
/**
* Search LDAP tree using the provided filter.
* @param resource $ldapConnection
// Set any required options
if ($this->config['version']) {
- $this->ldap->setOption($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, $this->config['version']);
+ $this->ldap->setVersion($ldapConnection, $this->config['version']);
}
$this->ldapConnection = $ldapConnection;
public function test_login()
{
$this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId);
- $this->mockLdap->shouldReceive('setOption')->once();
+ $this->mockLdap->shouldReceive('setVersion')->once();
$this->mockLdap->shouldReceive('searchAndGetEntries')->times(4)
->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array'))
->andReturn(['count' => 1, 0 => [
public function test_login_works_when_no_uid_provided_by_ldap_server()
{
$this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId);
- $this->mockLdap->shouldReceive('setOption')->once();
+ $this->mockLdap->shouldReceive('setVersion')->once();
$ldapDn = 'cn=test-user,dc=test' . config('services.ldap.base_dn');
$this->mockLdap->shouldReceive('searchAndGetEntries')->times(2)
->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array'))
public function test_initial_incorrect_details()
{
$this->mockLdap->shouldReceive('connect')->once()->andReturn($this->resourceId);
- $this->mockLdap->shouldReceive('setOption')->once();
+ $this->mockLdap->shouldReceive('setVersion')->once();
$this->mockLdap->shouldReceive('searchAndGetEntries')->times(2)
->with($this->resourceId, config('services.ldap.base_dn'), Mockery::type('string'), Mockery::type('array'))
->andReturn(['count' => 1, 0 => [