1. First modify the password in Protocol 0077 to modify the XML
{
/*
<iq type= ' Set ' to= ' Shakespeare.lit ' id= ' Change1 ' >
<query xmlns= ' Jabber:iq:register ' >
<username>bill</username>
<password>newpass</password>
</query>
</iq>
*/
Nsxmlelement *iq = [nsxmlelementelementwithname:@ "IQ"];
[IQ addattributewithname:@ "type"stringvalue:@ "set"];
[IQ addattributewithname:@ "to"stringvalue:@ "Ubuntu-dev"];
[IQ addattributewithname:@ "id"stringvalue:chang_pwd_id]; #define CHANG_PWD_ID @"Change1" to make sure the ID is unique.
nsxmlelement *queryelement = [nsxmlelementelementwithname:@ "Query"xmlns:@ "Jabber:iq: Register "];
[IQ addchild:queryelement];
nsstring *usernamestr = [[nsuserdefaultsstandarduserdefaults]objectforkey:@ "UserName" ];
nsxmlelement *username = [nsxmlelementelementwithname:@ "username"];
[username setstringvalue:usernamestr];
nsxmlelement *password = [nsxmlelementelementwithname:@ "password"];
NSLog(@ "self.tfnewpwdsure.text_______:%@",self. Tfnewpwdsure. Text);
[Password setstringvalue: Self. Tfnewpwdsure. text];
[Queryelement addchild:username];
[Queryelement Addchild:password];
NSLog (@ "iq__%@", iq.description);//print the XML stream check to see if the stitching is correct
[[Xmppserviceshareinstance]. Xmppstreamsendelement: iq];//Send {Xmppstream is encapsulated in a singleton xmppservice}
[[Xmppserviceshareinstance]. Xmppstreamadddelegate:selfdelegatequeue:dispatch_get_main_queue()];//set up proxy
}
#pragma make-xmppstream
-(BOOL) Xmppstream: (xmppstream *) sender Didreceiveiq: (Xmppiq *) iq{
NSLog (@ "__%@", IQ. description);
/*
<iq xmlns= "jabber:client" type= "result" id= "Change1" from= "Ubuntu-dev" to= "[Email PROTECTED]/870EFDCD" ></iq >
*/
nsstring *iqtypepwd = [[IQ Attributeforname:@ ' type ']stringvalue];
nsstring *iqidpwd = [[Iqattributeforname:@ ' id ']stringvalue];
NSLog(@ "iqtypepwd:%@___iqtypepwd:%@", iqtypepwd,iqidpwd);
if ([Iqtypepwd isequaltostring:@ "Result"]&&[iqidpwdisequaltostring:chang_pwd_id]) {// The password modification succeeds only if the type= "result" id= "change1" is determined
NSLog(@ "OpenFire password modified successfully!") );
}
return YES;
}
Personal Summary: The XMPP framework is not omnipotent, but the XML stream is omnipotent, and when XMPP doesn't meet your needs, it can be easily done with XML!
Original: http://blog.csdn.net/shang1219178163/article/details/22207283
change user password under-XMPP (server OpenFire) framework