Cleanup ldap encoding function