Improve freeing of bufferevents

Manually set each bufferevent to NULL value after it is freed -
otherwise we are no able check whether the bufferevent was free.
Use ldap_sasl_bind

Because of ldap_simple_bind becomming deprecated.
Rewrite ldap_read_cb

React properly to LDAP responses and use AVL for resolving requests.
Remove useless comment
Prototypes changed
register_module_event needs a context

It needs to provide one to the callback.
Add ldap module dependency
A sketch on ldap usage
Change default URI to be parsable
Improve reseting connection
Style change
Create trigger for enabling/disabling imap listener
Improve freeing of ldap requests
Move ldap_{config,init} to the beggining of function definitions
move ldap config up
Add registration of events for ldap module
Call events in specific situations

Created function for traversing events queue and executing all events
with proper flags.
Small corrections in get_user_info
Add function declarations of ldap functions
Check properly ldap result code

ldap_parse_result had its 'freeit' argument set to 1 what caused the
messages to be unreadable.