robbiehanson / XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS
Other
5.91k stars 2.09k forks source link

How to change password of openfire user from XMPP? #619

Open ashishgupta301 opened 8 years ago

ashishgupta301 commented 8 years ago

We need to implement forget password but using XMPP we are unable to change password in openfire.

Provide any solution or any idea about this.

atanu-pal commented 8 years ago

I have manually crated an IQ and sent to server to change password from client. I am also using Openfire as server.

Here is my code, hope this will help you.

    NSXMLElement *query =[NSXMLElement elementWithName:@"query" xmlns:@"jabber:iq:register"];
    NSXMLElement *username =[NSXMLElement elementWithName:@"username" stringValue:**userID**];
    NSXMLElement *changePassword =[NSXMLElement elementWithName:@"password" stringValue:**newPassword**];
    [query addChild:username];
    [query addChild:changePassword];

    XMPPIQ *iq =[XMPPIQ iqWithType:@"set"  elementID:[XMPPStream generateUUID] child:query];
    [iq addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@",**serverIP**]];

    [[[XMPPAlertReceiver getXMPPAlertReceiver] xmppStream] sendElement:iq];