LdapUser example



        return $this->loadUser($identifier$entry);
    }

    public function refreshUser(UserInterface $user): UserInterface
    {
        if (!$user instanceof LdapUser) {
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
        }

        return new LdapUser($user->getEntry()$user->getUserIdentifier()$user->getPassword()$user->getRoles()$user->getExtraFields());
    }

    /** * @final */
    public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
    {
        if (!$user instanceof LdapUser) {
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
        }

        
$provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={user_identifier})', 'userpassword', ['memberOf']);
        $user = $provider->loadUserByIdentifier('foo');
        $this->assertInstanceOf(LdapUser::class$user);
        $this->assertSame(['memberOf' => $memberOf]$user->getExtraFields());
    }

    public function testRefreshUserShouldReturnUserWithSameProperties()
    {
        $ldap = $this->createMock(LdapInterface::class);
        $provider = new LdapUserProvider($ldap, 'ou=MyBusiness,dc=symfony,dc=com', null, null, [], 'sAMAccountName', '({uid_key}={user_identifier})', 'userpassword', ['email']);

        $user = new LdapUser(new Entry('foo'), 'foo', 'bar', ['ROLE_DUMMY']['email' => 'foo@symfony.com']);

        $this->assertEquals($user$provider->refreshUser($user));
    }
}
Home | Imprint | This part of the site doesn't use cookies.