Commit de07a7a3 authored by James Lopez's avatar James Lopez

fix ldap group link and add some debug info

parent a21928d0
......@@ -2,6 +2,8 @@ class LdapGroupLink < ActiveRecord::Base
include Gitlab::Access
belongs_to :group
NIL_ATTRIBUTES = %w[cn filter].freeze
validates :cn, :group_access, :group_id, presence: true, unless: :filter
validates :cn, uniqueness: { scope: [:group_id, :provider] }, unless: :filter
validates :filter, :group_access, :group_id, presence: true, unless: :cn
......@@ -12,6 +14,8 @@ class LdapGroupLink < ActiveRecord::Base
scope :with_provider, ->(provider) { where(provider: provider) }
before_save :update_blank_attributes
def access_field
group_access
end
......@@ -30,4 +34,10 @@ class LdapGroupLink < ActiveRecord::Base
def provider_label
config.label
end
private
def update_blank_attributes
NIL_ATTRIBUTES.each { |attr| self[attr] = nil if self[attr].blank? }
end
end
......@@ -2,7 +2,7 @@
.pull-right
= link_to group_ldap_group_link_path(group, ldap_group_link), method: :delete, class: 'btn btn-danger btn-sm' do
= fa_icon('unlink', text: 'unlink')
%strong= ldap_group_link.cn ? "Group: #{ldap_group_link.cn}" : "Filter: #{ldap_group_link.filter}"
%strong= ldap_group_link.cn ? "Group: #{ldap_group_link.cn}" : "Filter: #{truncate(ldap_group_link.filter, length: 70)}"
- if ldap_group_link.config
.light
......
......@@ -12,7 +12,11 @@ module EE
end
def filter
@proxy.adapter.ldap_search(options).map(&:dn)
logger.debug "Running filter #{@filter} against #{@proxy.provider}"
@proxy.adapter.ldap_search(options).map(&:dn).tap do |dns|
logger.debug "Found #{dns.count} mathing users for filter #{@filter}"
end
end
private
......@@ -28,6 +32,10 @@ module EE
def config
@proxy.adapter.config
end
def logger
Rails.logger
end
end
end
end
......
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