dongtang6718 2017-01-23 15:17
浏览 76
已采纳

用fabiang php取消注册ejabberd用户

i use fabiang php example (https://github.com/fabiang/xmpp/blob/master/example.php) to successfully register new user. but when I try remove command it fails with

<error code='405' type='cancel'><not-allowed xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>The query is only allowed from local users</text></error>

I noticed I can register new user even if Im not logged in, so I suspect my authentication is not working as expected for remove. How to use fabiang to authenticate with sha1?

I can unregister from android app with sha1 auth without problem.

  • 写回答

1条回答 默认 最新

  • dsjxgu4759 2017-03-30 20:34
    关注

    I figured it out, in order to unregister user, you have to be logged in as that user (while for register you have to be logged in as admin).

    $this->implementation = new Implementation($withAuthentication);
    $this->options = new \Fabiang\Xmpp\Options('tcp://...');
    $this->options->setImplementation($this->implementation);
    $this->options->setLogger($this->logger)
      ->setUsername($xmppuser)
      ->setPassword($xmpppass)
      ->setTimeout(self::XMPP_TIMEOUT);
    
    $this->client = new \Fabiang\Xmpp\Client($this->options);
    
    $listener = new UnRegistrationListener();
    $unRegistrationObj = new UnRegistration();
    
    $this->client->connect();
    $this->implementation->registerListener($listener);
    $this->client->send($unRegistrationObj);
    $this->client->disconnect();
    

    and unregister message from ProtocolImplementationInterface looks like this:

    public function toString()
    {
    return \Fabiang\Xmpp\Util\XML::quoteMessage(
      "<iq id='%s' type='set'><query xmlns='jabber:iq:register'><remove></remove></query></iq>",
      \Fabiang\Xmpp\Util\XML::generateId()
    );
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我这模型写的不对吗?为什么lingo解出来的下面影子价格这一溜少一个变量
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波