Browse Source

9.0 users_ldap_populate fix 2 bugs

* leftovers from old api
* python-ldap does not like Unicode strings
pull/334/head
Alexandre Fayolle 9 years ago
parent
commit
06fbac70f9
  1. 10
      users_ldap_populate/model/users_ldap.py

10
users_ldap_populate/model/users_ldap.py

@ -21,7 +21,7 @@
import re
from openerp import models, api
from openerp import models, api, _
from openerp.exceptions import UserError
import logging
@ -52,7 +52,7 @@ class CompanyLDAP(models.Model):
logger.debug("action_populate called on res.company.ldap ids %s",
self.ids)
for conf in self.get_ldap_dicts(self.cr, self.ids):
for conf in self.get_ldap_dicts():
if not conf['create_user']:
continue
attribute_match = re.search(
@ -61,11 +61,11 @@ class CompanyLDAP(models.Model):
login_attr = attribute_match.group(1)
else:
raise UserError(
"No login attribute found"
"Could not extract login attribute from filter %s" %
_("No login attribute found: "
"Could not extract login attribute from filter %s") %
conf['ldap_filter'])
ldap_filter = filter_format(conf['ldap_filter'] % '*', ())
for result in self.query(conf, ldap_filter):
for result in self.query(conf, ldap_filter.encode('utf-8')):
self.get_or_create_user(conf, result[1][login_attr][0], result)
users_no_after = users_pool.search_count([])

Loading…
Cancel
Save