Python-LDAP timeout simple_bind_s

Is there a way to set the timeout for "simple_bind_s" in python-LDAP manually? I tested ldapObject.timeout = 10, this did not work for me. Any ideas?

Thanks in advance.

+6
source share
2 answers

Set the ldap.OPT_NETWORK_TIMEOUT option to 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 throw an ldap.SERVER_DOWN exception if the specified timeout is reached.

+10
source

For some reason ldap.OPT_NETWORK_TIMEOUT does not seem to time out to me, so instead of ldap.OPT_TIMEOUT I used ldap.OPT_TIMEOUT :

 import ldap l = ldap.initialize('ldaps://ldap.example.com') l.set_option(ldap.OPT_TIMEOUT, 10) l.simple_bind_s('username', 'password') 
+3
source

Source: https://habr.com/ru/post/892681/


All Articles