我怎样才能使ldap_simple_bind_s超时? [英] How can I cause ldap_simple_bind_s to timeout?

查看:1907
本文介绍了我怎样才能使ldap_simple_bind_s超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近有我们的测试LDAP服务器的问题 - 这是雄,不会响应请求。这样一来,我们的应用程序挂起永远*试图绑定到它。这仅发生在Unix机器 - 在Windows上, ldap_simple_bind_s 通话约30秒后超时

We recently had a problem with our test LDAP server - it was hung and wouldn't respond to requests. As a result, our application hung forever* while trying to bind to it. This only happened on Unix machines - on Windows, the ldap_simple_bind_s call timed out after about 30 seconds.

*我不知道这是否真的是的永久的,但它至少几分钟。

* I don't know if it really was forever, but it was at least several minutes.

我加入 ldap_set_option 通话,试图既 LDAP_OPT_TIMEOUT LDAP_OPT_NETWORK_TIMEOUT ,但绑定调用仍然挂起。有没有什么办法让 ldap_simple_bind_s 超时我选择的一段时间后?

I added calls to ldap_set_option, trying both LDAP_OPT_TIMEOUT and LDAP_OPT_NETWORK_TIMEOUT, but the bind call still hung. Is there any way to make ldap_simple_bind_s time out after some period of time of my choosing?

推荐答案

有几件事情发生在这里。

There are a couple of things happening here.

基本上LDAP SDK被打破;根据该规范根据您的ldap_set_option发送的值应该已超时。遗憾的是它没有这样做正确。您的绑定可能会最终超时,但它不会是直到在OS返回回一个失败,并且将来自TCP超时或超时的某一倍数。

Basically the LDAP SDK is broken; based on the spec it should have timed out based upon the value you sent in ldap_set_option. Unfortunately it's not doing that properly. Your bind will probably eventually time out, but it won't be until the OS returns back a failure, and that will come from the TCP timeout or some multiple of that timeout.

您可以通过使用ldap_simple_bind(),然后调用ldap_result()几次解决此问题。如果你没有得到结果的超时时间内回到你愿意,你可以调用ldap_abandon_ext()来告诉SDK放弃。

You can work around this by using ldap_simple_bind(), then calling ldap_result() a couple of times. If you don't get the result back within the timeout you want you can call ldap_abandon_ext() to tell the SDK to give up.

当然,因为你试图绑定,这将几乎肯定离开处于不可用状态的连接,所以你需要立即解除它。

Of course since you're trying to bind this will almost certainly leave the connection in an unusable state and so you will need to unbind it immediately.

希望这有助于。

这篇关于我怎样才能使ldap_simple_bind_s超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆