5

I'm trying to create new user via admin account. But I receive auth error. I tried answers like this, but it doesn't help.

My code for creating new user:

AccountManager accountManager = AccountManager.getInstance(mConnection);

        if (accountManager.supportsAccountCreation()) {
            try {
                accountManager.createAccount(username, password);
            }

            catch (XMPPException ex) {
                LOG.info(ex.getMessage(), ex);
            }

        }
        else{
            LOG.error("Server doesn't support creating new accounts");
        }

And I allow registration for ALL in config:

{access, register, [{allow, all}]}.

{access, register_from, [{allow, all}]}.

{mod_register, [
 ...
 {ip_access, [{allow, "127.0.0.0/8"},
              {deny, "0.0.0.0/0"}]},
 {access_from, register_from},
 {access, register}
]},

And even with this config i have error:

org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: forbidden - auth
    at org.jivesoftware.smack.XMPPException$XMPPErrorException.ifHasErrorThenThrow(XMPPException.java:135)
    at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:232)
    at org.jivesoftware.smack.PacketCollector.nextResultOrThrow(PacketCollector.java:213)
    at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:272)
    at org.jivesoftware.smackx.iqregister.AccountManager.createAccount(AccountManager.java:244)

P.S. Smack 4.1.0

Community
  • 1
  • 1
  • Are you sure you're ok with `{ip_access, [{allow, "127.0.0.0/8"}, {deny, "0.0.0.0/0"}]}`, i.e. are you connecting from the local host? – erszcz May 13 '15 at 09:46
  • @erszcz oh, forgot about this. Added my ip in allow list -> now it works. Thanks, mate. – Suvitruf - Andrei Apanasik May 13 '15 at 09:54
  • @erszcz but it works only with [{allow, all}], with [{allow, admin}] I receive same error =/ – Suvitruf - Andrei Apanasik May 13 '15 at 09:56
  • 1
    I'm not sure about the context of your code snippet, but maybe the user is not authenticated as an admin? Basically, this mechanism is used to register an account for yourself, i.e. an anonymous user connects to the server, registers an account for himself/herself and (then possibly reconnects and) authenticates using the new account. If you want to have stricter control over account creation use the command line `mongooseimctl` or a custom authentication module. – erszcz May 13 '15 at 11:55
  • @erszcz yeh, mb custom auth module - is best choice. – Suvitruf - Andrei Apanasik May 13 '15 at 12:08

1 Answers1

2

Solution:

step1:

enter image description here

step2:

enter image description here

step3:

enter image description here

after doing all these three steps run your program u will be able to register a new user on ejabberd server.

singh.indolia
  • 1,292
  • 13
  • 26