1
votes

I have a use case, in which as an admin user in ejabberd, I should be able to edit rosters for all other users. I am using smack library to connect to the ejabberd server using TCP connection.

Reading the documentation of ejabberd 14.07 here is the what it says under mod_roster:

managers List of remote entities that can manage users rosters using Remote Roster Management (XEP-0321). The protocol sections implemented are: 4.2. The remote entity requests current user’s roster. 4.3. The user updates roster. 4.4. The remote entity updates the user’s roster. A remote entity cab only get or modify roster items that have the same domain as the entity. Default value is: []. This example configuration enables Roster Versioning with storage of current id. The ICQ and MSN transports can get ICQ and MSN contacts, add them, or remove them for any local account:

I made the config changes in ejabberd and sent the following packets :

<iq id='PCe38-23' to='%[email protected]/Smack' type='set'>
          <query xmlns='jabber:iq:roster'>
            <item jid='%[email protected]/Smack'
                  name='Siddharth Banerjee'
                  subscription='both'>
            </item>
          </query>
            </iq>

<iq id='PCe38-24' to='%[email protected]/Smack' type='set'>
          <query xmlns='jabber:iq:roster'>
            <item jid='%[email protected]/Smack'
                  name='deco'
                  subscription='both'>
            </item>
          </query>
            </iq>

But I am getting the following :

<iq from='%[email protected]/Smack' to='[email protected]/75250b26-a52a-4e1d-a5fb-4b263cd2f451' type='error' id='PCe38-23'>
          <query xmlns='jabber:iq:roster'>
            <item jid='%[email protected]/Smack' name='Siddharth Banerjee' subscription='both'>
            </item>
          </query>
            <error code='503' type='cancel'><service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>

How do I modify another user's roster using smack ?

Please advise.

2

2 Answers

0
votes

I think you misunderstand the purpose of XEP-0321. It is mainly to allow gateways to manipulate the relevant part of the user roster. For example, a gateway for ICQ running on the server can manipulate the roster entry for a user (after authorization) for that subset only (i.e. @icq.domain.net roster entries, not @domain.net).

This is NOT a generic specification for manipulating the whole user roster.

For what I read in your post, you use always the same domain, so I guess you are trying to get access and manipulate user roster from another user. It cannot work, as per XEP-0321.

0
votes

https://blog.process-one.net/roster_versioning_support_for_ejabberd/

This example configuration enables Roster Versioning with storage of current id. The ICQ and MSN transports can get ICQ and MSN contacts, add them, or remove them for any local account:

modules:
  ...
  mod_roster:
    versioning: true
    store_current_id: true
    managers:
     - "icq.example.org"
     - "msn.example.org"
  ...

With this example configuration, only admins can manage their rosters; everybody else cannot modify the roster:

acl: admin: user: - "sarah": "example.org" access: roster: admin: allow

modules: ... mod_roster: access: roster