Creating new account - conflict (409)?

Hi,

I am currently using smack and I’m trying to create an account. The problem is that i get this conflict 409 error message . I don’t really know what this means. Can anyone help me figure this out?

Hi again,

I figured it out

Hi Kelly

I am facing some problem. Pls let me know what the issue was

It means the information your using to submit the registering isn’t all you need.

Or the accountname is already in use.

Try this code:

public void registerAccountsAtServer(String username, String password) {
System.out.println(“Registering account " + username + " at server”);
Registration register = new Registration();
ArrayList fieldListFields = new ArrayList();
PacketCollector iqCollector;

iqCollector = connection.createPacketCollector(new PacketTypeFilter(IQ.class));

    ArrayList fieldListNames = new ArrayList();

register.setType(IQ.Type.SET);
register.setTo(“SERVERNAME”);

Hashtable map = new Hashtable();

// set up the various attributes to be sent to the server

map.put(“username”, username);
map.put(“password”, password);
map.put(“email”, username + "@bot.nl");
map.put(“name”, username);

// send the packet
register.setAttributes(map);
PacketFilter filter = new AndFilter(new PacketIDFilter(register.getPacketID()), new PacketTypeFilter(IQ.class));

PacketCollector collector = connection.createPacketCollector(filter);
this.connection.sendPacket(register);

//Packet response = iqCollector.nextResult();
IQ response = (IQ) collector.nextResult(1000);

    if (response instanceof Registration) {
        if (response.getType() == IQ.Type.ERROR) {
            if (response.getError().toString().contains("409")) {
                System.out.println("Cannot register, user information already exists (error confict 409)");
            } else {
                System.out.println("Registration error! unknown error " + response.getError().getMessage());
            }
        } else if (response.getType() == IQ.Type.RESULT) {
            System.out.println("Registration result RESULT");
        } else if (response.getType() == IQ.Type.SET) {
            System.out.println("Registration result SET");
        }
    }
}

Job,

I have the same problem with “conflict (409)”.

I tried your code. The response from server is the same - 409.

The problem that I have restricted new user registration to admin role.
So I need to authenticate as admin user and than create a new account

If there is no restriction on the serever I can register!

My Code:

XMPPConnection connection = new XMPPConnection(configuration);
try {
SASLAuthentication.supportSASLMechanism(“PLAIN”, 0);

connection.connect();

connection.login(ADMIN_LOGIN, ADMIN_PASS);

AccountManager accountManager = connection.getAccountManager();

accountManager.createAccount(username, password);

} finally {
connection.disconnect();
}

When I removed line

connection.login(ADMIN_LOGIN, ADMIN_PASS);

the response from server was the same!

Could anyone give some idea how Smack client can be granted with admin role?

I think your problem is a setting in the server.

In the Registration settings (in the webinterface of OpenFire) you can enable in-band registration and some other settings you need.

As I wrote above I can registered if access rule set to {allow, all}.

Server is ejabberd. Registration is enabled.

I can modify access rule for registration. And I have to restrict registration.

Only admins should be able to register new account.

Access rule on ejabberd - {access,register,[{allow,admin}]}].

I tried use Smack and call connection.login(ADMIN_LOGIN, ADMIN_PASS) .

As I assumed connection authorized by admin account should be able to create new ones.

Now question is: why Smack cannot register new account anyway?

Thanks,

Max