Jerry Lee wrote:
> Hello,
>
> I'm adapting a QT LDAP browser using PyQT and Python-LDAP that will be
> freely available when it's useful - still a ways to got yet ;-)
>
> I have a question about bind.
> If I try to bind to a machine that isn't there, the app hangs for
> about 90 secs.
>
> It seems to be stuck at ldap.simple_bind.
>
> Is there a way to make it timeout after a certain amount of time?
>
> I've looked at set_option(OPT_NETWORK_TIMEOUT) and OPT_TIMEOUT but
> (assuming that bind actually looks at them) I can't figure out how to
> put meaningful values in there. Every time I
> set_option(OPT_NETWORK_TIMEOUT,5.0)
> meaning a timeout of 5 seconds and then check the value with
> get_option it reads
> 1.36904e+08 !!!!
Have you tried using an explicit timeout argument?
I usually call ldap.simple_bind this way:
l = ldap.open(LDAPServer)
id = l.simple_bind(LDAPbindUsername, LDAPbindPassword)
status,res = l.result(id, 1, 60)
if status != 'RES_BIND':
return -1
The third argument to ldap.result is indeed the timeout.
It usually appears to work :-)
Mauro Cicognini
|