Click here to Skip to main content
Licence CPOL
First Posted 29 May 2008
Views 8,824
Bookmarked 11 times

Reset the Windows Live password

By | 29 May 2008 | Article
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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mohd Naved Khan

Web Developer

India India

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralProblms in ManageDomain2 not available in service Pinmembervashk1:07 19 Apr '12  
Generalissue about ssl PinmemberEvelyn Kinsey0:18 17 Sep '09  
GeneralRe: issue about ssl Pinmemberust_donetsk21:14 19 Apr '12  
Generalcannot connect to server PinmemberMailoever21:28 5 May '09  
AnswerRe: cannot connect to server PinmemberMohd Naved Khan4:28 6 May '09  
Generalthx PinmemberMailoever22:04 29 Apr '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 30 May 2008
Article Copyright 2008 by Mohd Naved Khan
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid