Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
elica2099 #1
Member since Jan 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: Know if a user (jid) is authorized to enter in a room
Hi,

i use openfire 3.9.1.
I need to know if an user is a member of a room. There is some function that tell me if the user (jid) is authorized to enter a room?

The goal is to get list the rooms in the system discovered with the code below but with the information if the user is allowed to enter or not the room and display it on the list

  1. string srv = "conference." + ChatServer;
  2. DiscoManager dm = new DiscoManager(xmppClient);
  3. dm.DiscoverItems(srv, currentJID, new EventHandler<IqEventArgs>(DiscoItemsResult));
  4.  
  5. var query = e.Iq.Element<Matrix.Xmpp.Disco.Items>();
  6. if (query != null)
  7. {
  8.     foreach (var itm in query.GetItems())
  9.     {
  10.         System.Diagnostics.Debug.WriteLine(itm.Jid);
  11.  
  12.         Contacts.AddGroup(itm);
  13.     }
  14. }

Thank you

Maurizio Binello
This post was edited on 2016-01-26, 19:04 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

what you do so far is correct.

The DiscoverItems on the chat server gives you all rooms.
Then you can again call DiscoverItems on each room and it should give you all participants of a room.

You can also call DiscoverInformation on every item to get more details.

But I don't think that your server will give you the information you are looking for with Disco. But should be able to see this in the Xml results.

Usually you have to join the room as an admin and request the Memberlist using the MucManager.

Alex
Avatar
elica2099 #3
Member since Jan 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex,

very thanks for your quick reply :-)

What i need to know is that the user, the actual connected user, is a member of a room to inibite the access. If he is not in the list he cannot partecipate.

So if i understand well i can do a DiscoverItems on the room, get the list of the members and check i the user is in the list. If not, he don't have the access.

Can you give me some line of code or some tips?

Thanks

Maurizio
Avatar
Alex #4
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
DiscoverItems on a room returns you all people which are currently present in the room.
But it does not tell you who else has permissions to join the room.

Please see also the documentation here:
http://www.xmpp.org/extensions/xep-0045.html

Alex
Avatar
elica2099 #5
Member since Jan 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
Ah, ok.

So how can i know if the connecter user is allowed to enter the room (if the room are members only)?

There any kind of function or check or parameters to do so? or to get the full list of allowed users in the room.

Maurizio
Avatar
elica2099 #6
Member since Jan 2016 · 4 posts
Group memberships: Members
Show profile · Link to this post
i ckeck the documentation and the case basically is: chek if a user is "affiliated" to a members only room.

The member affiliation provides a way for a room owner or admin to specify a "whitelist" of users who are allowed to enter a members-only room. When a member enters a members-only room, his or her affiliation does not change, no matter what his or her role is.

what i need is to get that whitelist of people affiliated and check for the current user.

Another way is to enter the room and get the "Service Denies Access Because User Is Not on Member List" in the returning xml.
Where i can get the returning xml in the mucManager?

Maurizio
This post was edited on 2016-01-27, 13:18 by Alex.
Avatar
Alex #7
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by elica2099:
what i need is to get that whitelist of people affiliated and check for the current user.

This is defined here:
http://www.xmpp.org/extensions/xep-0045.html#modifymember

In the MucManager there is a function RequestMemberList.
By default only admins can execute this. But your server may allow you to open this also for participants. Then a user itself could query it and see if he is a member and allowed to join.

Quote by elica2099:
Another way is to enter the room and get the "Service Denies Access Because User Is Not on Member List" in the returning xml.
Where i can get the returning xml in the mucManager?

Yes, just try to join the room, the error should return in the OnPresence event.
See also:
http://www.xmpp.org/extensions/xep-0045.html#enter

If you are on the latest .NET version you could also use the async/await stuff in the MucManager.

  1. var presRes = await mm.EnterRoom("'dev@conference.ag-software.net", "Alex");

see also:
http://www.ag-software.net/2014/01/21/task-based-asynchron…

Please consult also the documentation of your server. MUC is a huge extension, not every server implements every part if it. Also many servers returns additional disco nodes for discovering more information about the room.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS