1 # copyright 2003-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
260 self.info('while trying to authenticate %s: %s', user, ex) |
260 self.info('while trying to authenticate %s: %s', user, ex) |
261 raise AuthenticationError() |
261 raise AuthenticationError() |
262 except Exception: |
262 except Exception: |
263 self.error('while trying to authenticate %s', user, exc_info=True) |
263 self.error('while trying to authenticate %s', user, exc_info=True) |
264 raise AuthenticationError() |
264 raise AuthenticationError() |
265 eid = self.repo.system_source.extid2eid(cnx, user['dn'].encode('ascii')) |
265 rset = cnx.execute('Any X,SN WHERE X cwuri %(extid)s, X is CWUser, ' |
266 if eid is None or eid < 0: |
266 'X cw_source S, S name SN', {'extid': user['dn']}) |
|
267 if not rset or rset[0][1] != self.uri: |
267 # user is not known or has been moved away from this source |
268 # user is not known or has been moved away from this source |
268 raise AuthenticationError() |
269 raise AuthenticationError() |
269 return eid |
270 return rset[0][0] |
270 |
271 |
271 def _connect(self, user=None, userpwd=None): |
272 def _connect(self, user=None, userpwd=None): |
272 protocol, host, port = self.connection_info() |
273 protocol, host, port = self.connection_info() |
273 self.info('connecting %s://%s:%s as %s', protocol, host, port, |
274 self.info('connecting %s://%s:%s as %s', protocol, host, port, |
274 user and user['dn'] or 'anonymous') |
275 user and user['dn'] or 'anonymous') |