[api] Fixed an issue where an LDAP connection unbind can be performed when a connection is not bound (when LDAP server is not running for example)