(imported from commit 0c5d8e2a55ba1b8909ba807fee3afe863dcdc226)
We fall back to guessing based on the realm if the user doesn't have a profile in our system (imported from commit 833885168c451074c885b4422d62986855a215f7)
(imported from commit 4a9a1bfc6c95763a816263a726cc61b3ca90bf15)