diff --git a/accounts/pkg/service/v0/accounts.go b/accounts/pkg/service/v0/accounts.go index af4a9c068c..bca89e9765 100644 --- a/accounts/pkg/service/v0/accounts.go +++ b/accounts/pkg/service/v0/accounts.go @@ -122,9 +122,15 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest } ids, err := s.index.FindBy(&proto.Account{}, "OnPremisesSamAccountName", match[1]) - if err != nil || len(ids) != 1 { + if err != nil || len(ids) > 1 { return merrors.Unauthorized(s.id, "account not found or invalid credentials") } + if len(ids) == 0 { + ids, err = s.index.FindBy(&proto.Account{}, "Mail", match[1]) + if err != nil || len(ids) != 1 { + return merrors.Unauthorized(s.id, "account not found or invalid credentials") + } + } a := &proto.Account{} err = s.repo.LoadAccount(ctx, ids[0], a)