ejabberd - Comments for "Shared roster +AD+mod_shared_roster_ldap 0.4" https://www.ejabberd.im/node/3973 en Mixed-case username treatment fixed in 0.5.1 https://www.ejabberd.im/node/3973#comment-55720 <p>Hello,<br /> It looks like it was not possible to have the module use ``display names'' for users whose usernames were not all lower case. This is fixed in release 0.5.1.</p> Sat, 08 May 2010 12:32:12 +0000 porridge comment 55720 at https://www.ejabberd.im Thanks for your help. However https://www.ejabberd.im/node/3973#comment-55646 <p>Thanks for your help.<br /> However the problem remained.</p> <p>I gоt a source <noindex><a href="https://alioth.debian.org/frs/download.php/3253/mod_shared_roster_ldap-0.4.0.tgz" rel="nofollow" > here </a></noindex><br /> I copy Your patch to file 1.diff</p> <div class="codeblock"><code>cat &gt; 1diff</code></div> <p>I apply the patch to file mod_shared_roster_ldap.erl</p> <div class="codeblock"><code> <br />patch mod_shared_roster_ldap.erl&lt;1.diff</code></div> <p>and get output</p> <div class="codeblock"><code> <br />patching file mod_shared_roster_ldap.erl<br />Hunk #1 FAILED at 167.<br />patch: **** malformed patch at line 29: get_user_name(User, Host) -&gt;</code></div> <p>I manually apply the patch to file mod_shared_roster_ldap.erl.<br /> It is compiled but the roster remains empty.<br /> Where I can find your source file?</p> <p>P.S. I apologise for my English.</p> Tue, 27 Apr 2010 13:23:47 +0000 freebeer comment 55646 at https://www.ejabberd.im RE: Shared roster +AD+mod_shared_roster_ldap 0.4 https://www.ejabberd.im/node/3973#comment-55532 <p>Try this patch for msrl 0.4.0, it tested and works good with uppercase letters<br /> or try latest msrl from git (not tested with uppercase letters)</p> <div class="codeblock"><code>From 9c820d4992a4cde8432d819a76148e41586a7fbb Mon Sep 17 00:00:00 2001<br />From: Denis Kurochkin &lt;d.k.brazz@gmail.com&gt;<br />Date: Mon, 22 Mar 2010 19:57:19 +0200<br />Subject: [PATCH] re-written get_user_name to increase performance <p>---<br /> src/mod_shared_roster_ldap.erl |&nbsp;&nbsp; 45 +++++++++++++++++++++++++++++++++++++++-<br /> 1 files changed, 44 insertions(+), 1 deletions(-)</p> <p>diff --git a/src/mod_shared_roster_ldap.erl b/src/mod_shared_roster_ldap.erl<br />index 1ce1c44..16de5a9 100644<br />--- a/src/mod_shared_roster_ldap.erl<br />+++ b/src/mod_shared_roster_ldap.erl<br />@@ -167,10 +167,12 @@ get_user_roster(Items, US) -&gt;<br /> &nbsp; end, SRUsers, Items),</p> <p>&nbsp;&nbsp;&nbsp;&nbsp; %% Export items in roster format:<br />+&nbsp;&nbsp;&nbsp; Names = get_usernames_dict(S),<br />&nbsp;&nbsp;&nbsp;&nbsp; SRItems = [#roster{usj = {U, S, {U1, S1, &quot;&quot;}},<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; us = US,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jid = {U1, S1, &quot;&quot;},<br />- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name = get_user_name(U1,S1),<br />+%% &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name = get_user_name(U1,S1),<br />+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name = get_user_name_from_dict(U1,Names),<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subscription = both,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ask = none,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; groups = GroupNames} ||<br />@@ -271,6 +273,9 @@ get_user_displayed_groups({User, Host}) -&gt;<br /> get_user_name(User, Host) -&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp; make_request(Host, {get_user_name, User}, []).</p> <p>+get_usernames_dict(Host) -&gt;<br />+&nbsp;&nbsp;&nbsp; make_request(Host, {get_usernames_dict}, []).<br />+</p> <p> %%%-----------------------<br /> %%% Internal functions.<br />@@ -384,6 +389,38 @@ handle_call({get_user_name, User}, _From, State) -&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp; end,<br />&nbsp;&nbsp;&nbsp;&nbsp; {reply, Reply, NewState};</p> <p>+handle_call({get_usernames_dict}, _From, State) -&gt;<br />+&nbsp;&nbsp;&nbsp; UserDescAttr = State#state.user_desc,<br />+&nbsp;&nbsp;&nbsp; UserUIDAttr = State#state.user_uid,<br />+&nbsp;&nbsp;&nbsp; Now = now_seconds(),<br />+&nbsp;&nbsp;&nbsp; % If necessary, retrieve descriptions and identifiers for all users, and<br />+&nbsp;&nbsp;&nbsp; % cache them in State.<br />+&nbsp;&nbsp;&nbsp; NewState = case mod_shared_roster_ldap_helpers:users_cache_fresh(State, Now) of<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fresh -&gt; State;<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stale -&gt;<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; % TODO: since eldap_search never reports errors, a potentially<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; % broken result may be cached and propagated to clients for up to<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; % State#state.user_cache_validity seconds.<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Retrieved = mod_shared_roster_ldap_helpers:eldap_search(State,<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [eldap_filter:do_sub(State#state.ufilter, [{&quot;%u&quot;, &quot;*&quot;}])],<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [UserDescAttr, UserUIDAttr]),<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; State#state{cached_users = Retrieved, cached_users_timestamp = Now}<br />+&nbsp;&nbsp;&nbsp; end,<br />+&nbsp;&nbsp;&nbsp; % Find entries about User among all cached Entries.<br />+&nbsp;&nbsp;&nbsp; Entries = NewState#state.cached_users,<br />+&nbsp;&nbsp;&nbsp; NamesDict = lists:foldl(<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fun(#eldap_entry{attributes=Attrs},Dict) -&gt;<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case {eldap_utils:get_ldap_attr(UserUIDAttr,Attrs),<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eldap_utils:get_ldap_attr(UserDescAttr,Attrs)}<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; of<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {UserUID, UserDesc} -&gt; dict:append(string:to_lower(UserUID), UserDesc, Dict);<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _ -&gt; Dict<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end,<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dict:new(),<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Entries),<br />+&nbsp;&nbsp;&nbsp; {reply, NamesDict, NewState};<br />+<br /> handle_call(stop, _From, State) -&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp; {stop, normal, ok, State};</p> <p>@@ -578,6 +615,12 @@ make_request(Host, Request, Fallback) -&gt;<br /> &nbsp;&nbsp;&nbsp; Result<br />&nbsp;&nbsp;&nbsp;&nbsp; end.</p> <p>+get_user_name_from_dict(User, Names) -&gt;<br />+&nbsp;&nbsp;&nbsp; case dict:find(User,Names) of<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {ok, Name} -&gt; Name;<br />+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _ -&gt; User<br />+&nbsp;&nbsp;&nbsp; end.<br />+<br /> %%%-----------------------<br /> %%% Unit tests.<br /> %%%<br />-- <br />1.5.6.5</p></code></div> Fri, 09 Apr 2010 14:51:59 +0000 d.k.brazz comment 55532 at https://www.ejabberd.im Yes, our format account - https://www.ejabberd.im/node/3973#comment-55527 <p>Yes, our format account - SurnameFnLn@domain.local<br /> (Fn - first letter of first name,Ln - first letter of patronymic)</p> <p>How it is treated?</p> Fri, 09 Apr 2010 10:02:23 +0000 freebeer comment 55527 at https://www.ejabberd.im RE: Shared roster +AD+mod_shared_roster_ldap 0.4 https://www.ejabberd.im/node/3973#comment-55526 <p>Is your sAMAccountName's or cn's have uppercase letters ?<br /> it seems 0.4 has problems with it</p> Fri, 09 Apr 2010 08:57:47 +0000 d.k.brazz comment 55526 at https://www.ejabberd.im re: Shared roster +AD+mod_shared_roster_ldap 0.4 https://www.ejabberd.im/node/3973#comment-55525 <p>Give your global "ldap_..." parameters<br /> Do you change version of ejabberd ?</p> Fri, 09 Apr 2010 08:52:34 +0000 d.k.brazz comment 55525 at https://www.ejabberd.im Unfortunately it doesn't https://www.ejabberd.im/node/3973#comment-55522 <p>Unfortunately it doesn't work.</p> <p>Current config</p> <div class="codeblock"><code>{mod_shared_roster_ldap,<br />&nbsp;&nbsp; [{ldap_groupattr,&quot;company&quot;},<br />&nbsp;&nbsp;&nbsp; {ldap_groupdesc,&quot;company&quot;},<br />&nbsp;&nbsp;&nbsp; {ldap_rfilter, &quot;(&amp;(memberOf=CN=JabberUsers, CN=Users, DC=xxxxxxx,DC=local))&quot;},<br />&nbsp;&nbsp;&nbsp; {ldap_memberattr,&quot;sAMAccountName&quot;},<br />&nbsp;&nbsp;&nbsp; {ldap_userdesc,&quot;description&quot;},<br />&nbsp;&nbsp;&nbsp; {ldap_useruid, &quot;sAMAccountName&quot;}<br />]</code></div> <p>When I delete parameter {ldap_memberattr,"sAMAccountName"}, the roster becomes empty.</p> Thu, 08 Apr 2010 13:54:36 +0000 freebeer comment 55522 at https://www.ejabberd.im Most likely you just need to https://www.ejabberd.im/node/3973#comment-55491 <p>Most likely you just need to add the following configuration parameter:</p> <p>{ldap_useruid, "sAMAccountName"},</p> <p>This is because in 0.3.1 and previous versions the user description is located by looking for the user ID in attribute specified with ldap_memberattr - in your case: "sAMAccountName".</p> <p>From 0.4 on, the module instead looks for the user ID in attribute specified with ldap_useruid (which defaults to "cn").</p> <p>Please report if this fixed the problem for you.</p> Fri, 02 Apr 2010 15:35:00 +0000 porridge comment 55491 at https://www.ejabberd.im