backport of #10340

better check whether string resembles a DN, fixes #9887

adjust login test to code changes

unify tests