inejge / ldap3

A pure-Rust LDAP library using the Tokio stack
Apache License 2.0
220 stars 38 forks source link

Can ldap connection reconnect? #81

Closed Zerowalker closed 2 years ago

Zerowalker commented 2 years ago

From my understanding you can clone the Ldap handle and keep reusing the same connection. In my tests it works fine except if the connection is broken (say the server is unavailable). Then it will forever fail unless i remake the connection.

So i wonder if it's possible to have it try to reconnect at certain intervals? That the cloned ldaps will fail during this is expected of course.

Also, does dropping a Ldap handle equal an unbind for just that one? cause i noticed if i unbind it will (as it says) close the connection which makes any future Ldap closed as well, which kinda makes it "useless" for closing when sharing a connection.

Thanks:)

inejge commented 2 years ago

So i wonder if it's possible to have it try to reconnect at certain intervals?

My preference for the library is to include the least possible amount of policy, and reconnection handling is all policy: how many targets? how often? for how long? etc. Of course, it's perfectly possible to make a wrapper to handle these matters and forward the operations to inner connections. I just don't see it as part of the library.

Also, does dropping a Ldap handle equal an unbind for just that one?

Not exactly, because LDAP is a multiplexed protocol, and an Ldap handle is an endpoint of a multiplexed operation substream, whereas unbind is (per spec) a global operation affecting the whole connection. Dropping the last Ldap handle will have the effect of unbind (closing the connection) but will not actually issue an Unbind operation (which is OK, servers must be prepared for that).

inejge commented 2 years ago

Since the first part is a WONTFIX, and the second a clarification not requiring a documentation update, I'll close this.

Zerowalker commented 2 years ago

Ah, it made things a bit clearer. It just shows that i don't understand how the ldap connection works.

Thanks:)