From f5b9587eb73e6c1045f934a063276930d20faa5e Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Wed, 30 Nov 2022 13:24:29 +0100 Subject: [PATCH] Revert "Support synchronize groups with over 1500 users in Active Directory server" This reverts commit d833228547ed9d5d3b79a8f17143512a9762f49d. --- config/sample-config2.yaml | 2 -- config/schema.yaml | 3 --- lib/pg_ldap_sync/application.rb | 40 +-------------------------------- 3 files changed, 1 insertion(+), 44 deletions(-) diff --git a/config/sample-config2.yaml b/config/sample-config2.yaml index fa29f12..dd96ea1 100644 --- a/config/sample-config2.yaml +++ b/config/sample-config2.yaml @@ -38,8 +38,6 @@ ldap_groups: lowercase_name: false # this attribute must reference to all member DN's of the given group member_attribute: member - # must be true if group with over 1500 members for Active Directory server - need_member_range_retrieval: false # Connection parameters to PostgreSQL server # see also: http://rubydoc.info/gems/pg/PG/Connection#initialize-instance_method diff --git a/config/schema.yaml b/config/schema.yaml index 227de45..08abdb8 100644 --- a/config/schema.yaml +++ b/config/schema.yaml @@ -46,9 +46,6 @@ mapping: "member_attribute": type: str required: yes - "need_member_range_retrieval": - type: bool - required: no "pg_connection": type: any diff --git a/lib/pg_ldap_sync/application.rb b/lib/pg_ldap_sync/application.rb index 90c7ec2..d68c858 100644 --- a/lib/pg_ldap_sync/application.rb +++ b/lib/pg_ldap_sync/application.rb @@ -85,40 +85,6 @@ class Application return users end - def load_group_members_by_range(group_dn) - range_start = 0 - all_group_members = [] - while true do - member_size = 0 - member_attribute_with_range = "#{@config[:ldap_groups][:member_attribute]};range=#{range_start}-*" - returned_member_attribute_with_range = "" - log.debug " current attribute for range retrieval ----> #{member_attribute_with_range} " - - res_entry = @ldap.search( - base: group_dn, - filter: Net::LDAP::Filter.eq('distinguishedName', group_dn), - attributes: member_attribute_with_range).first - - res_entry.each do |attribute, values| - next if "#{attribute}" == "dn" - returned_member_attribute_with_range = "#{attribute}" - log.debug " returned attribute --------> #{returned_member_attribute_with_range}" - member_size = values.count - values.each do |value| - log.debug " -----> #{value}" - all_group_members << value - end - break - end - - if returned_member_attribute_with_range == member_attribute_with_range - break - end - range_start = range_start + member_size - end - return all_group_members - end - def search_ldap_groups ldap_group_conf = @config[:ldap_groups] @@ -141,11 +107,7 @@ class Application end names.each do |n| - group_members = entry[ldap_group_conf[:member_attribute]] - if group_members.count == 0 and ldap_group_conf[:need_member_range_retrieval] - group_members = load_group_members_by_range(entry.dn) - end - groups << LdapRole.new(n, entry.dn, group_members) + groups << LdapRole.new(n, entry.dn, entry[ldap_group_conf[:member_attribute]]) end entry.each do |attribute, values| log.debug " #{attribute}:"