Commit 094a2590 authored by Stan Hu's avatar Stan Hu

Refactor DN cleaning

parent 0d344be8
......@@ -76,6 +76,7 @@ module EE
next
end
final_dn =
# If there is more than one key/value set we must have a full DN,
# or at least the probability is higher.
if parsed_dn.count > 2
......@@ -86,24 +87,23 @@ module EE
logger.warn { "Found potentially malformed/incomplete DN: '#{dn}'" }
dn
end
clean_encoding(final_dn)
end
# Remove `nil` values generated by the rescue above.
dns.compact!
clean_encoding(dns)
end
# net-ldap only returns ASCII-8BIT and does not support UTF-8 out-of-the-box:
# https://github.com/ruby-ldap/ruby-net-ldap/issues/4
def clean_encoding(dns)
dns.map do |dn|
def clean_encoding(dn)
begin
dn.force_encoding('UTF-8')
rescue
dn
end
end
end
def member_uid_to_dn(uid)
identity = Identity.find_by(provider: provider, secondary_extern_uid: uid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment