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\pyramid_ldap3__init__.py", 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.
I have the same issue with this setup:
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.
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 again instead of dn = data['dn']. You can fetch additional attributes from LDAP in data, but you must specify which attributes you're interested in when calling ldap_set_login_query.
dn = data
dn = data['dn']