Basically, you'd initialize the collection with the appropriate factory for each string, i.e.
map.put('A', <factoryA>);map.put('B', <factoryB>);...
Then you'd just retrieve the factory by map.get(username[0]).
One advantage of that approach would be that you're able to add more factories at runtime.
However, like Ravyne said, the client should not know about the concrete factories.
Instead it might know about a meta factory (or factory method), i.e. a factory that knows how to parse the user name and calls the appropriate concrete factory.
Then you would get something like this (heavily simplified):
//in your login codeUser user = metaFactory.create(username);...class MetaFactory{ private: map<char, conreteFactory> factories; public: User create(string username, /*more construction args*/) { return factories.get(username[0]).create(/*construction args, e.g. username*/); }}