Skip to content

Commit 73592db

Browse files
adobeDanadorton-adobe
authored andcommitted
tentative directional work on group creation
We need an issue to hold the spec for this.
1 parent 6750238 commit 73592db

File tree

3 files changed

+54
-16
lines changed

3 files changed

+54
-16
lines changed

examples/config files - basic/1 user-sync-config.yml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,10 @@ directory_users:
167167
# is specified as a list of entries, each of which has a directory_group
168168
# setting (whose value is a single directory group) and an adobe_groups
169169
# setting (whose value is a list of 0 or more product configuration and
170-
# user groups). All of the values in the adobe_groups settings must
171-
# match the name of product configurations and user groups which have
172-
# already been created on the Adobe side. (In this example, we pretend
173-
# that "Acrobat DC Pro" is a product configuration and "Copy Editors"
174-
# is a user group that the you have already created. Possibly
175-
# the "Copy Editors" user group has been assigned access to appropriate
176-
# Adobe products, such as InDesign and InCopy.)
170+
# user groups). In this example, imagine that "Acrobat DC Pro" is a
171+
# product configuration and "Copy Editors" is a user group, and that
172+
# the "Copy Editors" user group will be assigned access to appropriate
173+
# Adobe products, such as InDesign and InCopy.
177174
# [You will need to edit or remove these examples.]
178175
- directory_group: "Finance"
179176
adobe_groups:
@@ -186,6 +183,33 @@ directory_users:
186183
- "Copy Editors"
187184
- "Acrobat DC Pro"
188185

186+
# (optional) additional_groups (no default value)
187+
# People who use their directory groups for ACLs on the Adobe side
188+
# often have a very large number of groups that they want mapped
189+
# over to (user) groups on the Adobe side. To avoid having to
190+
# specify those groups statically in their config file, and to
191+
# update their config file when they change, they can instead
192+
# use a naming convention for the groups and specify that here.
193+
# The value of this attribute is a mapping from Python regular expressions
194+
# that specify directory groups of interest to Pythonn replacement expressions
195+
# that specify how to construct the name of the target Adobe group
196+
# that the directory group should be mapped to. If a value is
197+
# provided, then all users who are (directly) in groups whose
198+
# CN matches one of the source regular expressions will be put in a user group
199+
# on the Adobe side whose name is given by the target replacement expression.
200+
# The simple example here (which should be removed) maps all the
201+
# groups that start with "ACL-" or end with "-ACL" to an Adobe
202+
# group that starts with "ACL-Grp-".
203+
# (All of these regular expressions must match the entire group name.
204+
# For details on Python regular expression matching and replacement,
205+
# see https://docs.python.org/howto/regex.html )
206+
additional_groups:
207+
- source: "ACL-(.+)"
208+
target: "ACL-Grp-(\1)"
209+
- source: "(.+)-ACL"
210+
target: "ACL-Grp-(\1)"
211+
212+
189213
# The limits section provides processing limits which can help ensure that
190214
# User Sync jobs do not exceed expected guardrails in their operation
191215
limits:

examples/config files - basic/3 connector-ldap.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,29 @@ all_users_filter: "(&(objectClass=user)(objectCategory=person)(!(userAccountCont
7272
group_filter_format: "(&(|(objectCategory=group)(objectClass=groupOfNames)(objectClass=posixGroup))(cn={group}))"
7373

7474
# (optional) group_member_filter_format (default value given below)
75-
# group_users_filter specifies the query used to find all members of a group,
75+
# group_member_filter_format specifies the query used to find all members of a group,
7676
# where the string {group_dn} is replaced with the group distinguished name.
7777
# The default value just finds users who are immediate members of the group,
7878
# not those who are "indirectly" members by virtue of membership in a group
7979
# that is contained in the group. If you want indirect containment, then
8080
# use this value instead of the default:
8181
# group_member_filter_format: "(memberOf:1.2.840.113556.1.4.1941:={group_dn})"
8282
group_member_filter_format: "(memberOf={group_dn})"
83+
# Note that this filter is &-combined with the all_users_filter so that
84+
# only users that would be selected by that filter will be returned as
85+
# members of the given group.
86+
87+
# (optional) member_group_filter_format (default value given below)
88+
# member_group_filter_format specifies the query used to find all groups that
89+
# directly contain a given member. The string {member_dn} is replaced
90+
# with the DN of the group member. The string {member_uid) is replaced with
91+
# the uid attribute of the group member, if any. The default value expects
92+
# groups to refer to members by their DN. For groups that refer to their
93+
# members by their UID (e.g., posix groups in many OpenLDAP systems), you
94+
# probably want to use this value instead: "(memberUid={member_uid})"
95+
member_group_filter_format: "(member={member_dn})"
96+
# Note that this filter is &-combined with the group_filter_format query
97+
# specifying a wildcard for the group name. So it will only find groups.
8398

8499
# (optional) string_encoding (default value given below)
85100
# string_encoding specifies the Unicode string encoding used by the directory.
@@ -172,14 +187,9 @@ user_email_format: "{mail}"
172187
# are already pre-defined attribute names that are used for these fields:
173188
# - the Adobe first name is set from the LDAP "givenName" attribute
174189
# - the Adobe last name is set from the LDAP "sn" (surname) attribute
175-
# - the Adobe country is set from the LDAP "country" attribute
190+
# - the Adobe country is set from the LDAP "c" (country) attribute
176191
# If you need to override these values on the Adobe side, you can use the
177192
# custom extension mechanism (see the docs) to compute and set field values
178-
# by combining these and any other custom attributes needed. Seed the
193+
# by combining these and any other custom attributes needed. See the
179194
# User Sync documentation for full details.
180-
#
181-
# Finally, some LDAP systems use uids to identify groups, and place users in
182-
# groups via uid rather than name. The User Sync implementation always reads
183-
# the uid attribute on all objects if the directory provides one, so it is
184-
# able to handle directories which function in this way even though the
185-
# configuration files always specify groups by name.
195+

user_sync/connector/directory_ldap.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ def iter_users(self, users_filter, extended_attributes):
289289
elif last_attribute_name:
290290
self.logger.warning('No country code attribute (%s) for user with dn: %s', last_attribute_name, dn)
291291

292+
uid_value = LDAPValueFormatter.get_attribute_value(record, six.text_type('uid'))
293+
source_attributes['uid'] = uid_value
294+
user['member_groups'] = find_member_groups(dn, uid_value if uid_value else six.text_type(''))
295+
292296
if extended_attributes is not None:
293297
for extended_attribute in extended_attributes:
294298
extended_attribute_value = LDAPValueFormatter.get_attribute_value(record, extended_attribute)

0 commit comments

Comments
 (0)