From df85e16c75337f25b86c18e2ae157bceadce6368 Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Mon, 17 Dec 2018 15:24:49 +0100 Subject: [PATCH] B #2677 Match LDAP groups case insensitive --- src/authm_mad/remotes/ldap/ldap_auth.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/authm_mad/remotes/ldap/ldap_auth.rb b/src/authm_mad/remotes/ldap/ldap_auth.rb index 890ea2ce77..163f1efd8c 100644 --- a/src/authm_mad/remotes/ldap/ldap_auth.rb +++ b/src/authm_mad/remotes/ldap/ldap_auth.rb @@ -184,13 +184,17 @@ class OpenNebula::LdapAuth end end + def in_hash_ignore_case?(hash, key) + return hash.keys.find {|k| key.downcase == k.downcase} + end + def get_groups groups = [] if @options[:rfc2307bis] [@user['memberOf']].flatten.each do |group| - if @mapping[group] - groups << @mapping[group] + if (g = in_hash_ignore_case?(@mapping, group)) + groups << @mapping[g] end end else @@ -200,9 +204,10 @@ class OpenNebula::LdapAuth :attributes => [ "dn" ], :filter => filter ) do |entry| - if @mapping[entry.dn] - groups << @mapping[entry.dn] + if (g = in_hash_ignore_case?(@mapping, entry.dn)) + groups << @mapping[g] end + end end