`LDAP::Group` does not catch invalid DN errors
The two lines at https://gitlab.com/gitlab-org/gitlab-ee/blob/master/lib/ee/gitlab/ldap/group.rb#L96-97 (shown near the bottom of the method copied below) do not catch invalid DNs. The first case would be a bad DN configured by the administrators. The latter would be bad DNs sent from LDAP - this situation is less likely. However, we should still catch the errors, output logs, and move on.
def active_directory_members(entry, nested_groups_to_skip)
require 'net/ldap/dn'
members = []
# Retrieve all member pages/ranges
members.concat(ranged_members(entry)) if has_member_range?(entry)
# Process nested group members
members.concat(nested_members(nested_groups_to_skip))
# Clean dns of groups and users outside the base
members.reject! { |dn| nested_groups_to_skip.include?(dn) }
base = Net::LDAP::DN.new(adapter.config.base.downcase).to_a #<---
members.select! { |dn| Net::LDAP::DN.new(dn.downcase).to_a.last(base.length) == base } #<---
members
end