Search code examples
ejabberdsmackejabberd-api

How to register In-band user in particular Virtual Host in Ejabberd with Smack Client?


I am using Smack client 4.3.1 and want to register user using in-band registration method (using Smack's AccountManager).

I could create new user with "admin" XMPP connection and users are created in a domain where admin user is there say [email protected]

My requirement is, i want to create user in another virtual host - say [email protected] using same "admin" XMPP connection. is it possible ?

I tried "in band registration" with user "[email protected]" which has admin privilege. it is giving "XMPPError: conflict - cancel " error

My code is :

    AccountManager accountManager = AccountManager.getInstance(connection1);
    System.out.println("Is Account creation supported " +accountManager.isSupported() + " Account creation supported : " + accountManager.supportsAccountCreation());
    accountManager.sensitiveOperationOverInsecureConnection(true);

    EntityFullJid entityFullJid = JidCreate.entityFullFrom("[email protected]/resource1");

    Domainpart domainpart = entityFullJid.getDomain();

    Localpart localpart = entityFullJid.getLocalpart();

    System.out.println("local part of account " + localpart);

    accountManager.createAccount(localpart, "password");

is it possible to create user1 in example.com using in-band registration ?

my admin users

  admin:
    user:
      - "admin": "ec2-xxxxx.us-west-2.compute.amazonaws.com"
      - "mnallath1": "example.com"

my virtual hosts

hosts:
  - "ec2-xxxxx.us-west-2.compute.amazonaws.com"
  - "example.com"
  - "example.net"

Solution

  • Looking at the source code, it is now allowed to register new accounts using IBR from another vhost, even if done using an admin account.

    The function check_from returns deny because the account used does not belong to the vhost where the registration is attempted: https://github.com/processone/ejabberd/blob/master/src/mod_register.erl#L260