mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +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>
|
||||
|
||||
* src/mod_muc/mod_muc.erl: Component name is now more user friendly
|
||||
|
@ -44,6 +44,7 @@
|
||||
|
||||
-record(state, {host,
|
||||
eldap_id,
|
||||
bind_eldap_id,
|
||||
servers,
|
||||
port,
|
||||
dn,
|
||||
@ -101,6 +102,11 @@ init(Host) ->
|
||||
State#state.port,
|
||||
State#state.dn,
|
||||
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(
|
||||
Host,
|
||||
[{"registered-users", "list all registered users"}],
|
||||
@ -174,7 +180,7 @@ handle_call({check_pass, User, Password}, _From, State) ->
|
||||
false ->
|
||||
false;
|
||||
DN ->
|
||||
case eldap:bind(State#state.eldap_id, DN, Password) of
|
||||
case eldap:bind(State#state.bind_eldap_id, DN, Password) of
|
||||
ok -> true;
|
||||
_ -> false
|
||||
end
|
||||
@ -327,6 +333,7 @@ usort_attrs(_) ->
|
||||
|
||||
parse_options(Host) ->
|
||||
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}),
|
||||
LDAPPort = case ejabberd_config:get_local_option({ldap_port, Host}) of
|
||||
undefined -> 389;
|
||||
@ -363,6 +370,7 @@ parse_options(Host) ->
|
||||
end,
|
||||
#state{host = Host,
|
||||
eldap_id = Eldap_ID,
|
||||
bind_eldap_id = Bind_Eldap_ID,
|
||||
servers = LDAPServers,
|
||||
port = LDAPPort,
|
||||
dn = RootDN,
|
||||
|
@ -808,7 +808,7 @@ polish([], Res, Ref) ->
|
||||
%%-----------------------------------------------------------------------
|
||||
connect_bind(S) ->
|
||||
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
|
||||
{ok, Socket} ->
|
||||
case bind_request(Socket, S) of
|
||||
|
@ -202,8 +202,12 @@ do_sub(S, []) ->
|
||||
do_sub([], _) ->
|
||||
[];
|
||||
|
||||
do_sub(S, [H | T]) ->
|
||||
Result = do_sub(S, H, 1),
|
||||
do_sub(S, [{RegExp, New} | T]) ->
|
||||
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(S, {RegExp, New}, Iter) ->
|
||||
@ -246,6 +250,18 @@ remove_extra_asterisks(String) ->
|
||||
{"", ""}, String),
|
||||
Res.
|
||||
|
||||
replace_amps(String) ->
|
||||
lists:foldl(
|
||||
fun(X, Acc) ->
|
||||
if
|
||||
X == $& ->
|
||||
Acc ++ "\\&";
|
||||
true ->
|
||||
Acc ++ [X]
|
||||
end
|
||||
end,
|
||||
"", String).
|
||||
|
||||
split_attribute(String) ->
|
||||
split_attribute(String, "", $0).
|
||||
|
||||
|
@ -670,14 +670,9 @@ map_vcard_attr(VCardName, Attributes, Pattern, UD) ->
|
||||
_ -> ""
|
||||
end.
|
||||
|
||||
process_pattern(Str, {User, Domain}, Attrs) ->
|
||||
Res = lists:foldl(
|
||||
fun(X, Acc) ->
|
||||
{ok, NewStr, _} = regexp:sub(Acc, "%s", X),
|
||||
NewStr
|
||||
end,
|
||||
Str, Attrs),
|
||||
eldap_filter:do_sub(Res, [{"%u", User},{"%d", Domain}]).
|
||||
process_pattern(Str, {User, Domain}, AttrValues) ->
|
||||
eldap_filter:do_sub(Str,
|
||||
[{"%s", V, 1} || V <- AttrValues] ++ [{"%u", User},{"%d", Domain}]).
|
||||
|
||||
get_ldap_attr(LDAPAttr, Attributes) ->
|
||||
Res = lists:filter(
|
||||
|
Loading…
Reference in New Issue
Block a user