ldap.py: setdn, getdn, discover work for groups.

This commit adds two new API methods required for the
mentioned CLI commands to work. Some of the code could be
optimised further as it is similar to the user-handling
API logic.