diff --git a/ldapcherry/__init__.py b/ldapcherry/__init__.py index 5968a3a..c119f92 100644 --- a/ldapcherry/__init__.py +++ b/ldapcherry/__init__.py @@ -332,8 +332,10 @@ class LdapCherry(object): if not u in ret: ret[u] = {} for attr in tmp[u]: - if not attr in ret[u]: - ret[u][attr] = tmp[u][attr] + if attr in self.attributes.backend_attributes[b]: + attrid = self.attributes.backend_attributes[b][attr] + if not attr in ret[u]: + ret[u][attrid] = tmp[u][attr] return ret def _check_admin(self): diff --git a/ldapcherry/attributes.py b/ldapcherry/attributes.py index 860cae9..1c3abfb 100644 --- a/ldapcherry/attributes.py +++ b/ldapcherry/attributes.py @@ -48,8 +48,8 @@ class Attributes: for b in attr['backends']: self.backends.add(b) if b not in self.backend_attributes: - self.backend_attributes[b] = [] - self.backend_attributes[b].append(attr['backends'][b]) + self.backend_attributes[b] = {} + self.backend_attributes[b][attr['backends'][b]] = attrid if 'search_displayed' in attr and attr['search_displayed']: self.displayed_attributes[attrid] = attr @@ -78,7 +78,7 @@ class Attributes: def get_backend_attributes(self, backend): if backend not in self.backends: raise WrongBackend(backend) - return self.backend_attributes[backend] + return self.backend_attributes[backend].keys() def get_backend_key(self, backend): if backend not in self.backends: diff --git a/tests/test_Attributes.py b/tests/test_Attributes.py index acabfd0..c5a9f9b 100644 --- a/tests/test_Attributes.py +++ b/tests/test_Attributes.py @@ -39,7 +39,7 @@ class TestError(object): def testGetBackendAttributes(self): inv = Attributes('./tests/cfg/attributes.yml') ret = inv.get_backend_attributes('ldap') - expected = ['shell', 'cn', 'uid', 'uidNumber', 'gidNumber', 'home', 'userPassword', 'givenName', 'email', 'sn'] + expected = ['shell', 'cn', 'userPassword', 'uidNumber', 'gidNumber', 'sn', 'home', 'givenName', 'email', 'uid'] assert ret == expected def testGetKey(self):