tags:

views:

14

answers:

1

Hi,

I was wondering whether it is is possible to modify a user's password using Jabber Net. If so, is there a neat way to verify first that the old password is indeed valid before modifying it to the new one?

A: 

You need to log in first. This will ensure that the old password is correct. Then, use the Register commands. See the example (MainForm.cs) for the similar code, but the important bits are:

jc.OnRegisterInfo += new jabber.client.RegisterInfoHandler(jc_OnRegisterInfo);
jc.OnRegistered += new jabber.client.IQHandler(jc_OnRegistered);

jc.Password = "New Password";
jc.Register(new JID(jc.User, jc.Server, null));

// Called back when server sends registration form
private bool jc_OnRegisterInfo(object sender, Register r)
{
    if (r.Form == null)
        return true;

    // Some newer servers may use XData for registration
    muzzle.XDataForm f = new muzzle.XDataForm(r.Form);
    if (f.ShowDialog() != DialogResult.OK)
        return false;
    f.FillInResponse(r.Form);
    return true;
}

// Done setting password
private void jc_OnRegistered(object sender, IQ iq)
{
}
Joe Hildebrand
Thanks, worked like a charm!
tutipute