sources/ldap: update LDAP source to use new property mappings

This commit is contained in:
Jens Langhammer
2020-02-17 17:55:48 +01:00
parent 7268afaaf9
commit e57da71dcf
5 changed files with 53 additions and 6 deletions

View File

@ -6,7 +6,7 @@ import ldap3.core.exceptions
from structlog import get_logger
from passbook.core.models import Group, User
from passbook.sources.ldap.models import LDAPSource
from passbook.sources.ldap.models import LDAPSource, LDAPPropertyMapping
LOGGER = get_logger()
@ -154,7 +154,10 @@ class Connector:
) -> Dict[str, Dict[Any, Any]]:
properties = {"attributes": {}}
for mapping in self._source.property_mappings.all().select_subclasses():
properties[mapping.object_field] = attributes.get(mapping.ldap_property, "")
mapping: LDAPPropertyMapping
properties[mapping.object_field] = mapping.render(
user=None, request=None, ldap=attributes
)
if self._source.object_uniqueness_field in attributes:
properties["attributes"]["ldap_uniq"] = attributes.get(
self._source.object_uniqueness_field