从导致错误的 ejabberd 服务器中删除用户(smack)
Delete a user from ejabberd server causing error (smack)
我正在尝试从我的 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;
}
创建账户只需要连接,但删除账户需要登录:您需要先登录才能删除账户(即您不能在不知道密码的情况下删除账户)。调用 mConnection.connect().login()
.
我正在尝试从我的 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;
}
创建账户只需要连接,但删除账户需要登录:您需要先登录才能删除账户(即您不能在不知道密码的情况下删除账户)。调用 mConnection.connect().login()
.