diff --git a/config/sample-config2.yaml b/config/sample-config2.yaml index 0145f3e..fa29f12 100644 --- a/config/sample-config2.yaml +++ b/config/sample-config2.yaml @@ -37,10 +37,9 @@ ldap_groups: # lowercase name for use as PG role name lowercase_name: false # this attribute must reference to all member DN's of the given group - # If LDAP server is Active Directory, it's better to append ";range" to member_attribue; - # otherwise, it can't synchronize groups with over 1500 users for AD server. - # Example for AD server: "member;range" 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 08abdb8..227de45 100644 --- a/config/schema.yaml +++ b/config/schema.yaml @@ -46,6 +46,9 @@ 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 73d8728..90c7ec2 100644 --- a/lib/pg_ldap_sync/application.rb +++ b/lib/pg_ldap_sync/application.rb @@ -90,7 +90,7 @@ class Application all_group_members = [] while true do member_size = 0 - member_attribute_with_range = "#{@config[:ldap_groups][:member_attribute]}=#{range_start}-*" + 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} " @@ -141,9 +141,8 @@ class Application end names.each do |n| - member_attribute_sub_list = ldap_group_conf[:member_attribute].partition(";") - group_members = entry[member_attribute_sub_list[0]] - if group_members.count == 0 and member_attribute_sub_list[2] == "range" + 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)