Skip to content

Problem "conn.close()" #1

fabrizioPH opened this Issue Jul 2, 2014 · 2 comments

3 participants


First of all, thanks for the package ldap for pyramid, your work is much appreciated!
I recently started the implementation on active directory (windows 2008 r2, pyramid 1.5.1, python 3.4.1 64bit), and if the authentication is successful, an error occurs:
"lib\site-packages\", line 172, in authenticate
AttributeError: 'Connection' object has no attribute 'close'".

for now I just commented conn.close () and everything seems to work very well, but I have not checked if there is any problem side active directory.
Thanks for your time.

jbogarin commented Jul 3, 2014

I have the same issue with this setup:

  • Mac OS X - 10.9.3
  • Python 3.3
  • Pyramid 1.5.1
  • pyramid-ldap 0.2
  • python3-ldap

I believe that conn.close() shouldn't be used here. conn.unbind() is the correct way to go.

I'm not an expert and can't actually explain why. According to the documentation of python3-ldap documentation unbind is what you use to disconnect and close the connection.

Close is just an alias to unbind and I'm not sure why the error when you use close, from quick reading I believe it has something to do with using connection manager.

Any way, changing the line from conn.close() to conn.unbind() does the magic.

Hope this helps.


Cito commented Jul 3, 2014

Thanks for the feedback. The error appeared because the close() alias for unbind() has been removed in python3-ldap 0.9.4. I have adapted the latest version pyramid_ldap3 0.2.1 accordingly.

When you update to version 0.2.1, please note that the return values of pyramid_ldap3 are now comaptible with pyramid_ldap again. I.e. in your login() view you have to write dn = data[0] again instead of dn = data['dn']. You can fetch additional attributes from LDAP in data[1], but you must specify which attributes you're interested in when calling ldap_set_login_query.

@Cito Cito closed this Jul 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.