ejabberd - Comments for "Readonly VCard" https://www.ejabberd.im/forum/28773/readonly-vcard en Wow - thank you :-) I didn't https://www.ejabberd.im/forum/28773/readonly-vcard#comment-67461 <p>Wow - thank you :-) I didn't realise it was only in the patch.</p> <p>I will give it a try. If it doesn't work i will figure it out and put the code somewhere.</p> <p>thanks again,<br /> steven</p> Tue, 16 May 2017 07:23:49 +0000 stevenlivz comment 67461 at https://www.ejabberd.im Oh, I guess that https://www.ejabberd.im/forum/28773/readonly-vcard#comment-67459 <p>Oh, I guess that documentation refers to a feature implemented only in this patch:<br /> <noindex><a href="https://support.process-one.net/browse/EJAB-797" title="https://support.process-one.net/browse/EJAB-797" rel="nofollow" >https://support.process-one.net/browse/EJAB-797</a></noindex></p> <p>And this patch was not included in ejabberd. In case you are interested, I've updated the patch to work with ejabberd git master. I don't know if it will work with ejabberd 17.04:</p> <pre> From 9a63873c2b31540fe30c80e3fe28f2488a0fad7e Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 15 May 2017 17:42:29 +0200 Subject: [PATCH] New options access_get and access_set in mod_vcard, _ldap and _odbc (EJAB-797) # Conflicts: # src/mod_vcard.erl # src/mod_vcard_ldap.erl --- src/mod_vcard.erl | 28 +++++++++++++++++++--------- src/mod_vcard_ldap.erl | 12 ++++++++++++ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/mod_vcard.erl b/src/mod_vcard.erl index 00fd4bb..d813b55 100644 --- a/src/mod_vcard.erl +++ b/src/mod_vcard.erl @@ -203,7 +203,10 @@ process_local_iq(#iq{type = get, lang = Lang} = IQ) -&gt; process_sm_iq(#iq{type = set, lang = Lang, from = From, sub_els = [SubEl]} = IQ) -&gt; #jid{user = User, lserver = LServer} = From, - case lists:member(LServer, ?MYHOSTS) of + Access = gen_mod:get_module_opt(LServer, ?MODULE, access_set, + fun(A) when is_atom(A) -&gt; A end, all), + case lists:member(LServer, ?MYHOSTS) andalso + (acl:match_rule(LServer, Access, From) == allow) of true -&gt; set_vcard(User, LServer, SubEl), xmpp:make_iq_result(IQ); @@ -213,14 +216,21 @@ process_sm_iq(#iq{type = set, lang = Lang, from = From, end; process_sm_iq(#iq{type = get, from = From, to = To, lang = Lang} = IQ) -&gt; #jid{luser = LUser, lserver = LServer} = To, - case get_vcard(LUser, LServer) of - error -&gt; - Txt = &lt;&lt;"Database failure"&gt;&gt;, - xmpp:make_error(IQ, xmpp:err_internal_server_error(Txt, Lang)); - [] -&gt; - xmpp:make_iq_result(IQ, #vcard_temp{}); - Els -&gt; - IQ#iq{type = result, to = From, from = To, sub_els = Els} + Access = gen_mod:get_module_opt(LServer, ?MODULE, access_get, + fun(A) when is_atom(A) -&gt; A end, all), + case acl:match_rule(LServer, Access, From) of + allow -&gt; + case get_vcard(LUser, LServer) of + error -&gt; + Txt = &lt;&lt;"Database failure"&gt;&gt;, + xmpp:make_error(IQ, xmpp:err_internal_server_error(Txt, Lang)); + [] -&gt; + xmpp:make_iq_result(IQ, #vcard_temp{}); + Els -&gt; + IQ#iq{type = result, to = From, from = To, sub_els = Els} + end; + deny -&gt; + xmpp:make_error(IQ, xmpp:err_not_allowed()) end. -spec process_vcard(iq()) -&gt; iq(). diff --git a/src/mod_vcard_ldap.erl b/src/mod_vcard_ldap.erl index fe11d09..4e54652 100644 --- a/src/mod_vcard_ldap.erl +++ b/src/mod_vcard_ldap.erl @@ -91,6 +91,18 @@ is_search_supported(_LServer) -&gt; true. get_vcard(LUser, LServer) -&gt; + Access = gen_mod:get_module_opt(LServer, ?MODULE, access_get, + fun(A) when is_atom(A) -&gt; A end, all), + From = jid:make(LUser, LServer), + case ejabberd_auth:is_user_exists(LUser, LServer) andalso + (acl:match_rule(LServer, Access, From) == allow) of + true -&gt; + get_vcard2(LUser, LServer); + _ -&gt; + xmpp:make_error(#iq{}, xmpp:err_not_allowed()) + end. + +get_vcard2(LUser, LServer) -&gt; {ok, State} = eldap_utils:get_state(LServer, ?PROCNAME), VCardMap = State#state.vcard_map, case find_ldap_user(LUser, State) of -- 2.7.4 </pre> Mon, 15 May 2017 15:49:15 +0000 badlop comment 67459 at https://www.ejabberd.im Hi - it's in the ejabberd https://www.ejabberd.im/forum/28773/readonly-vcard#comment-67458 <p>Hi - it's in the ejabberd configuration documentation:</p> <p><a href="https://docs.ejabberd.im/admin/configuration/#mod-admin-extra" title="https://docs.ejabberd.im/admin/configuration/#mod-admin-extra">https://docs.ejabberd.im/admin/configuration/#mod-admin-extra</a></p> Mon, 15 May 2017 12:29:47 +0000 stevenlivz comment 67458 at https://www.ejabberd.im I think such thing is not https://www.ejabberd.im/forum/28773/readonly-vcard#comment-67455 <p>I think such thing is not possible. Where did you read about that "access_set" option? I can't find it in the ejabberd source code.</p> Mon, 15 May 2017 09:29:20 +0000 badlop comment 67455 at https://www.ejabberd.im