25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

* src/mod_vcard_ldap.erl: Bugfix

* src/mod_vcard.erl: Bugfix

* src/ejabberd_auth_odbc.erl: Bugfix

* doc/dev.tex: Updated

SVN Revision: 406
This commit is contained in:
Alexey Shchepin 2005-08-25 20:48:45 +00:00
parent ee3551db4b
commit a884ba4e8a
6 changed files with 163 additions and 113 deletions

View File

@ -1,3 +1,17 @@
2005-08-25 Alexey Shchepin <alexey@sevcom.net>
* src/mod_vcard_ldap.erl: Bugfix
* src/mod_vcard.erl: Bugfix
2005-08-23 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_auth_odbc.erl: Bugfix
2005-08-21 Alexey Shchepin <alexey@sevcom.net>
* doc/dev.tex: Updated
2005-08-11 Alexey Shchepin <alexey@sevcom.net>
* src/cyrsasl_digest.erl: Fixed challenge/response parsing (thanks

View File

@ -4,7 +4,7 @@
<HEAD><TITLE>Ejabberd Developers Guide</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=ISO8859-1">
<META name="GENERATOR" content="hevea 1.06">
<META name="GENERATOR" content="hevea 1.07">
</HEAD>
<BODY >
<!--HEVEA command line is: /usr/bin/hevea -charset ISO8859-1 dev.tex -->
@ -21,7 +21,7 @@
<A HREF="mailto:alexey@sevcom.net"><TT>mailto:alexey@sevcom.net</TT></A><BR>
<A HREF="xmpp:aleksey@jabber.ru"><TT>xmpp:aleksey@jabber.ru</TT></A></H3>
<H3 ALIGN=center>September 10, 2003</H3><DIV ALIGN=center>
<H3 ALIGN=center>August 21, 2005</H3><DIV ALIGN=center>
<IMG SRC="logo.png">
@ -47,11 +47,12 @@
</UL>
<LI><A HREF="#htoc7">2&nbsp;&nbsp;XML representation</A>
<LI><A HREF="#htoc8">3&nbsp;&nbsp;Module <TT>xml</TT></A>
<LI><A HREF="#htoc9">4&nbsp;&nbsp;<TT>ejabberd</TT> modules</A>
<LI><A HREF="#htoc9">4&nbsp;&nbsp;Module <TT>xml_stream</TT></A>
<LI><A HREF="#htoc10">5&nbsp;&nbsp;<TT>ejabberd</TT> modules</A>
<UL><LI>
<A HREF="#htoc10">4.1&nbsp;&nbsp;<CODE>gen_mod</CODE> behaviour</A>
<LI><A HREF="#htoc11">4.2&nbsp;&nbsp;Module <CODE>gen_iq_handler</CODE></A>
<LI><A HREF="#htoc12">4.3&nbsp;&nbsp;Services</A>
<A HREF="#htoc11">5.1&nbsp;&nbsp;<CODE>gen_mod</CODE> behaviour</A>
<LI><A HREF="#htoc12">5.2&nbsp;&nbsp;Module <CODE>gen_iq_handler</CODE></A>
<LI><A HREF="#htoc13">5.3&nbsp;&nbsp;Services</A>
</UL>
</UL>
@ -90,9 +91,6 @@ Works on most of popular platforms: *nix (tested on Linux, FreeBSD and
<LI>Support for <A HREF="http://www.jabber.org/jeps/jep-0039.html">Statistics Gathering</A>.
<LI>Support for <TT>xml:lang</TT>
</UL>
<TT>ejabberd</TT> is a Free and Open Source fault-tolerant distributed Jabber
server. It is written mostly in Erlang.<BR>
<BR>
<!--TOC subsection How it works-->
<H3><A NAME="htoc2">1.1</A>&nbsp;&nbsp;How it works</H3><!--SEC END -->
@ -158,7 +156,7 @@ does not exist, then it is opened and registered.<BR>
<H2><A NAME="htoc7">2</A>&nbsp;&nbsp;XML representation</H2><!--SEC END -->
<A NAME="sec:xmlrepr"></A>
Each XML stanza represented as following tuple:
Each XML stanza is represented as the following tuple:
<PRE>
XMLElement = {xmlelement, Name, Attrs, [ElementOrCDATA]}
Name = string()
@ -173,7 +171,7 @@ XMLElement = {xmlelement, Name, Attrs, [ElementOrCDATA]}
&lt;message to='test@conference.example.org' type='groupchat'&gt;
&lt;body&gt;test&lt;/body&gt;
&lt;/message&gt;
</PRE>represented as following structure:
</PRE>is represented as the following structure:
<PRE>
{xmlelement, "message",
[{"to", "test@conference.example.org"},
@ -233,21 +231,34 @@ Res = string() | XMLElement
get_tag_attr/2, get_tag_attr_s/2
get_subtag/2
</PRE></DL>
<!--TOC section Module <TT>xml_stream</TT>-->
<H2><A NAME="htoc9">4</A>&nbsp;&nbsp;Module <TT>xml_stream</TT></H2><!--SEC END -->
<A NAME="sec:xmlstreammod"></A>
<DL COMPACT=compact><DT>
<CODE><B>parse_element(Str) -&gt; XMLElement | {error, Err}</B></CODE><DD>
<PRE>
Str = string()
Err = term()
</PRE>Parses <TT>Str</TT> using XML parser, returns either parsed element or error
tuple.
</DL>
<!--TOC section <TT>ejabberd</TT> modules-->
<H2><A NAME="htoc9">4</A>&nbsp;&nbsp;<TT>ejabberd</TT> modules</H2><!--SEC END -->
<H2><A NAME="htoc10">5</A>&nbsp;&nbsp;<TT>ejabberd</TT> modules</H2><!--SEC END -->
<A NAME="sec:emods"></A>
<!--TOC subsection <CODE>gen_mod</CODE> behaviour-->
<H3><A NAME="htoc10">4.1</A>&nbsp;&nbsp;<CODE>gen_mod</CODE> behaviour</H3><!--SEC END -->
<H3><A NAME="htoc11">5.1</A>&nbsp;&nbsp;<CODE>gen_mod</CODE> behaviour</H3><!--SEC END -->
<A NAME="sec:genmod"></A>
TBD<BR>
<BR>
<!--TOC subsection Module <CODE>gen_iq_handler</CODE>-->
<H3><A NAME="htoc11">4.2</A>&nbsp;&nbsp;Module <CODE>gen_iq_handler</CODE></H3><!--SEC END -->
<H3><A NAME="htoc12">5.2</A>&nbsp;&nbsp;Module <CODE>gen_iq_handler</CODE></H3><!--SEC END -->
<A NAME="sec:geniqhandl"></A>
The module <CODE>gen_iq_handler</CODE> allows to easily write handlers for IQ packets
@ -255,23 +266,25 @@ of particular XML namespaces that addressed to server or to users bare JIDs.<BR>
<BR>
In this module the following functions are defined:
<DL COMPACT=compact><DT>
<CODE><B>add_iq_handler(Component, NS, Module, Function, Type)</B></CODE><DD>
<CODE><B>add_iq_handler(Component, Host, NS, Module, Function, Type)</B></CODE><DD>
<PRE>
Component = Module = Function = atom()
NS = string()
Host = NS = string()
Type = no_queue | one_queue | parallel
</PRE>Registers function <CODE>Module:Function</CODE> as handler for IQ packets that
contain child of namespace <CODE>NS</CODE> in <CODE>Component</CODE>. Queueing
discipline is <CODE>Type</CODE>. There are at least two components defined:
</PRE>Registers function <CODE>Module:Function</CODE> as handler for IQ packets on
virtual host <CODE>Host</CODE> that contain child of namespace <CODE>NS</CODE> in
<CODE>Component</CODE>. Queueing discipline is <CODE>Type</CODE>. There are at least
two components defined:
<DL COMPACT=compact><DT>
<CODE><B>ejabberd_local</B></CODE><DD> Handles packets that addressed to server JID;
<DT><CODE><B>ejabberd_sm</B></CODE><DD> Handles packets that addressed to users bare JIDs.
</DL>
<DT><CODE><B>remove_iq_handler(Component, NS)</B></CODE><DD>
<DT><CODE><B>remove_iq_handler(Component, Host, NS)</B></CODE><DD>
<PRE>
Component = atom()
NS = string()
</PRE>Removes IQ handler for namespace <CODE>NS</CODE> from <CODE>Component</CODE>.
Host = NS = string()
</PRE>Removes IQ handler on virtual host <CODE>Host</CODE> for namespace <CODE>NS</CODE> from
<CODE>Component</CODE>.
</DL>
Handler function must have the following type:
<DL COMPACT=compact><DT>
@ -284,8 +297,8 @@ From = To = jid()
-behaviour(gen_mod).
-export([start/1,
stop/0,
-export([start/2,
stop/1,
process_local_iq/3]).
-include("ejabberd.hrl").
@ -293,13 +306,13 @@ From = To = jid()
-define(NS_CPUTIME, "ejabberd:cputime").
start(Opts) -&gt;
start(Host, Opts) -&gt;
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_CPUTIME,
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_CPUTIME,
?MODULE, process_local_iq, IQDisc).
stop() -&gt;
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_CPUTIME).
stop(Host) -&gt;
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_CPUTIME).
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) -&gt;
case Type of
@ -317,7 +330,7 @@ process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) -&gt;
</PRE>
<!--TOC subsection Services-->
<H3><A NAME="htoc12">4.3</A>&nbsp;&nbsp;Services</H3><!--SEC END -->
<H3><A NAME="htoc13">5.3</A>&nbsp;&nbsp;Services</H3><!--SEC END -->
<A NAME="sec:services"></A>
TBD<BR>
@ -328,14 +341,15 @@ TODO: use <CODE>proc_lib</CODE>
-behaviour(gen_mod).
-export([start/1, init/1, stop/0]).
-export([start/2, init/1, stop/1]).
-include("ejabberd.hrl").
-include("jlib.hrl").
start(Opts) -&gt;
Host = gen_mod:get_opt(host, Opts, "echo." ++ ?MYNAME),
register(ejabberd_mod_echo, spawn(?MODULE, init, [Host])).
start(Host, Opts) -&gt;
MyHost = gen_mod:get_opt(host, Opts, "echo." ++ Host),
register(gen_mod:get_module_proc(Host, ?PROCNAME),
spawn(?MODULE, init, [MyHost])).
init(Host) -&gt;
ejabberd_router:register_local_route(Host),
@ -347,15 +361,16 @@ loop(Host) -&gt;
ejabberd_router:route(To, From, Packet),
loop(Host);
stop -&gt;
ejabberd_router:unregister_local_route(Host),
ejabberd_router:unregister_route(Host),
ok;
_ -&gt;
loop(Host)
end.
stop() -&gt;
ejabberd_mod_echo ! stop,
ok.
stop(Host) -&gt;
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
Proc ! stop,
{wait, Proc}.
</PRE>
<!--HTMLFOOT-->
<!--ENDHTML-->

View File

@ -41,7 +41,7 @@
\author{Alexey Shchepin \\
\ahrefurl{mailto:alexey@sevcom.net} \\
\ahrefurl{xmpp:aleksey@jabber.ru}}
\date{September 10, 2003}
\date{August 21, 2005}
\begin{document}
\begin{titlepage}
@ -89,8 +89,6 @@ The main features of \ejabberd{} are:
\item Support for \tjepref{0039}{Statistics Gathering}.
\item Support for \ns{xml:lang}
\end{itemize}
\ejabberd{} is a Free and Open Source fault-tolerant distributed \Jabber{}
server. It is written mostly in Erlang.
@ -158,7 +156,7 @@ does not exist, then it is opened and registered.
\section{XML representation}
\label{sec:xmlrepr}
Each XML stanza represented as following tuple:
Each XML stanza is represented as the following tuple:
\begin{verbatim}
XMLElement = {xmlelement, Name, Attrs, [ElementOrCDATA]}
Name = string()
@ -175,7 +173,7 @@ E.\,g. this stanza:
<body>test</body>
</message>
\end{verbatim}
represented as following structure:
is represented as the following structure:
\begin{verbatim}
{xmlelement, "message",
[{"to", "test@conference.example.org"},
@ -245,6 +243,18 @@ Res = string() | XMLElement
\end{description}
\section{Module \texttt{xml\_stream}}
\label{sec:xmlstreammod}
\begin{description}
\item[\verb!parse_element(Str) -> XMLElement | {error, Err}!]
\begin{verbatim}
Str = string()
Err = term()
\end{verbatim}
Parses \texttt{Str} using XML parser, returns either parsed element or error
tuple.
\end{description}
\section{\ejabberd{} modules}
@ -264,25 +274,27 @@ of particular XML namespaces that addressed to server or to users bare JIDs.
In this module the following functions are defined:
\begin{description}
\item[\verb|add_iq_handler(Component, NS, Module, Function, Type)|]
\item[\verb|add_iq_handler(Component, Host, NS, Module, Function, Type)|]
\begin{verbatim}
Component = Module = Function = atom()
NS = string()
Host = NS = string()
Type = no_queue | one_queue | parallel
\end{verbatim}
Registers function \verb|Module:Function| as handler for IQ packets that
contain child of namespace \verb|NS| in \verb|Component|. Queueing
discipline is \verb|Type|. There are at least two components defined:
Registers function \verb|Module:Function| as handler for IQ packets on
virtual host \verb|Host| that contain child of namespace \verb|NS| in
\verb|Component|. Queueing discipline is \verb|Type|. There are at least
two components defined:
\begin{description}
\item[\verb|ejabberd_local|] Handles packets that addressed to server JID;
\item[\verb|ejabberd_sm|] Handles packets that addressed to users bare JIDs.
\end{description}
\item[\verb|remove_iq_handler(Component, NS)|]
\item[\verb|remove_iq_handler(Component, Host, NS)|]
\begin{verbatim}
Component = atom()
NS = string()
Host = NS = string()
\end{verbatim}
Removes IQ handler for namespace \verb|NS| from \verb|Component|.
Removes IQ handler on virtual host \verb|Host| for namespace \verb|NS| from
\verb|Component|.
\end{description}
Handler function must have the following type:
@ -300,8 +312,8 @@ From = To = jid()
-behaviour(gen_mod).
-export([start/1,
stop/0,
-export([start/2,
stop/1,
process_local_iq/3]).
-include("ejabberd.hrl").
@ -309,13 +321,13 @@ From = To = jid()
-define(NS_CPUTIME, "ejabberd:cputime").
start(Opts) ->
start(Host, Opts) ->
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_CPUTIME,
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_CPUTIME,
?MODULE, process_local_iq, IQDisc).
stop() ->
gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_CPUTIME).
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_CPUTIME).
process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
case Type of
@ -345,14 +357,15 @@ TODO: use \verb|proc_lib|
-behaviour(gen_mod).
-export([start/1, init/1, stop/0]).
-export([start/2, init/1, stop/1]).
-include("ejabberd.hrl").
-include("jlib.hrl").
start(Opts) ->
Host = gen_mod:get_opt(host, Opts, "echo." ++ ?MYNAME),
register(ejabberd_mod_echo, spawn(?MODULE, init, [Host])).
start(Host, Opts) ->
MyHost = gen_mod:get_opt(host, Opts, "echo." ++ Host),
register(gen_mod:get_module_proc(Host, ?PROCNAME),
spawn(?MODULE, init, [MyHost])).
init(Host) ->
ejabberd_router:register_local_route(Host),
@ -364,15 +377,16 @@ loop(Host) ->
ejabberd_router:route(To, From, Packet),
loop(Host);
stop ->
ejabberd_router:unregister_local_route(Host),
ejabberd_router:unregister_route(Host),
ok;
_ ->
loop(Host)
end.
stop() ->
ejabberd_mod_echo ! stop,
ok.
stop(Host) ->
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
Proc ! stop,
{wait, Proc}.
\end{verbatim}

View File

@ -122,11 +122,12 @@ dirty_get_registered_users() ->
get_vh_registered_users(?MYNAME).
get_vh_registered_users(Server) ->
LServer = jlib:nameprep(Server),
case catch ejabberd_odbc:sql_query(
jlib:nameprep(Server),
LServer,
"select username from users") of
{selected, ["username"], Res} ->
[U || {U} <- Res];
[{U, LServer} || {U} <- Res];
_ ->
[]
end.

View File

@ -12,7 +12,7 @@
-behaviour(gen_mod).
-export([start/2, init/2, stop/1,
-export([start/2, init/3, stop/1,
process_local_iq/3,
process_sm_iq/3,
reindex_vcards/0,
@ -70,36 +70,36 @@ start(Host, Opts) ->
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_VCARD,
?MODULE, process_sm_iq, IQDisc),
catch mod_disco:register_sm_feature(Host, ?NS_VCARD),
Hosts = gen_mod:get_hosts(Opts, "vjud."),
MyHost = gen_mod:get_opt(host, Opts, "vjud." ++ Host),
Search = gen_mod:get_opt(search, Opts, true),
register(gen_mod:get_module_proc(Host, ?PROCNAME),
spawn(?MODULE, init, [Hosts, Search])).
spawn(?MODULE, init, [MyHost, Host, Search])).
init(Hosts, Search) ->
init(Host, ServerHost, Search) ->
case Search of
false ->
loop(Hosts);
loop(Host, ServerHost);
_ ->
ejabberd_router:register_routes(Hosts),
loop(Hosts)
ejabberd_router:register_route(Host),
loop(Host, ServerHost)
end.
loop(Hosts) ->
loop(Host, ServerHost) ->
receive
{route, From, To, Packet} ->
case catch do_route(From, To, Packet) of
case catch do_route(ServerHost, From, To, Packet) of
{'EXIT', Reason} ->
?ERROR_MSG("~p", [Reason]);
_ ->
ok
end,
loop(Hosts);
loop(Host, ServerHost);
stop ->
catch ejabberd_router:unregister_routes(Hosts),
ejabberd_router:unregister_route(Host),
ok;
_ ->
loop(Hosts)
loop(Host, ServerHost)
end.
stop(Host) ->
@ -272,7 +272,7 @@ set_vcard(User, LServer, VCARD) ->
do_route(From, To, Packet) ->
do_route(ServerHost, From, To, Packet) ->
#jid{user = User, resource = Resource} = To,
if
(User /= "") or (Resource /= "") ->
@ -310,7 +310,7 @@ do_route(From, To, Packet) ->
[{xmlelement, "x",
[{"xmlns", ?NS_XDATA},
{"type", "result"}],
search_result(Lang, To, XData)
search_result(Lang, To, ServerHost, XData)
}]}]},
ejabberd_router:route(
To, From, jlib:iq_to_xml(ResIQ))
@ -420,7 +420,7 @@ find_xdata_el1([_ | Els]) ->
{xmlelement, "field", [{"label", translate:translate(Lang, Label)},
{"var", Var}], []}).
search_result(Lang, JID, Data) ->
search_result(Lang, JID, ServerHost, Data) ->
[{xmlelement, "title", [],
[{xmlcdata, translate:translate(Lang, "Results of search in ") ++
jlib:jid_to_string(JID)}]},
@ -437,7 +437,7 @@ search_result(Lang, JID, Data) ->
?LFIELD("email", "email"),
?LFIELD("Organization Name", "orgname"),
?LFIELD("Organization Unit", "orgunit")
]}] ++ lists:map(fun record_to_item/1, search(JID#jid.lserver, Data)).
]}] ++ lists:map(fun record_to_item/1, search(ServerHost, Data)).
-define(FIELD(Var, Val),
{xmlelement, "field", [{"var", Var}],

View File

@ -12,7 +12,7 @@
-behaviour(gen_mod).
-export([start/2, init/2, stop/1,
-export([start/2, init/3, stop/1,
process_local_iq/3,
process_sm_iq/3,
remove_user/1]).
@ -21,6 +21,7 @@
-include("eldap/eldap.hrl").
-include("jlib.hrl").
-define(PROCNAME, ejabberd_mod_vcard_ldap).
start(Host, Opts) ->
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
@ -28,45 +29,47 @@ start(Host, Opts) ->
?MODULE, process_local_iq, IQDisc),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_VCARD,
?MODULE, process_sm_iq, IQDisc),
LDAPServers = ejabberd_config:get_local_option(ldap_servers),
RootDN = ejabberd_config:get_local_option(ldap_rootdn),
Password = ejabberd_config:get_local_option(ldap_password),
LDAPServers = ejabberd_config:get_local_option({ldap_servers, Host}),
RootDN = ejabberd_config:get_local_option({ldap_rootdn, Host}),
Password = ejabberd_config:get_local_option({ldap_password, Host}),
eldap:start_link("mod_vcard_ldap", LDAPServers, 389, RootDN, Password),
Host = gen_mod:get_opt(host, Opts, "vjud." ++ ?MYNAME),
MyHost = gen_mod:get_opt(host, Opts, "vjud." ++ Host),
Search = gen_mod:get_opt(search, Opts, true),
register(ejabberd_mod_vcard_ldap, spawn(?MODULE, init, [Host, Search])).
register(gen_mod:get_module_proc(Host, ?PROCNAME),
spawn(?MODULE, init, [MyHost, Host, Search])).
init(Host, Search) ->
init(Host, ServerHost, Search) ->
case Search of
false ->
loop(Host);
loop(Host, ServerHost);
_ ->
ejabberd_router:register_route(Host),
loop(Host)
loop(Host, ServerHost)
end.
loop(Host) ->
loop(Host, ServerHost) ->
receive
{route, From, To, Packet} ->
case catch do_route(From, To, Packet) of
case catch do_route(ServerHost, From, To, Packet) of
{'EXIT', Reason} ->
?ERROR_MSG("~p", [Reason]);
_ ->
ok
end,
loop(Host);
loop(Host, ServerHost);
stop ->
catch ejabberd_router:unregister_route(Host),
ejabberd_router:unregister_route(Host),
ok;
_ ->
loop(Host)
loop(Host, ServerHost)
end.
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_VCARD),
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_VCARD),
ejabberd_mod_vcard_ldap ! stop,
ok.
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
Proc ! stop,
{wait, Proc}.
process_local_iq(_From, _To, #iq{type = Type, lang = Lang, sub_el = SubEl} = IQ) ->
case Type of
@ -92,10 +95,10 @@ process_local_iq(_From, _To, #iq{type = Type, lang = Lang, sub_el = SubEl} = IQ)
]}]}
end.
find_ldap_user(User) ->
Attr = ejabberd_config:get_local_option(ldap_uidattr),
find_ldap_user(Host, User) ->
Attr = ejabberd_config:get_local_option({ldap_uidattr, Host}),
Filter = eldap:equalityMatch(Attr, User),
Base = ejabberd_config:get_local_option(ldap_base),
Base = ejabberd_config:get_local_option({ldap_base, Host}),
case eldap:search("mod_vcard_ldap", [{base, Base},
{filter, Filter},
{attributes, []}]) of
@ -192,12 +195,13 @@ process_sm_iq(From, To, #iq{type = Type, sub_el = SubEl} = IQ) ->
set ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
get ->
#jid{luser = LUser} = To,
case find_ldap_user(LUser) of
#jid{luser = LUser, lserver = LServer} = To,
case find_ldap_user(LServer, LUser) of
#eldap_entry{attributes = Attributes} ->
Vcard = ldap_attributes_to_vcard(Attributes,From,To),
IQ#iq{type = result, sub_el = Vcard};
_ -> IQ#iq{type = result, sub_el = []}
_ ->
IQ#iq{type = result, sub_el = []}
end
end.
@ -234,7 +238,7 @@ process_sm_iq(From, To, #iq{type = Type, sub_el = SubEl} = IQ) ->
do_route(From, To, Packet) ->
do_route(ServerHost, From, To, Packet) ->
#jid{user = User, resource = Resource} = To,
if
(User /= "") or (Resource /= "") ->
@ -272,7 +276,7 @@ do_route(From, To, Packet) ->
[{xmlelement, "x",
[{"xmlns", ?NS_XDATA},
{"type", "result"}],
search_result(Lang, To, XData)
search_result(Lang, To, ServerHost, XData)
}]}]},
ejabberd_router:route(
To, From, jlib:iq_to_xml(ResIQ))
@ -382,7 +386,7 @@ find_xdata_el1([_ | Els]) ->
{xmlelement, "field", [{"label", translate:translate(Lang, Label)},
{"var", Var}], []}).
search_result(Lang, JID, Data) ->
search_result(Lang, JID, ServerHost, Data) ->
[{xmlelement, "title", [],
[{xmlcdata, translate:translate(Lang, "Results of search in ") ++
jlib:jid_to_string(JID)}]},
@ -401,7 +405,7 @@ search_result(Lang, JID, Data) ->
?LFIELD("Organization Unit", "orgunit")
]}] ++ lists:map(fun(E) ->
record_to_item(E#eldap_entry.attributes)
end, search(JID#jid.lserver, Data)).
end, search(ServerHost, Data)).
-define(FIELD(Var, Val),
{xmlelement, "field", [{"var", Var}],
@ -491,8 +495,8 @@ record_to_item(Attributes) ->
search(LServer, Data) ->
Filter = make_filter(Data),
Base = ejabberd_config:get_local_option(ldap_base),
UIDAttr = ejabberd_config:get_local_option(ldap_uidattr),
Base = ejabberd_config:get_local_option({ldap_base, LServer}),
UIDAttr = ejabberd_config:get_local_option({ldap_uidattr, LServer}),
case eldap:search("mod_vcard_ldap",[{base, Base},
{filter, Filter},
{attributes, []}]) of
@ -500,15 +504,17 @@ search(LServer, Data) ->
[X || X <- E,
ejabberd_auth:is_user_exists(
ldap_get_value(X, UIDAttr), LServer)];
_ ->
?ERROR_MSG("~p", ["Bad search"])
Err ->
?ERROR_MSG("Bad search: ~p", [[LServer, {base, Base},
{filter, Filter},
{attributes, []}]])
end.
make_filter(Data) ->
Filter = [X || X <- lists:map(fun(R) ->
make_assertion(R)
end,Data),
end, Data),
X /= none ],
case Filter of
[F] ->