public function deactivate($username)
    {
        if (!$this->config->get('concrete.user.deactivation.authentication_failure.enabled', false)) {
            return;
        }

        $user = $this->resolveUser($username);
        if (!$user) {
            throw new InvalidArgumentException(t('Unable to find and deactivate given user'));
        }

        $event = DeactivateUser::create($user);
        $this->director->dispatch('on_before_user_deactivate', $event);

        // Here we could retrieve the user entity from the event and allow an event handler to change which user gets
        // deactivated, but we don't want to support that at the moment
        // $user = $event->getUserEntity();

        // Set the user to inactive
        $this->entityManager->transactional(function(EntityManagerInterface $localManager) use ($user) {
            $user = $localManager->merge($user);
            $user->setUserIsActive(false);
        });

        // Send out a `user_deactivate` event
        $this->director->dispatch('on_after_user_deactivate', $event);
    }