Is there a way to set timeout for "simple_bind_s" in python-LDAP manually? I have tested ldapObject.timeout = 10 it did not work for me. Any ideas?
Thanks in advance..
Set the option ldap.OPT_NETWORK_TIMEOUT
for the ldap object.
import ldap
l = ldap.initialize('ldap://servername:389')
l.set_option(ldap.OPT_NETWORK_TIMEOUT, 10.0)
l.simple_bind_s('username', 'password')
This will raise a ldap.SERVER_DOWN exception if the specified timeout is reached.
For some reason ldap.OPT_NETWORK_TIMEOUT
never seems to time out for me, so I used ldap.OPT_TIMEOUT
instead (which will raise ldap.TIMEOUT
):
import ldap
l = ldap.initialize('ldaps://ldap.example.com')
l.set_option(ldap.OPT_TIMEOUT, 10)
l.simple_bind_s('username', 'password')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.