I'm currently in the process of registering and unregister/remove
users programmatically from my openfire XMPP server using jabber-net.
Users get created of deleted from a superuser "admin" account.
For registering a list users synchronously i have the following code:
=================================================
public void RegisterUsers(List<User> users)
{
if (client.IsAuthenticated)
{
IQ regForm = RequestRegistrationForm();
foreach (User user in users)
{
// populate form with user information
IQ form = PopulateRegistrationForm(regForm, user);
form.To = Server;
form.Type = IQType.set;
form.ID = Element.NextID();
form.From = user.Username + "@" + Server + "/" +
Resource;
// send a synchronous IQ call
// TODO: keeps throwing timeout error waiting for
IQ response. try to fix it
IQ response =
client.Tracker.IQ(form,
(int)client.KeepAlive);
}
}
=================================================
The accounts get created and everything is fine. Sometimes I do get a
timeout error waiting for IQ response. Any idea why this might
happen?, Since the user accounts still get created when this error is
thrown
for removing the users i have to following code:
=================================================
public void UnRegisterUsers(List<User> users)
{
if (client.IsAuthenticated)
{
RegisterIQ iq = new RegisterIQ(client.Document);
iq.To = Server;
iq.Type = IQType.set;
Register r = iq.Query as Register;
r.Remove = true;
foreach (User user in users)
{
iq.ID = Element.NextID();
iq.From = user.Username + "@" + Server + "/" +
Resource;
client.Tracker.IQ(iq, (int)client.KeepAlive);
}
}
}
=================================================
The stanza for cancelling the accounts of the user follows the
protocol from:
http://xmpp.org/extensions/xep-0077.html#usecases-cancel
and produces the following stanza:
<iq id="JN_7" type="set" to="localxmpp" from="useraccount@localxmpp/
resource"><query xmlns="jabber:iq:register"><remove /></query></iq>
which, as far is I can see, is correct.
The problem I'm encountering is that instead of the "useraccount"
getting removed, my "admin" account get's deleted. And I receive the
following response.
<iq type="result" id="JN_7" from="localxmpp"
to="conclusionadmin@localxmpp/conclusion"/>
Thank you,