Skip to content

Commit 92f18b1

Browse files
committed
Compare AD DNs case-insensitively when checking group membership
1 parent 99ab8c6 commit 92f18b1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/github/ldap/membership_validators/active_directory.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def perform(entry)
3131
attributes: ATTRS
3232

3333
# membership validated if entry was matched and returned as a result
34-
matched.map(&:dn).include?(entry.dn)
34+
# Active Directory DNs are case-insensitive
35+
matched.map { |m| m.dn.downcase }.include?(entry.dn.downcase)
3536
end
3637

3738
# Internal: Constructs a membership filter using the "in chain"

test/membership_validators/active_directory_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,13 @@ def test_validates_user_in_posix_group
123123
validator = make_validator(%w(posix-group1))
124124
assert validator.perform(@entry)
125125
end
126+
127+
def test_validates_user_in_group_with_differently_cased_dn
128+
validator = make_validator(%w(all-users))
129+
@entry[:dn].map(&:upcase!)
130+
assert validator.perform(@entry)
131+
132+
@entry[:dn].map(&:downcase!)
133+
assert validator.perform(@entry)
134+
end
126135
end

0 commit comments

Comments
 (0)