PDI-11151 - Check for sorted keys after LDAP connection

Fixed Null Pointer Exception, includes unit tests