16 # You should have received a copy of the GNU Lesser General Public License along |
16 # You should have received a copy of the GNU Lesser General Public License along |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 """cubicweb ldap user source |
18 """cubicweb ldap user source |
19 |
19 |
20 this source is for now limited to a read-only CWUser source |
20 this source is for now limited to a read-only CWUser source |
21 |
|
22 |
|
23 |
21 |
24 Part of the code is coming form Zope's LDAPUserFolder |
22 Part of the code is coming form Zope's LDAPUserFolder |
25 |
23 |
26 Copyright (c) 2004 Jens Vagelpohl. |
24 Copyright (c) 2004 Jens Vagelpohl. |
27 All Rights Reserved. |
25 All Rights Reserved. |
295 # no such user |
293 # no such user |
296 raise AuthenticationError() |
294 raise AuthenticationError() |
297 # check password by establishing a (unused) connection |
295 # check password by establishing a (unused) connection |
298 try: |
296 try: |
299 self._connect(user, password) |
297 self._connect(user, password) |
|
298 except ldap.LDAPError, ex: |
|
299 # Something went wrong, most likely bad credentials |
|
300 self.info('while trying to authenticate %s: %s', user, ex) |
|
301 raise AuthenticationError() |
300 except Exception: |
302 except Exception: |
301 self.error('while trying to authenticate %s: %s', user, |
303 self.error('while trying to authenticate %s', user, exc_info=True) |
302 exc_info=True) |
|
303 # Something went wrong, most likely bad credentials |
|
304 raise AuthenticationError() |
304 raise AuthenticationError() |
305 return self.extid2eid(user['dn'], 'CWUser', session) |
305 return self.extid2eid(user['dn'], 'CWUser', session) |
306 |
306 |
307 def ldap_name(self, var): |
307 def ldap_name(self, var): |
308 if var.stinfo['relations']: |
308 if var.stinfo['relations']: |