Fix identity and user retrieval when special characters are used
Fixes#4023
I also added tests to make sure the user with special characters in his name is returned correctly.
@rspeicher this probably should be added to 8.3 as a patch.
See merge request !2176