248 try: |
248 try: |
249 conn.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3) |
249 conn.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3) |
250 except ldap.LDAPError: # Invalid protocol version, fall back safely |
250 except ldap.LDAPError: # Invalid protocol version, fall back safely |
251 conn.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION2) |
251 conn.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION2) |
252 # Deny auto-chasing of referrals to be safe, we handle them instead |
252 # Deny auto-chasing of referrals to be safe, we handle them instead |
253 #try: |
253 # Required for AD |
254 # connection.set_option(ldap.OPT_REFERRALS, 0) |
254 try: |
255 #except ldap.LDAPError: # Cannot set referrals, so do nothing |
255 conn.set_option(ldap.OPT_REFERRALS, 0) |
256 # pass |
256 except ldap.LDAPError: # Cannot set referrals, so do nothing |
|
257 pass |
257 #conn.set_option(ldap.OPT_NETWORK_TIMEOUT, conn_timeout) |
258 #conn.set_option(ldap.OPT_NETWORK_TIMEOUT, conn_timeout) |
258 #conn.timeout = op_timeout |
259 #conn.timeout = op_timeout |
259 # Now bind with the credentials given. Let exceptions propagate out. |
260 # Now bind with the credentials given. Let exceptions propagate out. |
260 if user is None: |
261 if user is None: |
261 # no user specified, we want to initialize the 'data' connection, |
262 # no user specified, we want to initialize the 'data' connection, |