Adding new users to a group

Hi All,

Does anybody know how to add a new user to a group? I can do this in the portal but the Smack api doesn’t seem to provide this. Am I missing something obvious? Any help is much appreciated.

Thanks in advanced!

Hi All,

I finally had some free time to revisit the issue in detail and I have figured a way to add users to existing groups. Hopefully this post will help other new users to the smack library seeing that the original post was viewed over 737 times. Note, my settings are Openfire 3.6.4 and Smack 3.1.0.

  1. The first thing new users should do is query the system for supported commands. This is done through the AdHocCommandManager api.
  • Use AdHocCommandManager:discoverCommands(String jid). This returns the default list of supported commands for the connected XMPP server.
  • If you iterate over the returned Item objects you should get something similar


  1. Get the remote command.
  1. From the RemoteCommand object, execute the command. This determines if we need to fill out any information for the command to complete.
  • RemoteCommand:execute();
  • Executing the command shows the following required fields needs to be populated to complete the command.

  • 0
  1. To complete the command we need to updated the fields from the Form

object. The DataForm can be retrieved from the RemoteCommand:getForm() method.

  • You can get the fields from the Form:getFields() method.
  • From the FormField object, use the addValue(String) or addValues(List) call to set the values.
  1. Complete the command with the updated form
  • Use RemoteCommand:execute(Form) where the passed form contains the updated field values.
  1. You can check the status of the command through the RemoteCommand:getStatus() method