25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-02 16:37:52 +01: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: 1199
This commit is contained in:
Mickaël Rémond 2008-02-19 15:19:10 +00:00
parent 327b4406db
commit 6737a9ff95
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> 2008-02-18 Christophe Romain <christophe.romain@process-one.net>
* src/ejabberd_c2s.erl: Bug in get_conn_type since SVN r1194 crashes * src/ejabberd_c2s.erl: Bug in get_conn_type since SVN r1194 crashes

View File

@ -116,7 +116,7 @@ dirty_get_registered_users() ->
lists:flatmap( lists:flatmap(
fun(M) -> fun(M) ->
M:dirty_get_registered_users() M:dirty_get_registered_users()
end, auth_modules(?MYNAME)). end, auth_modules()).
%% Registered users list do not include anonymous users logged %% Registered users list do not include anonymous users logged
get_vh_registered_users(Server) -> get_vh_registered_users(Server) ->
@ -201,7 +201,6 @@ remove_user(User, Server, Password) ->
M:remove_user(User, Server, Password) M:remove_user(User, Server, Password)
end, auth_modules(Server)). end, auth_modules(Server)).
ctl_process_get_registered(_Val, Host, ["registered-users"]) -> ctl_process_get_registered(_Val, Host, ["registered-users"]) ->
Users = ejabberd_auth:get_vh_registered_users(Host), Users = ejabberd_auth:get_vh_registered_users(Host),
NewLine = io_lib:format("~n", []), NewLine = io_lib:format("~n", []),
@ -215,6 +214,16 @@ ctl_process_get_registered(Val, _Host, _Args) ->
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% Internal functions %%% 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) -> auth_modules(Server) ->
LServer = jlib:nameprep(Server), LServer = jlib:nameprep(Server),
Method = ejabberd_config:get_local_option({auth_method, LServer}), 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) -> try_register(_User, _Server, _Password) ->
{error, not_allowed}. {error, not_allowed}.
%% TODO
%% Return the list of all users handled by external
dirty_get_registered_users() -> dirty_get_registered_users() ->
[]. [].

View File

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

View File

@ -159,7 +159,11 @@ try_register(_User, _Server, _Password) ->
{error, not_allowed}. {error, not_allowed}.
dirty_get_registered_users() -> 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) -> get_vh_registered_users(Server) ->
case catch get_vh_registered_users_ldap(Server) of case catch get_vh_registered_users_ldap(Server) of

View File

@ -130,7 +130,11 @@ try_register(User, Server, Password) ->
end. end.
dirty_get_registered_users() -> 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) -> get_vh_registered_users(Server) ->
LServer = jlib:nameprep(Server), LServer = jlib:nameprep(Server),

View File

@ -30,6 +30,7 @@
-export([start/0, load_file/1, -export([start/0, load_file/1,
add_global_option/2, add_local_option/2, add_global_option/2, add_local_option/2,
get_global_option/1, get_local_option/1]). get_global_option/1, get_local_option/1]).
-export([get_vh_by_auth_method/1]).
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("ejabberd_config.hrl"). -include("ejabberd_config.hrl").
@ -303,6 +304,11 @@ get_local_option(Opt) ->
undefined undefined
end. 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) -> check_odbc_modules(ODBC_server) ->
case catch check_odbc_modules2(ODBC_server) of case catch check_odbc_modules2(ODBC_server) of