Python-LDAP simple_bind_s 超时

标签 python timeout python-ldap

有没有办法在 python-LDAP 中手动为“simple_bind_s”设置超时?我已经测试了 ldapObject.timeout = 10 它对我不起作用。有什么想法吗?

提前致谢..

最佳答案

为 ldap 对象设置选项 ldap.OPT_NETWORK_TIMEOUT

import ldap

l = ldap.initialize('ldap://servername:389')
l.set_option(ldap.OPT_NETWORK_TIMEOUT, 10.0)
l.simple_bind_s('username', 'password')

如果达到指定的超时,这将引发 ldap.SERVER_DOWN 异常。

关于Python-LDAP simple_bind_s 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6679910/

相关文章:

Python TimedRotatingFileHandler - 日志文件名中的 PID - 最佳方法

Python Paramiko 和 IPV6 SSH

PHP connection_aborted() 无法正常工作

90 秒后 ASP.NET 请求超时 - 服务不可用 503

linux - 如何查看我的openldap目录树结构

python - 我怎样才能简单地计算 python 中时间序列的滚动/移动方差?

python - tkinter、python 和 seaborn 问题 : _tkinter. TclError:没有显示名称,也没有 $DISPLAY 环境变量

flask - 当 gunicorn 工作人员超时时,是否可以获得堆栈跟踪?

openssl - 使用 .start_tls_s() 时如何强制 Python LDAP 验证/验证 SSL 证书

Python:assertRaises()在引发时未捕获ldap.SERVER_DOWN错误