Reset the Windows Live password






1.27/5 (4 votes)
Windows Live password Reset Utility using Web service
Introduction
This Article is about the password resetting in Windows live domain Accounts.This article is meant for the developers who want to manage the domain for windows live.
Background
The code can be used by the developers to reset the password of a windows live ID.Some of the difficulties that I faced while developing this small utility was that,when you try to access the web services from the following url(https://domains.live.com/service/managedomain2.asmx)using a proxy Server you might be asked to give the credentials of the proxy server.And many of you would not like to do so,so build the application on a system which has a direct access to internet.
Using the code
The code is quite straigth forward,
Step 1. Add the Web reference from the given url to your solution.I have named it livedomain in my example.
Step 2. Feed the Admin username and password to the given code
Step 3. Feed the mail address of the Windows live user ,of whom you need to change the password.
Step 4. Run the Application to see instant results.
//Following are the Namespace that you may require. using System.Net; using System.Text; // Use this piece of code in a page load or on a button Click as per your wish try { livedomain.ManageDomain2 srvc = new livedomain.ManageDomain2(); string loginUrl = srvc.GetLoginUrl("Admin User ID"); string loginTemplate = srvc.GetLoginDataTemplate().Replace("%NAME%", "Admin USer ID").Replace("%PASSWORD%", "Admin Password"); string loginTicket = PostWebData(loginUrl, loginTemplate); if (srvc.VerifyAuthData(loginTicket)) { livedomain.ManageDomain2Authorization srvcAuth = new livedomain.ManageDomain2Authorization(); srvcAuth.authorizationType = livedomain.ManageDomain2AuthorizationType.PassportTicket; srvcAuth.authorizationData = loginTicket; srvc.ManageDomain2AuthorizationValue = srvcAuth; // return loginTicket; } else throw new ApplicationException("An error occurred while attempting to create an authorization ticket"); string memberName = "Users Mail address whose password needs to be changed"; string newPassword = "New password"; //Call to the ResetMemberPassword API //accepts the member name, //the new password and a flag indicating //whether the user should have to change it //the new password the next time they //log into Windows Live srvc.ResetMemberPassword(memberName, newPassword, true); Response.Write("Member password has been changed"); } catch (Exception ex) { Response.Write(String.Format("The following error occurred" + " while changing the member password: {0}", ex.Message)); } } //This is the function you need to include in the page or class private static string PostWebData(string URL, string postContent) { HttpWebRequest request = null; HttpWebResponse response = null; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] tmpBytes = encoding.GetBytes(postContent); request = (HttpWebRequest)WebRequest.Create(URL); request.Method = "POST"; request.ContentLength = postContent.Length; request.UserAgent = "Mozilla/4.0 (compatible;" + "MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)"; Stream newStream = request.GetRequestStream(); request.AllowAutoRedirect = true; newStream.Write(tmpBytes, 0, tmpBytes.Length); // Get the response response = (HttpWebResponse)request.GetResponse(); // Return the result string result = new StreamReader(response.GetResponseStream()).ReadToEnd(); newStream.Close(); return result; }The above code is developed in Asp.net C# 2.0.
Points of Interest
One can use text boxes to get the input from the user,regarding the email account ,admin user ID password etc ..Hope this Article has helped you to get the utility working