Hello
I have a problem.
mod_share_roster_ldap v 0.4 return JIID instead of ldap_userdesk into shared roster.
module mod_share_roster_ldap v 0.3 works fine.
Conf:
ejabberd 2.1.3
mod_share_roster_ldap v 0.4
{mod_shared_roster_ldap,
[{ldap_groupattr,"company"},
{ldap_groupdesc,"company"},
{ldap_rfilter, "(&(memberOf=CN=JabberUsers, CN=Users, DC=xxxxxxx,DC=local))"},
{ldap_memberattr,"sAMAccountName"},
{ldap_userdesc,"description"}
]
What in there can be problem?
Most likely you just need to
Most likely you just need to add the following configuration parameter:
{ldap_useruid, "sAMAccountName"},
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".
From 0.4 on, the module instead looks for the user ID in attribute specified with ldap_useruid (which defaults to "cn").
Please report if this fixed the problem for you.
Unfortunately it doesn't
Unfortunately it doesn't work.
Current config
{mod_shared_roster_ldap,
[{ldap_groupattr,"company"},
{ldap_groupdesc,"company"},
{ldap_rfilter, "(&(memberOf=CN=JabberUsers, CN=Users, DC=xxxxxxx,DC=local))"},
{ldap_memberattr,"sAMAccountName"},
{ldap_userdesc,"description"},
{ldap_useruid, "sAMAccountName"}
]
When I delete parameter {ldap_memberattr,"sAMAccountName"}, the roster becomes empty.
re: Shared roster +AD+mod_shared_roster_ldap 0.4
Give your global "ldap_..." parameters
Do you change version of ejabberd ?
RE: Shared roster +AD+mod_shared_roster_ldap 0.4
Is your sAMAccountName's or cn's have uppercase letters ?
it seems 0.4 has problems with it
Yes, our format account -
Yes, our format account - SurnameFnLn@domain.local
(Fn - first letter of first name,Ln - first letter of patronymic)
How it is treated?
RE: Shared roster +AD+mod_shared_roster_ldap 0.4
Try this patch for msrl 0.4.0, it tested and works good with uppercase letters
or try latest msrl from git (not tested with uppercase letters)
From 9c820d4992a4cde8432d819a76148e41586a7fbb Mon Sep 17 00:00:00 2001
From: Denis Kurochkin <d.k.brazz@gmail.com>
Date: Mon, 22 Mar 2010 19:57:19 +0200
Subject: [PATCH] re-written get_user_name to increase performance
---
src/mod_shared_roster_ldap.erl | 45 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/src/mod_shared_roster_ldap.erl b/src/mod_shared_roster_ldap.erl
index 1ce1c44..16de5a9 100644
--- a/src/mod_shared_roster_ldap.erl
+++ b/src/mod_shared_roster_ldap.erl
@@ -167,10 +167,12 @@ get_user_roster(Items, US) ->
end, SRUsers, Items),
%% Export items in roster format:
+ Names = get_usernames_dict(S),
SRItems = [#roster{usj = {U, S, {U1, S1, ""}},
us = US,
jid = {U1, S1, ""},
- name = get_user_name(U1,S1),
+%% name = get_user_name(U1,S1),
+ name = get_user_name_from_dict(U1,Names),
subscription = both,
ask = none,
groups = GroupNames} ||
@@ -271,6 +273,9 @@ get_user_displayed_groups({User, Host}) ->
get_user_name(User, Host) ->
make_request(Host, {get_user_name, User}, []).
+get_usernames_dict(Host) ->
+ make_request(Host, {get_usernames_dict}, []).
+
%%%-----------------------
%%% Internal functions.
@@ -384,6 +389,38 @@ handle_call({get_user_name, User}, _From, State) ->
end,
{reply, Reply, NewState};
+handle_call({get_usernames_dict}, _From, State) ->
+ UserDescAttr = State#state.user_desc,
+ UserUIDAttr = State#state.user_uid,
+ Now = now_seconds(),
+ % If necessary, retrieve descriptions and identifiers for all users, and
+ % cache them in State.
+ NewState = case mod_shared_roster_ldap_helpers:users_cache_fresh(State, Now) of
+ fresh -> State;
+ stale ->
+ % TODO: since eldap_search never reports errors, a potentially
+ % broken result may be cached and propagated to clients for up to
+ % State#state.user_cache_validity seconds.
+ Retrieved = mod_shared_roster_ldap_helpers:eldap_search(State,
+ [eldap_filter:do_sub(State#state.ufilter, [{"%u", "*"}])],
+ [UserDescAttr, UserUIDAttr]),
+ State#state{cached_users = Retrieved, cached_users_timestamp = Now}
+ end,
+ % Find entries about User among all cached Entries.
+ Entries = NewState#state.cached_users,
+ NamesDict = lists:foldl(
+ fun(#eldap_entry{attributes=Attrs},Dict) ->
+ case {eldap_utils:get_ldap_attr(UserUIDAttr,Attrs),
+ eldap_utils:get_ldap_attr(UserDescAttr,Attrs)}
+ of
+ {UserUID, UserDesc} -> dict:append(string:to_lower(UserUID), UserDesc, Dict);
+ _ -> Dict
+ end
+ end,
+ dict:new(),
+ Entries),
+ {reply, NamesDict, NewState};
+
handle_call(stop, _From, State) ->
{stop, normal, ok, State};
@@ -578,6 +615,12 @@ make_request(Host, Request, Fallback) ->
Result
end.
+get_user_name_from_dict(User, Names) ->
+ case dict:find(User,Names) of
+ {ok, Name} -> Name;
+ _ -> User
+ end.
+
%%%-----------------------
%%% Unit tests.
%%%
--
1.5.6.5
Thanks for your help. However
Thanks for your help.
However the problem remained.
I gоt a source here
I copy Your patch to file 1.diff
cat > 1diff
I apply the patch to file mod_shared_roster_ldap.erl
patch mod_shared_roster_ldap.erl<1.diff
and get output
patching file mod_shared_roster_ldap.erl
Hunk #1 FAILED at 167.
patch: **** malformed patch at line 29: get_user_name(User, Host) ->
I manually apply the patch to file mod_shared_roster_ldap.erl.
It is compiled but the roster remains empty.
Where I can find your source file?
P.S. I apologise for my English.
Mixed-case username treatment fixed in 0.5.1
Hello,
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.