pauldorman/clj-ldap — pull request #8 by ah45 (2014-10-08 15:14:07+00:00)
Title: Ensure bind? calls against connection pools leave connections unchanged

Without an explicit release connections from connection pools will keep the new binding. This can cause errors, especially when the bind fails.

For example, running the following in the REPL (with appropriate substitutions) will result in an exception being raised on the second call to `get-then-bind` because the previous bind will have left the connection in an invalid state:

```clojure
(require '[clj-ldap.client :as ldap])

(let [get-then-bind (fn [c dn pw]
(let [u (ldap/get c dn)]
(ldap/bind? c dn pw)))
c (ldap/connect {:host ["localhost:389"]
:bind-dn "cn=A User,ou=Users,dc=example,dc=com"
:password "password"})
dn "cn=An Example,ou=Users,dc=example,dc=com"
fail-pw "aksjdlajl"]
(do (get-then-bind c dn fail-pw)
(get-then-bind c dn fail-pw)))
````

Per the [Unboundid LDAP SDK documentation for bind][bind-docs]:

> Note that this will impact the state of the connection in the pool, and therefore this method should only be used if this connection pool is used exclusively for processing bind operations, or if the retain identity request control (only available in the Commercial Edition of the LDAP SDK for use with the UnboundID Directory Server) is included in the bind request to ensure that the authentication state is not impacted.

[bind-docs]: https://www.unboundid.com/products/ldap-sdk/docs/javadoc/com/unboundid/ldap/sdk/AbstractConnectionPool.html#bind(com.unboundid.ldap.sdk.BindRequest)

This patch ensures that the `bind?` method adheres to the contract expressed by the documentation (leaves connection pool connection state unchanged.)