From 1df48950f50599bc5bde0a33356dfe3ae5e3385d Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Wed, 14 Nov 2012 11:03:50 +0100 Subject: [PATCH] Add ability to lowercase the LDAP name for use as PG role name --- config/sample-config2.yaml | 4 ++++ config/schema.yaml | 6 ++++++ lib/pg_ldap_sync/application.rb | 2 ++ 3 files changed, 12 insertions(+) diff --git a/config/sample-config2.yaml b/config/sample-config2.yaml index 22e0ff9..0e2b10b 100644 --- a/config/sample-config2.yaml +++ b/config/sample-config2.yaml @@ -21,6 +21,8 @@ ldap_users: filter: (&(objectClass=person)(objectClass=organizationalPerson)(givenName=*)(sn=*)(sAMAccountName=*)) # this attribute is used as PG role name name_attribute: sAMAccountName + # lowercase name for use as PG role name + lowercase_name: true # Search parameters for LDAP groups which should be synchronized ldap_groups: @@ -28,6 +30,8 @@ ldap_groups: filter: (cn=company.*) # this attribute is used as PG role name name_attribute: cn + # lowercase name for use as PG role name + lowercase_name: false # this attribute must reference to all member DN's of the given group member_attribute: member diff --git a/config/schema.yaml b/config/schema.yaml index 417053f..29fc256 100644 --- a/config/schema.yaml +++ b/config/schema.yaml @@ -17,6 +17,9 @@ mapping: "name_attribute": type: str required: yes + "lowercase_name": + type: bool + required: no "ldap_groups": type: map @@ -31,6 +34,9 @@ mapping: "name_attribute": type: str required: yes + "lowercase_name": + type: bool + required: no "member_attribute": type: str required: yes diff --git a/lib/pg_ldap_sync/application.rb b/lib/pg_ldap_sync/application.rb index cab9e2b..b0136bd 100644 --- a/lib/pg_ldap_sync/application.rb +++ b/lib/pg_ldap_sync/application.rb @@ -85,6 +85,7 @@ class Application log.warn "user attribute #{ldap_user_conf[:name_attribute].inspect} not defined for #{entry.dn}" next end + name.downcase! if ldap_user_conf[:lowercase_name] log.info "found user-dn: #{entry.dn}" user = LdapRole.new name, entry.dn @@ -111,6 +112,7 @@ class Application log.warn "user attribute #{ldap_group_conf[:name_attribute].inspect} not defined for #{entry.dn}" next end + name.downcase! if ldap_group_conf[:lowercase_name] log.info "found group-dn: #{entry.dn}" group = LdapRole.new name, entry.dn, entry[ldap_group_conf[:member_attribute]]