Problems with using LastActivityManager : Getting Forbidden (403) error


I’m trying to use the LastActivityManager.getLastActivity to try to find out if a particular user is online or offline. I’ve looked around on how to use my Admin account to get Presence status (Online, Offline, etc) of any arbitrary user in the system but without them being on the admin’s Roster. If getLastActivity works, i can determine if a user’s online by checking if activity.lastActivity == 0.

At least that’s the plan, but I’m not able to get this working.

I’m using the code similar to below:

ConnectionConfiguration connectConfig = new ConnectionConfiguration(“localhost”, 5222, “MyTestDomain”);

XMPPConnection connection = new XMPPConnection(connectConfig);

connection .connect();

connection .login(“Admin”, “MyAdminPassword”);

LastActivity activity = LastActivityManager.getLastActivity(connection, );

The admin login succeeds but when I make the getLastActivityCall, I get an XMPPException with a “forbidden(403)” message

I’ve tried this on OpenFire and Jabber2 and I get same failure messages on both side.

Is there something that I’m doing wrong or do I need some specific server config to enable the LastActivityManager functionality.

Anyone know of an alternative to getting Presenece info for users not in your roster. Basically I’m looking for something similar to

admin#get-online-users that is defined in Service Adminstration extension XEP-0133


You can’t do what you want with just Smack out of the box. By default you can only get the presence of a user if they are on your roster. There are other things you can do though to achieve what you want. Somehow Clearspace, Jive’s other product, is able to retrieve the presence of all users from Openfire. It uses a different mechanism like ad-hoc commands or a server component or something, that you might be able to use in a similar way. So I would start by figuring out how that was implemented. Another option is that you could create a very simple Openfire plugin that automatically adds each user to the roster of one or more administrator users. I don’t think it would be difficult, but it would be specific to Openfire obviously.


Hey Scyrb222,

The forbidden(403) error that you are getting when using LastActivityManager means that the user requesting the information about the other user is not in the roster. That means that users should approve a presence subscription so that you can get the last activity of the user.

Maybe another option for you could be the Presence Service.


– Gato