SpecialSnowflake
SpecialSnowflake

Reputation: 995

Delete a user from ejabberd server causing error (smack)

I'm trying to delete a user from my ejabberd server but am continuously receiving the following error: org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: not-allowed - cancel

I'm assuming this has something to do with user permissions? Registration is enabled for all so that shouldm't be the problem?

Here is what my code looks like:

    @Override
protected Boolean doInBackground(String... params) {

    builder.setUsernameAndPassword(params[0], params[1]);
    mConnection = new XMPPTCPConnection(builder.build());
    try {
        mConnection.connect();
    } catch (SmackException | IOException | XMPPException e) {
        Log.d(TAG, "Something went wrong when trying to connect");
        e.printStackTrace();
        return false;
    }
    AccountManager manager = AccountManager.getInstance(mConnection);
    manager.sensitiveOperationOverInsecureConnection(true);
    try {
        manager.deleteAccount();
    } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException e) {
        Log.d(TAG, "Something went wrong when trying delete the account");
        e.printStackTrace();
        return false;

    }
    return true;

}

Upvotes: 0

Views: 178

Answers (1)

guik
guik

Reputation: 419

Account creation requires only connection, but account deletion requires login: you need to login first before being able to delete the account (i.e. you cant not delete an account without knowing its password). Call mConnection.connect().login().

Upvotes: 1

Related Questions