Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python-LDAP simple_bind_s timeout

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..

like image 489
kursat Avatar asked Jul 13 '11 13:07

kursat


People also ask

How do I set LDAP timeout?

Click Security > Global Security. 2. Under Available Realm Definitions, choose "Standalone LDAP registry" and click Configure. This property sets a specified timeout value, in milliseconds, to be used when opening a communications link to the LDAP server.

What is LDAP connection timeout?

After trying to connect to the LDAP server during a certain amount of time, Informatica returns a "Timed out" message. In this case, the issue is because the user does not use the proper port to connect to the LDAP server. For an SSL encrypted connection, you must use port 636.

How do I use LDAP authentication in Python?

In order to use LDAP with Python we need to import the Server and the Connection object, and any additional constant we will use in our LDAP. As you might remember from the LDAP Protocol diagram the authentication operation is called Bind.


1 Answers

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.

like image 102
robots.jpg Avatar answered Sep 28 '22 08:09

robots.jpg