Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
mrOrbit #1
Member since Jan 2006 · 9 posts
Group memberships: Members
Show profile · Link to this post
Subject: Remove jabber account from jabber server.
Can i remove jabber account from jabber server with your library?

And how i can do it.

I use wildfire jabberserver.
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi,

Not all servers support removing accounts. If your server supports it use this code:

  1. private void RemoveAccount()
  2. {
  3.     agsXMPP.protocol.iq.register.RegisterIq rIq = new agsXMPP.protocol.iq.register.RegisterIq();
  4.     rIq.To = new Jid(XmppCon.Server);
  5.     rIq.Query.RemoveAccount = true;
  6.  
  7.     XmppCon.IqGrabber.SendIq(rIq, new IqCB(OnRemoveAccountResult), null);           
  8. }
  9.  
  10. private void OnRemoveAccountResult(object sender, IQ iq, object data)
  11. {
  12.     if (iq.Type == IqType.result)
  13.     {
  14.         // Removed Account Successful
  15.         XmppCon.Close();
  16.     }
  17.     else if (iq.Type == IqType.error)
  18.     {
  19.         // failed for some reason
  20.     }
  21. }
Alexander Gnauck
AG-Software
This post was edited 2 times, last on 2012-01-31, 20:39 by Alex.
Avatar
sunng #3
Member since Apr 2007 · 7 posts
Group memberships: Members
Show profile · Link to this post
hi Alex,

I found that there is no event called "OnRemoveAccountResult" in XmppClientConnection

where should I set the Event?

just in the  followwing line?

m_XmppCon.IqGrabber.SendIq(rIq, new IqCB(OnRemoveAccountResult), null); 

thank you
Avatar
Jabberer #4
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
no there is none, this is a callback defined in the sample code above
Software Developer
AG-Software
Avatar
reach4thelasers #5
Member since Dec 2009 · 7 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #2
Exactly how do you specify which account to remove in this code?  Do also need to log in with the admin account to delete it?  how do you specify that?
Avatar
Alex #6
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by reach4thelasers:
Exactly how do you specify which account to remove in this code?  Do also need to log in with the admin account to delete it?  how do you specify that?

This removes you are currently logged in with.

Alex
Alexander Gnauck
AG-Software
Avatar
reach4thelasers #7
Member since Dec 2009 · 7 posts
Group memberships: Members
Show profile · Link to this post
Do you know if this works with eJabberd?  The code above sends the following:
<iq xmlns="jabber:client" id="agsXMPP_1" to="kevin-laptop"><query xmlns="jabber:iq:register"><remove /></query></iq>

Which fails to delete the currently logged in user; it produces the following in my logs:

=INFO REPORT==== 2010-05-31 20:52:03 ===
D(<0.796.0>:ejabberd_c2s:1412) : Send XML on stream = "<iq from='kevin-laptop' to='testaccount@kevin-laptop/agsXMPP' type='error' xml:lang='en' id='agsXMPP_1'><query xmlns='jabber:iq:register'><remove/></query><error code='400' type='modify'><bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>"

Any idea why its a bad request?  Not sure if it has anything to do with the space in <remove  ..  /> 

Anyone know if this feature is supported in eJabberd?
Avatar
Alex #8
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
When did you send this request?
The id=agsXMPP_1 indicates that you sent it to early. Are you authenticated when you send it?

Alex
Alexander Gnauck
AG-Software
Avatar
reach4thelasers #9
Member since Dec 2009 · 7 posts
Group memberships: Members
Show profile · Link to this post
I don't think its being sent too soon as I don't send the remove request until after the OnLogin event fires.  Even if I insert a Thread.Sleep(5000) I get the same result although this time the id is _5.

The "bad request" error makes me think it might be something to do with the space in
<remove (space here)  />

Here's my Console output


On Login Event Handler Called
Sending Remove Request
<iq xmlns="jabber:client" id="agsXMPP_5" to="kevin-laptop"><query xmlns="jabber:iq:register"><remove /></query></iq>
Account Remove Failed
<iq xmlns="jabber:client" to="testaccount@kevin-laptop/agsXMPP" xml:lang="en" type="error" from="kevin-laptop" id="agsXMPP_5"><query xmlns="jabber:iq:register"><remove /></query><error type="modify" code="400"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" /></error></iq>

  Account not deleted
  Expected: True
  But was:  False
Avatar
Alex #10
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
also your request has no type. Set Type to set.
Alexander Gnauck
AG-Software
Avatar
reach4thelasers #11
Member since Dec 2009 · 7 posts
Group memberships: Members
Show profile · Link to this post
Quote by Alex:
also your request has no type. Set Type to set.

Thank you, that was the problem!
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP SDK Support RSS