Add email service and settings
This commit is contained in:
12
app/services/ldap_manager/update_email_maildrop.rb
Normal file
12
app/services/ldap_manager/update_email_maildrop.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module LdapManager
|
||||
class UpdateEmailMaildrop < LdapManagerService
|
||||
def initialize(dn, address)
|
||||
@dn = dn
|
||||
@address = address
|
||||
end
|
||||
|
||||
def call
|
||||
replace_attribute @dn, :mailRoutingAddress, @address
|
||||
end
|
||||
end
|
||||
end
|
||||
12
app/services/ldap_manager/update_email_password.rb
Normal file
12
app/services/ldap_manager/update_email_password.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module LdapManager
|
||||
class UpdateEmailPassword < LdapManagerService
|
||||
def initialize(dn, password_hash)
|
||||
@dn = dn
|
||||
@password_hash = password_hash
|
||||
end
|
||||
|
||||
def call
|
||||
replace_attribute @dn, :mailpassword, @password_hash
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -50,8 +50,11 @@ class LdapService < ApplicationService
|
||||
treebase = ldap_config["base"]
|
||||
end
|
||||
|
||||
attributes = %w{dn cn uid mail displayName admin service}
|
||||
filter = Net::LDAP::Filter.eq("uid", args[:uid] || "*")
|
||||
attributes = %w[
|
||||
dn cn uid mail displayName admin service
|
||||
mailRoutingAddress mailpassword
|
||||
]
|
||||
filter = Net::LDAP::Filter.eq("uid", args[:uid] || "*")
|
||||
|
||||
entries = ldap_client.search(base: treebase, filter: filter, attributes: attributes)
|
||||
entries.sort_by! { |e| e.cn[0] }
|
||||
@@ -61,7 +64,9 @@ class LdapService < ApplicationService
|
||||
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)
|
||||
service: e.try(:service),
|
||||
email_maildrop: e.try(:mailRoutingAddress),
|
||||
email_password: e.try(:mailpassword)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user