mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
* src/eldap/eldap.erl: Enable the keepalive socket option (thanks
to Evgeniy Khramtsov) * src/ejabberd_auth_ldap.erl: Now uses two LDAP connections (thanks to Evgeniy Khramtsov) * src/eldap/eldap_filter.erl: Bugfix (thanks to Evgeniy Khramtsov) * src/mod_vcard_ldap.erl: Likewise SVN Revision: 621
This commit is contained in:
parent
112c609222
commit
bb4f9f63b9
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2006-09-23 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/eldap/eldap.erl: Enable the keepalive socket option (thanks
|
||||||
|
to Evgeniy Khramtsov)
|
||||||
|
|
||||||
|
* src/ejabberd_auth_ldap.erl: Now uses two LDAP connections
|
||||||
|
(thanks to Evgeniy Khramtsov)
|
||||||
|
|
||||||
|
* src/eldap/eldap_filter.erl: Bugfix (thanks to Evgeniy Khramtsov)
|
||||||
|
* src/mod_vcard_ldap.erl: Likewise
|
||||||
|
|
||||||
2006-09-22 Mickael Remond <mickael.remond@process-one.net>
|
2006-09-22 Mickael Remond <mickael.remond@process-one.net>
|
||||||
|
|
||||||
* src/mod_muc/mod_muc.erl: Component name is now more user friendly
|
* src/mod_muc/mod_muc.erl: Component name is now more user friendly
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
-record(state, {host,
|
-record(state, {host,
|
||||||
eldap_id,
|
eldap_id,
|
||||||
|
bind_eldap_id,
|
||||||
servers,
|
servers,
|
||||||
port,
|
port,
|
||||||
dn,
|
dn,
|
||||||
@ -101,6 +102,11 @@ init(Host) ->
|
|||||||
State#state.port,
|
State#state.port,
|
||||||
State#state.dn,
|
State#state.dn,
|
||||||
State#state.password),
|
State#state.password),
|
||||||
|
eldap:start_link(State#state.bind_eldap_id,
|
||||||
|
State#state.servers,
|
||||||
|
State#state.port,
|
||||||
|
State#state.dn,
|
||||||
|
State#state.password),
|
||||||
ejabberd_ctl:register_commands(
|
ejabberd_ctl:register_commands(
|
||||||
Host,
|
Host,
|
||||||
[{"registered-users", "list all registered users"}],
|
[{"registered-users", "list all registered users"}],
|
||||||
@ -174,7 +180,7 @@ handle_call({check_pass, User, Password}, _From, State) ->
|
|||||||
false ->
|
false ->
|
||||||
false;
|
false;
|
||||||
DN ->
|
DN ->
|
||||||
case eldap:bind(State#state.eldap_id, DN, Password) of
|
case eldap:bind(State#state.bind_eldap_id, DN, Password) of
|
||||||
ok -> true;
|
ok -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end
|
end
|
||||||
@ -327,6 +333,7 @@ usort_attrs(_) ->
|
|||||||
|
|
||||||
parse_options(Host) ->
|
parse_options(Host) ->
|
||||||
Eldap_ID = atom_to_list(gen_mod:get_module_proc(Host, ?MODULE)),
|
Eldap_ID = atom_to_list(gen_mod:get_module_proc(Host, ?MODULE)),
|
||||||
|
Bind_Eldap_ID = atom_to_list(gen_mod:get_module_proc(Host, bind_ejabberd_auth_ldap)),
|
||||||
LDAPServers = ejabberd_config:get_local_option({ldap_servers, Host}),
|
LDAPServers = ejabberd_config:get_local_option({ldap_servers, Host}),
|
||||||
LDAPPort = case ejabberd_config:get_local_option({ldap_port, Host}) of
|
LDAPPort = case ejabberd_config:get_local_option({ldap_port, Host}) of
|
||||||
undefined -> 389;
|
undefined -> 389;
|
||||||
@ -363,6 +370,7 @@ parse_options(Host) ->
|
|||||||
end,
|
end,
|
||||||
#state{host = Host,
|
#state{host = Host,
|
||||||
eldap_id = Eldap_ID,
|
eldap_id = Eldap_ID,
|
||||||
|
bind_eldap_id = Bind_Eldap_ID,
|
||||||
servers = LDAPServers,
|
servers = LDAPServers,
|
||||||
port = LDAPPort,
|
port = LDAPPort,
|
||||||
dn = RootDN,
|
dn = RootDN,
|
||||||
|
@ -808,7 +808,7 @@ polish([], Res, Ref) ->
|
|||||||
%%-----------------------------------------------------------------------
|
%%-----------------------------------------------------------------------
|
||||||
connect_bind(S) ->
|
connect_bind(S) ->
|
||||||
Host = next_host(S#eldap.host, S#eldap.hosts),
|
Host = next_host(S#eldap.host, S#eldap.hosts),
|
||||||
TcpOpts = [{packet, asn1}, {active, true}, binary],
|
TcpOpts = [{packet, asn1}, {active, true}, {keepalive, true}, binary],
|
||||||
case gen_tcp:connect(Host, S#eldap.port, TcpOpts) of
|
case gen_tcp:connect(Host, S#eldap.port, TcpOpts) of
|
||||||
{ok, Socket} ->
|
{ok, Socket} ->
|
||||||
case bind_request(Socket, S) of
|
case bind_request(Socket, S) of
|
||||||
|
@ -202,8 +202,12 @@ do_sub(S, []) ->
|
|||||||
do_sub([], _) ->
|
do_sub([], _) ->
|
||||||
[];
|
[];
|
||||||
|
|
||||||
do_sub(S, [H | T]) ->
|
do_sub(S, [{RegExp, New} | T]) ->
|
||||||
Result = do_sub(S, H, 1),
|
Result = do_sub(S, {RegExp, replace_amps(New)}, 1),
|
||||||
|
do_sub(Result, T);
|
||||||
|
|
||||||
|
do_sub(S, [{RegExp, New, Times} | T]) ->
|
||||||
|
Result = do_sub(S, {RegExp, replace_amps(New), Times}, 1),
|
||||||
do_sub(Result, T).
|
do_sub(Result, T).
|
||||||
|
|
||||||
do_sub(S, {RegExp, New}, Iter) ->
|
do_sub(S, {RegExp, New}, Iter) ->
|
||||||
@ -246,6 +250,18 @@ remove_extra_asterisks(String) ->
|
|||||||
{"", ""}, String),
|
{"", ""}, String),
|
||||||
Res.
|
Res.
|
||||||
|
|
||||||
|
replace_amps(String) ->
|
||||||
|
lists:foldl(
|
||||||
|
fun(X, Acc) ->
|
||||||
|
if
|
||||||
|
X == $& ->
|
||||||
|
Acc ++ "\\&";
|
||||||
|
true ->
|
||||||
|
Acc ++ [X]
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
"", String).
|
||||||
|
|
||||||
split_attribute(String) ->
|
split_attribute(String) ->
|
||||||
split_attribute(String, "", $0).
|
split_attribute(String, "", $0).
|
||||||
|
|
||||||
|
@ -670,14 +670,9 @@ map_vcard_attr(VCardName, Attributes, Pattern, UD) ->
|
|||||||
_ -> ""
|
_ -> ""
|
||||||
end.
|
end.
|
||||||
|
|
||||||
process_pattern(Str, {User, Domain}, Attrs) ->
|
process_pattern(Str, {User, Domain}, AttrValues) ->
|
||||||
Res = lists:foldl(
|
eldap_filter:do_sub(Str,
|
||||||
fun(X, Acc) ->
|
[{"%s", V, 1} || V <- AttrValues] ++ [{"%u", User},{"%d", Domain}]).
|
||||||
{ok, NewStr, _} = regexp:sub(Acc, "%s", X),
|
|
||||||
NewStr
|
|
||||||
end,
|
|
||||||
Str, Attrs),
|
|
||||||
eldap_filter:do_sub(Res, [{"%u", User},{"%d", Domain}]).
|
|
||||||
|
|
||||||
get_ldap_attr(LDAPAttr, Attributes) ->
|
get_ldap_attr(LDAPAttr, Attributes) ->
|
||||||
Res = lists:filter(
|
Res = lists:filter(
|
||||||
|
Loading…
Reference in New Issue
Block a user