25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-10-11 15:08:56 +02:00

* src/ejabberd_config.erl: dirty_get_registered_users now correctly returns all users for all vhosts no matter which back-end is used (EJAB-527)

* src/ejabberd_auth_odbc.erl: Likewise
* src/ejabberd_auth_internal.erl: Likewise
* src/ejabberd_auth.erl: Likewise
* src/ejabberd_auth_external.erl: Likewise
* src/ejabberd_auth_ldap.erl: Likewise

SVN Revision: 1198
This commit is contained in:
Mickaël Rémond 2008-02-19 13:49:29 +00:00
parent 56e9971435
commit 6e3ac3a5a0
7 changed files with 41 additions and 4 deletions

View File

@ -1,3 +1,14 @@
2008-02-19 Mickael Remond <mremond@process-one.net>
* src/ejabberd_config.erl: dirty_get_registered_users now
correctly returns all users for all vhosts no matter which
back-end is used (EJAB-527)
* src/ejabberd_auth_odbc.erl: Likewise
* src/ejabberd_auth_internal.erl: Likewise
* src/ejabberd_auth.erl: Likewise
* src/ejabberd_auth_external.erl: Likewise
* src/ejabberd_auth_ldap.erl: Likewise
2008-02-18 Christophe Romain <christophe.romain@process-one.net>
* src/ejabberd_c2s.erl: Bug in get_conn_type since SVN r1194 crashes

View File

@ -122,7 +122,7 @@ dirty_get_registered_users() ->
lists:flatmap(
fun(M) ->
M:dirty_get_registered_users()
end, auth_modules(?MYNAME)).
end, auth_modules()).
%% Registered users list do not include anonymous users logged
get_vh_registered_users(Server) ->
@ -207,7 +207,6 @@ remove_user(User, Server, Password) ->
M:remove_user(User, Server, Password)
end, auth_modules(Server)).
ctl_process_get_registered(_Val, Host, ["registered-users"]) ->
Users = ejabberd_auth:get_vh_registered_users(Host),
NewLine = io_lib:format("~n", []),
@ -221,6 +220,16 @@ ctl_process_get_registered(Val, _Host, _Args) ->
%%%----------------------------------------------------------------------
%%% Internal functions
%%%----------------------------------------------------------------------
%% Return the lists of all the auth modules actually used in the
%% configuration
auth_modules() ->
lists:usort(
lists:flatmap(
fun(Server) ->
auth_modules(Server)
end, ?MYHOSTS)).
%% Return the list of authenticated modules for a given host
auth_modules(Server) ->
LServer = jlib:nameprep(Server),
Method = ejabberd_config:get_local_option({auth_method, LServer}),

View File

@ -66,6 +66,8 @@ set_password(User, Server, Password) ->
try_register(_User, _Server, _Password) ->
{error, not_allowed}.
%% TODO
%% Return the list of all users handled by external
dirty_get_registered_users() ->
[].

View File

@ -134,6 +134,7 @@ try_register(User, Server, Password) ->
mnesia:transaction(F)
end.
%% Get all registered users in Mnesia
dirty_get_registered_users() ->
mnesia:dirty_all_keys(passwd).

View File

@ -159,7 +159,11 @@ try_register(_User, _Server, _Password) ->
{error, not_allowed}.
dirty_get_registered_users() ->
get_vh_registered_users(?MYNAME).
Servers = ejabberd_config:get_vh_by_auth_method(ldap),
lists:flatmap(
fun(Server) ->
get_vh_registered_users(Server)
end, Servers).
get_vh_registered_users(Server) ->
case catch get_vh_registered_users_ldap(Server) of

View File

@ -130,7 +130,11 @@ try_register(User, Server, Password) ->
end.
dirty_get_registered_users() ->
get_vh_registered_users(?MYNAME).
Servers = ejabberd_config:get_vh_by_auth_method(odbc),
lists:flatmap(
fun(Server) ->
get_vh_registered_users(Server)
end, Servers).
get_vh_registered_users(Server) ->
LServer = jlib:nameprep(Server),

View File

@ -30,6 +30,7 @@
-export([start/0, load_file/1,
add_global_option/2, add_local_option/2,
get_global_option/1, get_local_option/1]).
-export([get_vh_by_auth_method/1]).
-include("ejabberd.hrl").
-include("ejabberd_config.hrl").
@ -303,6 +304,11 @@ get_local_option(Opt) ->
undefined
end.
%% Return the list of hosts handled by a given module
get_vh_by_auth_method(AuthMethod) ->
mnesia:dirty_select(local_config,
[{#local_config{key = {auth_method, '$1'},
value=AuthMethod},[],['$1']}]).
check_odbc_modules(ODBC_server) ->
case catch check_odbc_modules2(ODBC_server) of