equal
deleted
inserted
replaced
23 from __future__ import with_statement |
23 from __future__ import with_statement |
24 |
24 |
25 from logilab.common.decorators import cached |
25 from logilab.common.decorators import cached |
26 from logilab.common.shellutils import generate_password |
26 from logilab.common.shellutils import generate_password |
27 |
27 |
28 from cubicweb import Binary |
28 from cubicweb import Binary, ConfigurationError |
29 from cubicweb.server.utils import crypt_password |
29 from cubicweb.server.utils import crypt_password |
30 from cubicweb.server.sources import datafeed |
30 from cubicweb.server.sources import datafeed |
31 |
31 |
32 |
32 |
33 class DataFeedLDAPAdapter(datafeed.DataFeedParser): |
33 class DataFeedLDAPAdapter(datafeed.DataFeedParser): |
90 def ldap2cwattrs(self, sdict, tdict=None): |
90 def ldap2cwattrs(self, sdict, tdict=None): |
91 if tdict is None: |
91 if tdict is None: |
92 tdict = {} |
92 tdict = {} |
93 for sattr, tattr in self.source.user_attrs.iteritems(): |
93 for sattr, tattr in self.source.user_attrs.iteritems(): |
94 if tattr not in self.non_attribute_keys: |
94 if tattr not in self.non_attribute_keys: |
95 tdict[tattr] = sdict[sattr] |
95 try: |
|
96 tdict[tattr] = sdict[sattr] |
|
97 except KeyError: |
|
98 raise ConfigurationError('source attribute %s is not present ' |
|
99 'in the source, please check the ' |
|
100 'user-attrs-map field' % sattr) |
96 return tdict |
101 return tdict |
97 |
102 |
98 def before_entity_copy(self, entity, sourceparams): |
103 def before_entity_copy(self, entity, sourceparams): |
99 if entity.__regid__ == 'EmailAddress': |
104 if entity.__regid__ == 'EmailAddress': |
100 entity.cw_edited['address'] = sourceparams['address'] |
105 entity.cw_edited['address'] = sourceparams['address'] |