예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function __construct($configuration = [], $connection = null, SchemaInterface $schema = null)
 {
     // Set the configuration.
     $this->setConfiguration($configuration);
     if (!$connection instanceof ConnectionInterface) {
         // Get the default LDAP Connection instance if
         // one hasn't been instantiated yet.
         $connection = $this->getDefaultConnection();
     }
     if (!$schema instanceof SchemaInterface) {
         // Create a new LDAP Schema instance if
         // one hasn't been instantiated yet.
         $schema = Schema::get();
     }
     // Set the connection.
     $this->setConnection($connection);
     // Set the schema.
     $this->setSchema($schema);
 }
예제 #2
0
 /**
  * Assembles the domain components in the Distinguished Name.
  *
  * @return null|string
  */
 public function assembleDcs()
 {
     return $this->assembleRdns(Schema::get()->domainComponent(), $this->domainComponents);
 }
예제 #3
0
 public function test_config_login_fallback()
 {
     $this->app['config']->set('adldap_auth.login_fallback', true);
     $mockedProvider = $this->mock(Provider::class);
     $mockedSearch = $this->mock(Factory::class);
     $mockedConnection = $this->mock(ConnectionInterface::class);
     $mockedConnection->shouldReceive('isBound')->twice()->andReturn(true);
     $mockedSearch->shouldReceive('users')->twice()->andReturn($mockedSearch);
     $mockedSearch->shouldReceive('select')->twice()->andReturn($mockedSearch);
     $mockedSearch->shouldReceive('getConnection')->twice()->andReturn($mockedConnection);
     $mockedSearch->shouldReceive('whereEquals')->twice()->andReturn($mockedSearch);
     $mockedSearch->shouldReceive('first')->twice()->andReturn(null);
     $manager = new Manager();
     $manager->add('default', $mockedProvider);
     $mockedProvider->shouldReceive('search')->twice()->andReturn($mockedSearch);
     $mockedProvider->shouldReceive('getSchema')->twice()->andReturn(Schema::get());
     Adldap::shouldReceive('getManager')->andReturn($manager);
     EloquentUser::create(['email' => '*****@*****.**', 'name' => 'John Doe', 'password' => bcrypt('Password123')]);
     $credentials = ['email' => '*****@*****.**', 'password' => 'Password123'];
     $outcome = Auth::attempt($credentials);
     $user = \Auth::user();
     $this->assertTrue($outcome);
     $this->assertInstanceOf('Adldap\\Laravel\\Tests\\Models\\User', $user);
     $this->assertEquals('*****@*****.**', $user->email);
     $this->app['config']->set('adldap_auth.login_fallback', false);
     $outcome = Auth::attempt($credentials);
     $this->assertFalse($outcome);
 }