summaryrefslogtreecommitdiff
path: root/src/ejabberd_auth_ldap.erl
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-30 19:01:47 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2017-04-30 19:01:47 +0300
commitfddd6110e00df12c99a20a2cc9d074f5f4f1f965 (patch)
tree366575b855f1b2013db7eeb02ecb213f81c98c1f /src/ejabberd_auth_ldap.erl
parentMerge branch 'new-option-validation' (diff)
Don't validate an option in gen_mod:get*opt() functions
The changes are very similar to those from previous commit: * Now there is no need to pass validating function in gen_mod:get_opt() and gen_mod:get_module_opt() functions, because the modules' configuration keeps already validated values. * New functions gen_mod:get_opt/2 and gen_mod:get_module_opt/3 are introduced. * Functions gen_mod:get_opt/4 and get_module_opt/5 are deprecated. If the functions are still called, the "function" argument is simply ignored. * Validating callback Mod:listen_opt_type/1 is introduced to validate listening options at startup.
Diffstat (limited to 'src/ejabberd_auth_ldap.erl')
-rw-r--r--src/ejabberd_auth_ldap.erl35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/ejabberd_auth_ldap.erl b/src/ejabberd_auth_ldap.erl
index 81c2ab9d..53c25649 100644
--- a/src/ejabberd_auth_ldap.erl
+++ b/src/ejabberd_auth_ldap.erl
@@ -364,24 +364,11 @@ parse_options(Host) ->
Eldap_ID = misc:atom_to_binary(gen_mod:get_module_proc(Host, ?MODULE)),
Bind_Eldap_ID = misc:atom_to_binary(
gen_mod:get_module_proc(Host, bind_ejabberd_auth_ldap)),
- UIDsTemp = gen_mod:get_opt(
- {ldap_uids, Host}, [],
- fun(Us) ->
- lists:map(
- fun({U, P}) ->
- {iolist_to_binary(U),
- iolist_to_binary(P)};
- ({U}) ->
- {iolist_to_binary(U)};
- (U) ->
- {iolist_to_binary(U)}
- end, lists:flatten(Us))
- end, [{<<"uid">>, <<"%u">>}]),
+ UIDsTemp = ejabberd_config:get_option(
+ {ldap_uids, Host}, [{<<"uid">>, <<"%u">>}]),
UIDs = eldap_utils:uids_domain_subst(Host, UIDsTemp),
SubFilter = eldap_utils:generate_subfilter(UIDs),
- UserFilter = case gen_mod:get_opt(
- {ldap_filter, Host}, [],
- fun eldap_utils:check_filter/1, <<"">>) of
+ UserFilter = case ejabberd_config:get_option({ldap_filter, Host}, <<"">>) of
<<"">> ->
SubFilter;
F ->
@@ -390,20 +377,8 @@ parse_options(Host) ->
SearchFilter = eldap_filter:do_sub(UserFilter,
[{<<"%u">>, <<"*">>}]),
{DNFilter, DNFilterAttrs} =
- gen_mod:get_opt({ldap_dn_filter, Host}, [],
- fun([{DNF, DNFA}]) ->
- NewDNFA = case DNFA of
- undefined ->
- [];
- _ ->
- [iolist_to_binary(A)
- || A <- DNFA]
- end,
- NewDNF = eldap_utils:check_filter(DNF),
- {NewDNF, NewDNFA}
- end, {undefined, []}),
- LocalFilter = gen_mod:get_opt(
- {ldap_local_filter, Host}, [], fun(V) -> V end),
+ ejabberd_config:get_option({ldap_dn_filter, Host}, {undefined, []}),
+ LocalFilter = ejabberd_config:get_option({ldap_local_filter, Host}),
#state{host = Host, eldap_id = Eldap_ID,
bind_eldap_id = Bind_Eldap_ID,
servers = Cfg#eldap_config.servers,