equal
deleted
inserted
replaced
140 for sattr, tattr in items: |
140 for sattr, tattr in items: |
141 if tattr not in self.non_attribute_keys: |
141 if tattr not in self.non_attribute_keys: |
142 try: |
142 try: |
143 tdict[tattr] = sdict[sattr] |
143 tdict[tattr] = sdict[sattr] |
144 except KeyError: |
144 except KeyError: |
145 raise ConfigurationError('source attribute %s is not present ' |
145 raise ConfigurationError('source attribute %s has not ' |
146 'in the source, please check the ' |
146 'been found in the source, ' |
147 '%s-attrs-map field' % |
147 'please check the %s-attrs-map ' |
|
148 'field and the permissions of ' |
|
149 'the LDAP binding user' % |
148 (sattr, etype[2:].lower())) |
150 (sattr, etype[2:].lower())) |
149 return tdict |
151 return tdict |
150 |
152 |
151 def before_entity_copy(self, entity, sourceparams): |
153 def before_entity_copy(self, entity, sourceparams): |
152 etype = entity.cw_etype |
154 etype = entity.cw_etype |
166 def after_entity_copy(self, entity, sourceparams): |
168 def after_entity_copy(self, entity, sourceparams): |
167 super(DataFeedLDAPAdapter, self).after_entity_copy(entity, sourceparams) |
169 super(DataFeedLDAPAdapter, self).after_entity_copy(entity, sourceparams) |
168 etype = entity.cw_etype |
170 etype = entity.cw_etype |
169 if etype == 'EmailAddress': |
171 if etype == 'EmailAddress': |
170 return |
172 return |
171 # all CWUsers must be treated before CWGroups to have to in_group relation |
173 # all CWUsers must be treated before CWGroups to have the in_group relation |
172 # set correctly in _associate_ldapusers |
174 # set correctly in _associate_ldapusers |
173 elif etype == 'CWUser': |
175 elif etype == 'CWUser': |
174 groups = filter(None, [self._get_group(name) |
176 groups = filter(None, [self._get_group(name) |
175 for name in self.source.user_default_groups]) |
177 for name in self.source.user_default_groups]) |
176 if groups: |
178 if groups: |
194 except KeyError: |
196 except KeyError: |
195 return # no email for that user, nothing to do |
197 return # no email for that user, nothing to do |
196 if not isinstance(emailaddrs, list): |
198 if not isinstance(emailaddrs, list): |
197 emailaddrs = [emailaddrs] |
199 emailaddrs = [emailaddrs] |
198 for emailaddr in emailaddrs: |
200 for emailaddr in emailaddrs: |
199 # search for existant email first, may be coming from another source |
201 # search for existing email first, may be coming from another source |
200 rset = self._cw.execute('EmailAddress X WHERE X address %(addr)s', |
202 rset = self._cw.execute('EmailAddress X WHERE X address %(addr)s', |
201 {'addr': emailaddr}) |
203 {'addr': emailaddr}) |
202 if not rset: |
204 if not rset: |
203 # not found, create it. first forge an external id |
205 # not found, create it. first forge an external id |
204 emailextid = userdict['dn'] + '@@' + emailaddr.encode('utf-8') |
206 emailextid = userdict['dn'] + '@@' + emailaddr.encode('utf-8') |