[API] Fix wierd ldap code.
[API] fix 500 error on first login.
[API] Fix realname extracting during creation from ldap.