DS-1739 fix LDAP auth appending "null" to username

https://jira.duraspace.org/browse/DS-1739

Fix the problem plus minor cleanup to avoid similar problems.