/** * Bind the interfaces to their implementations in the service container. */ public function registerLdapInterfaces() { $this->app->bind('LaravelAuthLdap\\Contracts\\LdapServer', function ($app) { $server = new AdLDAPLdapServer(); $server->setAdServer(new adLDAP($app->config['adldap'])); return $server; }); $this->app->bind('LaravelAuthLdap\\Contracts\\LdapUser', function ($app) { $user = new BaseLdapUser(); $user->setConvertFields($app->config['auth-ldap.convert_fields']); $user->setUsernameField($app->config['auth-ldap.username_field']); return $user; }); $this->app->bind('LaravelAuthLdap\\Contracts\\LdapUserProvider', function ($app) { $provider = new BaseLdapUserProvider(); $driverName = array_get($app->config['auth-ldap'], 'provider.driver'); if ($driverName !== null) { $driver = $this->app['auth']->driver($driverName); $provider->setProvider($driver->getProvider()); } $provider->setLdapServer($app->make('LaravelAuthLdap\\Contracts\\LdapServer')); $mustExist = array_get($app->config['auth-ldap'], 'provider.must_exist'); $provider->setUserMustExistInProvider($mustExist === null ? false : $mustExist); $provider->setCredentialsFields($app->config['auth-ldap.credentials_fields']); return $provider; }); }
public function testGetAuthIdentifier() { $usernameField = 'username'; $username = '******'; $user = new stdClass(); $user->{$usernameField} = $username; $this->baseLdapUser->setUser($user); $this->baseLdapUser->setUsernameField($usernameField); // check that the identifier is being pulled correctly $this->assertEquals($username, $this->baseLdapUser->getAuthIdentifier()); }