Allow users to set/update their display name in LDAP
This commit is contained in:
12
app/services/ldap_manager/update_display_name.rb
Normal file
12
app/services/ldap_manager/update_display_name.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module LdapManager
|
||||
class UpdateDisplayName < LdapManagerService
|
||||
def initialize(dn, display_name)
|
||||
@dn = dn
|
||||
@display_name = display_name
|
||||
end
|
||||
|
||||
def call
|
||||
replace_attribute @dn, :displayName, @display_name
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -6,7 +6,7 @@ module LdapManager
|
||||
end
|
||||
|
||||
def call
|
||||
replace_attribute @dn, :mail, [ @address ]
|
||||
replace_attribute @dn, :mail, @address
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,7 +50,7 @@ class LdapService < ApplicationService
|
||||
treebase = ldap_config["base"]
|
||||
end
|
||||
|
||||
attributes = %w{dn cn uid mail admin service}
|
||||
attributes = %w{dn cn uid mail displayName admin service}
|
||||
filter = Net::LDAP::Filter.eq("uid", args[:uid] || "*")
|
||||
|
||||
entries = ldap_client.search(base: treebase, filter: filter, attributes: attributes)
|
||||
@@ -59,6 +59,7 @@ class LdapService < ApplicationService
|
||||
{
|
||||
uid: e.uid.first,
|
||||
mail: e.try(:mail) ? e.mail.first : nil,
|
||||
display_name: e.try(:displayName) ? e.displayName.first : nil,
|
||||
admin: e.try(:admin) ? 'admin' : nil,
|
||||
service: e.try(:service)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user