Fix LDAP backend option setting.

Review Request #388 — Created May 15, 2008 and submitted

Information

Review Board SVN (deprecated)

Reviewers

The Python LDAP library (I'm using 2.3.4) assumes the OPT_PROTOCOL_VERSION is an integer.  Due to some bad error handling code, a TypeError is set, but the C extension module does not handle it properly, so in strange situations you'll get a random TypeError raised.  (Look at options.c in the py ldap source near the LDAP_OPT_PROTOCOL_VERSION case statement).

Alternatively, I think this line could be removed, since the python-ldap library seems to default to version 3.
I was still able to log in after the change.  A simple standalone example:

import ldap
LDAP_URI = 'ldap://example.com:389/'
ldapo = ldap.initialize(LDAP_URI)
ldapo.set_option(ldap.OPT_PROTOCOL_VERSION, '3')
import pdb

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: an integer is required

I used "import pdb" as an example to trigger the bug, but it can be just about anything.