Neos.Neos/Classes/Domain/Service/UserService.php
public function getUsername(User $user, $authenticationProviderName = null)
    {
        $authenticationProviderName = $authenticationProviderName ?: $this->defaultAuthenticationProviderName;
        foreach ($user->getAccounts() as $account) {
            /** @var Account $account */
            if ($account->getAuthenticationProviderName() === $authenticationProviderName) {
                return $account->getAccountIdentifier();
            }
        }
        return null;
    }
public function getUsername(User $user, $authenticationProviderName = null)
    {
        $authenticationProviderName = $authenticationProviderName ?: $this->defaultAuthenticationProviderName;
        foreach ($user->getAccounts() as $account) {
            /** @var Account $account */
            if ($account->getAuthenticationProviderName() === $authenticationProviderName) {
                return $account->getAccountIdentifier();
            }
        }
        return null;
    }
public function getUsername ( User $ user , $ authenticationProviderName = null ) { $ authenticationProviderName = $ authenticationProviderName ? : $ this -> defaultAuthenticationProviderName ; foreach ( $ user -> getAccounts ( ) as $ account ) { /** @var Account $account */ if ( $ account -> getAuthenticationProviderName ( ) === $ authenticationProviderName ) { return $ account -> getAccountIdentifier ( ) ; } } return null ; }
Returns the username of the given user

Technically, this method will look for the user's backend account (or, if authenticationProviderName is specified,
for the account matching the given authentication provider) and return the account's identifier.

@param User $user
@param string $authenticationProviderName
@return string The username or null if the given user does not have a backend account
Returns the username of the given user