[enh] Limit domains per user

This commit is contained in:
kload 2014-08-19 16:01:14 +02:00
parent 565f1e053d
commit f32f278105

View file

@ -485,7 +485,29 @@ function do_edit ()
end end
local mail_pattern = "[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?" local mail_pattern = "[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?"
local domains = conf["domains"]
-- Limit domains per user
local domains = {}
local ldap = lualdap.open_simple(conf["ldap_host"])
for dn, attribs in ldap:search {
base = conf["ldap_group"],
scope = "onelevel",
sizelimit = 1,
filter = "(uid="..user..")",
attrs = {"mail"}
} do
for _, domain in ipairs(conf["domains"]) do
for k, mail in ipairs(attribs["mail"]) do
if string.ends(mail, "@"..domain) then
if not is_in_table(domains, domain) then
table.insert(domains, domain)
end
end
end
end
end
ldap:close()
local mails = {} local mails = {}
local filter = "(|" local filter = "(|"
table.insert(mailalias, 1, args.mail) table.insert(mailalias, 1, args.mail)