diff --git a/CHANGES.rst b/CHANGES.rst index d39998b..009206b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,25 +1,35 @@ Changelog --------------- -0.1.5 +0.2.0 +++++ -- Added escape_filter_chars() to filter the filter +**Improvements** +- Added verify_password(dn, password) method + +**Bugfixes** +- Added escape_filter_chars() to filter (sanitize) the filter - Override of cidicts __getitem__ so that user.attrs['nonexistent'] won't raise an exception, but instead returns an empty list +0.1.3 and 0.1.4 ++++++++++++++++ + +- Wrestling with pypi (needs a new version number even if you've made a mistake by uploading rubbish) + 0.1.2 +++++ -- README.md to README.rst (pypi should show a nice README as well) +- Converted README.md to README.rst (pypi should show a nice README as well) 0.1.1 +++++ +**Bugfixes** - Fixed pretty print of binary attribute -- Fixed ldap.get sizelimit=1 exception for now +- Fixed ldap.get sizelimit=1 exception for now (come back to this later) - Added try catch to api -0.1 -+++ +0.1.0 ++++++ -- Initial version, have to start somewhere \ No newline at end of file +- Initial version (have to start somewhere) \ No newline at end of file diff --git a/ldappr/connection.py b/ldappr/connection.py index 9247b28..49a4b94 100644 --- a/ldappr/connection.py +++ b/ldappr/connection.py @@ -21,6 +21,7 @@ class Connection(object): def search(self, search_filter): """Get list of objects that match the search_filter + :param search_filter: filter to find the objects :return: list of LdapperObjects (or empty list) """ @@ -83,6 +84,15 @@ class Connection(object): result = self.get_values(dn, attr) return result[0] + def verify_password(self, dn, password): + try: + test_conn = ldap.initialize(self.ldap_url) + test_conn.simple_bind_s(dn, password) + test_conn.unbind_s() + return True + except ldap.LDAPError: + return False + def close(self): self.conn.unbind_s() diff --git a/ldappr/test/test_ldappr.py b/ldappr/test/test_ldappr.py index e0c8938..49a7336 100644 --- a/ldappr/test/test_ldappr.py +++ b/ldappr/test/test_ldappr.py @@ -122,5 +122,11 @@ sn: Doe user = self.ldap.get_by_dn(self.new_dn) self.assertEqual(user.attrs['mobile'], ['9876543210']) + def test_verify_password(self): + self.assertEqual(self.ldap.verify_password(self.bind_dn, + self.password), True) + self.assertEqual(self.ldap.verify_password(self.bind_dn, + 'wrong_password'), False) + if __name__ == '__main__': unittest.main()