Skip to content

Commit 5fa3440

Browse files
committed
sanitize group names
1 parent 3f8d6e8 commit 5fa3440

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

apps/ldap/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@ def add_officer(username):
142142

143143

144144
def add_group_member(group, username):
145+
sanitized_group = escape_rdn(group)
145146
with newuser_connection() as c:
146147
if c.bind():
147148
success = c.modify(
148-
"cn={0},{1}".format(group, GROUP_OU),
149+
"cn={0},{1}".format(sanitized_group, GROUP_OU),
149150
{"memberUid": [(MODIFY_ADD, [username])]},
150151
)
151152
if success:
@@ -160,10 +161,11 @@ def remove_group_members(group, usernames):
160161
if not usernames:
161162
# without this check, the memberUid attribute gets overridden with []
162163
return False, "No users specified"
164+
sanitized_group = escape_rdn(group)
163165
with newuser_connection() as c:
164166
if c.bind():
165167
success = c.modify(
166-
"cn={0},{1}".format(group, GROUP_OU),
168+
"cn={0},{1}".format(sanitized_group, GROUP_OU),
167169
{"memberUid": [(MODIFY_DELETE, usernames)]},
168170
)
169171
if success:

0 commit comments

Comments
 (0)