+2006-11-23 Alexey Shchepin <alexey@sevcom.net>
+
+ * src/eldap/eldap.erl: Bugfix (thanks to Evgeniy Khramtsov)
+
+ * src/ejabberd_sm.erl: The max_user_sessions option is now
+ configured via access rule
+ * src/ejabberd.cfg.example: Likewise
+
2006-11-20 Mickael Remond <mickael.remond@process-one.net>
* src/ejd2odbc.erl: Copy mod_private data from Mnesia to
{hosts, ["localhost"]}.
%% Define the maximum number of time a single user is allowed to connect:
-{max_user_sessions, 10}.
+{access, max_user_sessions, [{10, all}]}.
%% Anonymous login support:
%% auth_method: anonymous
SIDs = mnesia:dirty_select(
session,
[{#session{sid = '$1', usr = {LUser, LServer, '_'}, _ = '_'}, [], ['$1']}]),
- MaxSessions = get_max_user_sessions(LServer),
+ MaxSessions = get_max_user_sessions(LUser, LServer),
if length(SIDs) =< MaxSessions -> ok;
true -> {_, Pid} = lists:min(SIDs),
Pid ! replaced
%% This option defines the max number of time a given users are allowed to
%% log in
%% Defaults to infinity
-get_max_user_sessions(Host) ->
- case ejabberd_config:get_local_option({max_user_sessions, Host}) of
- undefined -> ?MAX_USER_SESSIONS;
- Max -> Max
+get_max_user_sessions(LUser, Host) ->
+ case acl:match_rule(
+ Host, max_user_sessions, jlib:make_jid(LUser, Host, "")) of
+ Max when is_integer(Max) -> Max;
+ infinity -> infinity;
+ _ -> ?MAX_USER_SESSIONS
end.
check_id(S#eldap.id, Msg#'LDAPMessage'.messageID),
case Msg#'LDAPMessage'.protocolOp of
{bindResponse, Result} ->
- case Result#'LDAPResult'.resultCode of
+ case Result#'BindResponse'.resultCode of
success -> bound;
Error -> {fail_bind, Error}
end