8

As an occupant/member, I need to know all the "members" in the room with ejabberd-14.x

I followed http://xmpp.org/extensions/xep-0045.html#getmemberlist

I got forbidden (401) for following stanze - Admin privilege required

<iq from='crone1@shakespeare.lit/desktop'
    id='member3'
    to='coven@chat.shakespeare.lit'
    type='get'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='member'/>
  </query>
</iq>

If I change

<query xmlns='http://jabber.org/protocol/muc#admin'> 

from admin to user namespace, then I get status code 501 - Feature not implemented

Would you know how can I get members of a room as an occupant or member?

I am not an admin/moderator in this use case.

XEP-0045 does say:

Note: A service SHOULD also return the member list to any occupant in a members-only room; i.e., it SHOULD NOT generate a error when a member in the room requests the member list. This functionality can assist clients in showing all the existing members even if some of them are not in the room, e.g. to help a member determine if another user should be invited. A service SHOULD also allow any member to retrieve the member list even if not yet an occupant.

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
GJain
  • 5,025
  • 6
  • 48
  • 82

1 Answers1

1

You need to be at least a member yourself to access the affiliation list. It doesn't matter whether or not you are currently an occupant (ie. in the room).

Note that an affiliation (such as "member") is a persistent setting that needs to be explicitly given to people, who default to "none" otherwise. In a normal unrestricted room, this setting doesn't have any other effect than allowing you to retrieve the member list. The member list is unrelated to the occupant list.

(If you merely want to know who is currently in the room, you should send a query with the namespace http://jabber.org/protocol/disco#items instead of muc#admin.)

Example (just tried on my ejabberd server). Attempting to query the list with an unaffiliated account:

<iq from='crone1@shakespeare.lit/desktop'
    id='member3'
    to='coven@chat.shakespeare.lit'
    type='get'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='member'/>
  </query>
</iq>
<iq from='coven@chat.shakespeare.lit'
    to='crone1@shakespeare.lit/desktop'
    type='error'
    id='member3'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='member'/>
  </query>
  <error code='403' type='auth'>
    <forbidden/>
    <text>Administrator privileges required</text>
  </error>
</iq>

Using a privileged (room owner) account to grant that first account member privileges:

<iq from='admin@shakespeare.lit/desktop'
    type='set'
    to='coven@chat.shakespeare.lit'
    id='member4'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item jid='crone1@shakespeare.lit' affiliation='member'/>
  </query>
</iq>

<iq to='admin@shakespeare.lit/desktop'
    from='coven@chat.shakespeare.lit'
    type='result' id='member4'/>

Trying again:

<iq from='crone1@shakespeare.lit/desktop' 
    type='get'
    to='coven@chat.shakespeare.lit'
    id='member5'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='member'/>
  </query>
</iq>

<iq to='crone1@shakespeare.lit/desktop'
    from='coven@chat.shakespeare.lit'
    type='result'
    id='member5'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item jid='crone1@shakespeare.lit' affiliation='member'/>
  </query>
</iq>
Christoph Burschka
  • 4,467
  • 3
  • 16
  • 31