Browse DevX
Sign up for e-mail newsletters from DevX


Set Up Passport Authentication in ASP.NET : Page 4

Learn how to use basic authentication features in Microsoft Passport. Once you've gained an understanding of the Passport information exchange between users and sites, you'll be ready to write the code for your own Passport-enabled ASP.NET page.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Step 6. Select Your Registered Application
The drop-down list on this page contains all the applications that you registered using the same e-mail account. Select the application you just registered in Steps 1, 2, 3, and 4. You will get all the information related to the application, along with a number of links (as shown in Figure 10).

Information Related to Your Application
Figure 10: All the Information Related to Your Application

Step 7. Initiate the Key Download
Click the "Download a Key" link to start the key download procedure. Select the service, operating system, and the Web server. The code for this article was tested for the Passport service, Windows operating system, and the IIS Web server. After entering this information, press the select button.

Step 8. Download the Key to a Convenient Location
Next, you'll see the key download screen, which contains a "Download Key" button. Pressing the button downloads and saves a key to your hard disk at the location of your choice. The key is downloaded in the form of an .exe file with the following name format:

  • PartnerSiteID_Version (for example, if the site id was 32841 and the Passport manager version was 1 then the name of the .exe file would be Partner32841_1.exe).
  • Passport server uses this key for secure communication with the Passport-enabled application. Store it in a convenient location. You will need it shortly.

    Step 9. Download and Install Passport SDK
    To assist in rapid application development, Microsoft offers a class named "PassportIdentity" that wraps all the HTTP communication you will need to do with the Passport server. This leaves an easy-to-use interface for developing Passport-enabled applications.

    Microsoft also produces a GUI to configure the communication with Passport server. All classes and GUIs are bundled as an SDK called Passport SDK. You will need this SDK before you can use Passport features in ASP.NET. Download Passport SDK, install it on your machine, and run the Passport manager administration utility.

    Step 10. Complete the Passport Manager Administration Utility
    Figure 11 shows the GUI of the Passport manager administration utility. You need only fill in the Site ID text field with the Site ID you got in Step 4. The rest of the fields are optional. You may have to change the value of the Language field, which is set of US English by default.

    GUI of Passport Manager
    Figure 11: GUI of the Passport Manager Administration Utility

    Step 11. Getting a Test Account
    Up until now, you've used your .NET Passport-enabled e-mail account (Hotmail or MSDN) to register your application. However, to test pre-production Passport-enabled applications, you need a separate test account. You use this account only during development. Once you've paid Microsoft the fee for using the Passport service, you won't need it.

    The Passport server keeps the development accounts separate from production accounts. Pre-production sites cannot work with Passport-enabled accounts. So if you try to use a Hotmail account (or any other Passport-enabled account) to authenticate on a pre-production site, the authentication will fail. That's why you need to get a test account.

    The following steps register you for a .NET Passport-enabled test account:

    1. Obtain an e-mail address other than Hotmail or MSN.com.
    2. Visit the Microsoft Passport test account registration site (http://current-register.passporttest.net/). You will encounter a registration page that asks for an e-mail address, a password, and some personal information (see Figure 12). If you're willing to share your personal information with the site(s) you will test using this account, you can check the boxes labeled "share my e-mail address" and "share my other registration information." Microsoft administrates test accounts separately from the real Passport-enabled accounts.

    Registration Page
    Figure 12: Registration Page Asks for E-mail, Password, and Personal Information

    Step 12. Install the Key You Downloaded in Step 8
    Execute the Partner_32841_1.exe file with the "addkey" switch on the command prompt, as shown here:

    Partner32841_1 /addkey

    Step 13. Instruct the IIS to Use the Key
    Once the key is installed, you need to tell your IIS to use this key. Execute the same Partner_32841_1.exe file with two switches, as shown here:

    Partner32841_1.exe /makecurrent /t 0

    The "makecurrent" switch instructs IIS to start using this key after "t" seconds. So if the "t" switch value is 0, IIS starts using this key immediately.

    Step 14. Create a New ASP.NET Project
    You need to make a small change in the web.config file, which you will find among your project files. Open the web.config file and change the value of the "mode" attribute of the "authentication" element from "Windows" to "[Windows/Forms/Passport/None]". This will allow your ASP.NET application to use Passport-based authentication in addition to other types of authentications.

    Now that you have successfully configured your machine and the application that you want to build, you can start developing your first ASP.NET application.

    Comment and Contribute






    (Maximum characters: 1200). You have 1200 characters left.



    Thanks for your registration, follow us on our social networks to keep up-to-date