private User GetGraphUserForImpersonation(AzureConfig settings, GraphClient graphClient, UserMapping idUserMapping) { var usernameWithoutPrefix = settings.UsernamePrefixEnabled ? UserInfo.Username.Substring(AzureConfig.ServiceName.Length + 1) : UserInfo.Username; var user = idUserMapping.B2cClaimName == "sub" ? graphClient.GetUser(usernameWithoutPrefix) : graphClient.GetAllUsers($"$filter={idUserMapping.GetB2cCustomAttributeName(settings.PortalID)} eq '{usernameWithoutPrefix}'").Values.FirstOrDefault(); return(user); }