ipa-kdb: remove memory leaks

All known memory leaks caused by unfreed allocated memory or unfreed
LDAP results (which should be also done after unsuccessful searches)
are fixed.

https://fedorahosted.org/freeipa/ticket/3413
ipa-kdb: fix retry logic in ipadb_deref_search

This function retried an LDAP search when the result was OK due to
flawed logic of retry detection (ipadb_need_retry function which
returns true when we need retry and not 0).

https://fedorahosted.org/freeipa/ticket/3413
ipa-kdb: Free talloc autofree context when module is closed

Currently kdb5kdc crashes on exit if the ipadb KDB modules is loaded and trusts
are configured. The reason is the talloc autofree context which get initialised
during the ndr_push_union_blob() call. On exit the KDC module is unloaded an
later on atexit() tries to free the context, but all related symbols are
already unloaded with the module.

This patch frees the talloc autofree context during the cleanup routine of the
module. Since this is called only at exit and not during normal operations this
is safe even if other KDC plugins use the talloc autofree context, e.g. via
some Samba libraries, as well.

Fixes https://fedorahosted.org/freeipa/ticket/3410
Add custom mapping object for LDAP entry data.
Remove some unused imports

Remove all unused LDAP-related imports, plus some other ones.

This should make it easier to quickly check what uses which LDAP wrapper
Remove unused methods from Entry, Entity, and IPAdmin

These classes are deprecated, there's no use keeping unused methods around.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Derive Entity class from Entry, and move it to ldapupdate

The two classes were nearly identical, and the updater is
the only code that uses Entity.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Use explicit loggers in ldap2 code

This change makes it easier to see what is going on, in addition
to getting rid of pylint exceptions.

Also, make logging imports use explicit names instead of `import *`.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Move LDAPEntry to ipaserver.ipaldap and derive Entry from it

Legacy Entry methods such as setValue are added to LDAPEntry directly,
so that we can use connection classes that return LDAPEntry with
code that expects Entries.

The Entry and its unique __init__ are still kept for compatibility.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Remove connection-creating code from ShemaCache

The connection code depends on the api object. If we want to use
the cache in installer code, where the api object is not always
available, the dependency must be removed.

Luckily, SchemaCache.get_schema is currently always given a connection.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Move the decision to force schema updates out of IPASimpleLDAPObject

This decision used the api object, which might not be available
in installer code. Move the decision to callers.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Move SchemaCache and IPASimpleLDAPObject to ipaserver.ipaldap

The ldap2 plugin should only contain the actual CRUDBackend plugin.
Common LDAP classes are moved to ipaldap.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Start LDAPConnection, a common base for ldap2 and IPAdmin

The first method to be extracted is handle_errors

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Make IPAdmin not inherit from IPASimpleLDAPObject

Instead of inheritance, the LDAPObject is kept in a `conn` attribute,
as the ldap2 class does it.
However, all IPASimpleLDAPObject methods are still available as before
(using __getattr__-based proxying).

Also, remove the IPAEntryLDAPObject class. The methods it overrode
were never called in ways that would make them behave differently than
the superclass.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Move schema-related methods to LDAPConnection

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Move DN handling methods to LDAPConnection

ldap2 has "DN normalization" functionality, which silently adds the base
DN to DNs that don't already end with it.
This functionality is left in the ldap2 class only.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Move filter making methods to LDAPConnection

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Move entry finding methods to LDAPConnection

The get_ipa_config method relies on IPA being installed.
Leave the implementation in ldap2, and add stub get_ipa_config that
simply returns an empty dictionary to LDAPConnection.

The get_members method contains an optimization that also relies on
the api object. The optimization is disabled in base LDAPConfig.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Remove unused proxydn functionality from IPAdmin

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660
Move entry add, update, remove, rename to LDAPConnection

Also remove _FORCE_REPLACE_ON_UPDATE_ATTRS which was never used.

Part of the work for: https://fedorahosted.org/freeipa/ticket/2660