我正在尝试从我的ejabberd服务器中删除用户,但我不断收到以下错误:org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPPError: not-allowed - cancel
我认为这与用户权限有关?所有人都可以注册,这不应该是问题吗?
以下是我的代码:
@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;
}
答案 0 :(得分:1)
帐户创建只需要连接,但帐户删除需要登录:您需要先登录才能删除帐户(即,您无法在不知道密码的情况下删除帐户)。致电mConnection.connect().login()
。