sources/ldap: use dn attribute for distinguishedName, ignore users with no distinguishedName
closes #527
This commit is contained in:
parent
add20de8de
commit
cc3fccb27e
|
@ -185,7 +185,10 @@ class LDAPSynchronizer:
|
|||
properties["attributes"]["ldap_uniq"] = attributes.get(
|
||||
self._source.object_uniqueness_field
|
||||
)
|
||||
properties["attributes"]["distinguishedName"] = attributes.get(
|
||||
"distinguishedName"
|
||||
)
|
||||
distinguished_name = attributes.get("distinguishedName", attributes.get("dn"))
|
||||
if not distinguished_name:
|
||||
raise IntegrityError(
|
||||
"Object does not have a distinguishedName or dn field."
|
||||
)
|
||||
properties["attributes"]["distinguishedName"] = distinguished_name
|
||||
return properties
|
||||
|
|
|
@ -53,6 +53,7 @@ def _build_mock_connection(password: str) -> Connection:
|
|||
"objectSid": "user0",
|
||||
"objectCategory": "Person",
|
||||
"memberOf": "cn=group1,ou=groups,DC=AD2012,DC=LAB",
|
||||
"distinguishedName": "cn=user0,ou=users,DC=AD2012,DC=LAB",
|
||||
},
|
||||
)
|
||||
# User without SID
|
||||
|
@ -64,6 +65,7 @@ def _build_mock_connection(password: str) -> Connection:
|
|||
"name": "user1_sn",
|
||||
"revision": 0,
|
||||
"objectCategory": "Person",
|
||||
"distinguishedName": "cn=user1,ou=users,DC=AD2012,DC=LAB",
|
||||
},
|
||||
)
|
||||
# Duplicate users
|
||||
|
@ -76,6 +78,7 @@ def _build_mock_connection(password: str) -> Connection:
|
|||
"revision": 0,
|
||||
"objectSid": "unique-test2222",
|
||||
"objectCategory": "Person",
|
||||
"distinguishedName": "cn=user2,ou=users,DC=AD2012,DC=LAB",
|
||||
},
|
||||
)
|
||||
connection.strategy.add_entry(
|
||||
|
@ -87,6 +90,7 @@ def _build_mock_connection(password: str) -> Connection:
|
|||
"revision": 0,
|
||||
"objectSid": "unique-test2222",
|
||||
"objectCategory": "Person",
|
||||
"distinguishedName": "cn=user3,ou=users,DC=AD2012,DC=LAB",
|
||||
},
|
||||
)
|
||||
connection.bind()
|
||||
|
|
Reference in New Issue