WL Training at Bangkok | Day 01

Today we start

10.13. Started to write.

Sleepy, but have new stuff to hack :). The trainer is Ben Williams, he is presenting overview of Windows Live now. Based on schedule, he will move to Silverlight Streaming (SLS) after the overview. I am not interesting with SLS for now. So, I downloaded Windows Live ID Client SDK (WLIDClientSDK) and play with it.

Wl02 

The scenario is simple. You have an Windows client application that want to utilize authentication service from WL ID Authentication Server, after authenticated, client application maybe consume other WL services.  The Windows Live ID service that receives credentials and responds by issuing an authentication ticket. This authentication ticket is used in subsequent requests to obtain service tickets for specific Windows Live ID sites and services, as necessary. This ticketing mechanism is common.

Now lets look inside WLIDClientSDK. There are 2 DLLs :

- Microsoft.WindowsLive.Id.Client.dll (we will play with it more)
- msidcrl40.dll (COM object for Windows Live ID Login Screen)


Ok, let see the main WLIDClientSDK DLL design. Basically it contains simple classes for identity management and authentication to WL ID Authentication Server. Microsoft.WindowsLive.Id.Client.dll has Identity and IdentityManager classes as its core. The IdentityManager class is used primarily to maintain a connection to the authentication server and to perform tasks necessary for the creation and maintenance of Identity objects. Use IdentityManager to manage your application name and create Identity objects. To initialize global instance of IdentityManager, you can use CreateInstance method and after initialized, IdentityManager object can be used to create identity objects. The Identity class represents an end-user of your application. Use CreateIdentity to create an instance of Identity to use in your application.

ClassDiagram1

Now lets look my simple codes below using WLIDClientSDK API:

using System;
using Microsoft.WindowsLive.Id.Client;  

namespace WLClientID
{
    class Program
    {

 

        [STAThread]  // Don't forget to use this as Sign-In dialog Window is Single Threat App
        static void Main(string[] args)
        {
            IdentityManager oIDManager = IdentityManager.CreateInstance("Risman123", "RismanConsole");
            Identity oID = oIDManager.CreateIdentity(); ;
            string currentUserName = "";
            if (!oID.IsAuthenticated)
            {
                try
                {
                    //Try to authenticate the user by showing the Sign-In dialog window.
                    if (oID.Authenticate())
                    {
                        currentUserName = oID.UserName;
                    }
                    else
                    {
                        Console.WriteLine("Authentication failed");
                    }
                }
                catch (WLLogOnException wlex)
                {
                    //Check to see if FlowUrl is defined.
                    if (wlex.FlowUrl != null)
                    {
                        //If FlowUrl is defined, direct user to the web page to correct the error.
                        Console.WriteLine(wlex.ErrorString + "Please go to " + wlex.FlowUrl.AbsoluteUri + "to correct error");
                    }
                    else
                    {
                        //If FlowUrl is not defined, simply display the ErrorString.
                        Console.WriteLine(wlex.ErrorString);
                    }
                }
            }
            else
            {
                //If user is authenticated, they intended to Sign-Out. Try signing the user out.
                try
                {
                    oID.CloseIdentityHandle();
                    currentUserName = "";
                }
                catch (WLLogOnException wlex)
                {
                    //Check to see if FlowUrl is defined.
                    if (wlex.FlowUrl != null)
                    {
                        //If FlowUrl is defined, direct user to the web page to correct the error.
                        Console.WriteLine(wlex.ErrorString + "Please go to " + wlex.FlowUrl.AbsoluteUri + "to correct error");
                    }
                    else
                    {
                        //If FlowUrl is not defined, simply display the ErrorString.
                        Console.WriteLine(wlex.ErrorString);
                    }
                }
            }
        }
    }
}

 

If you see the codes, oID.Authenticate() method open Sign-In dialog Window from msidcrl40.dll (COM Object).  My question is, can we customize the sign-in windows? I don't really like its user experience and want to add more links in the form. I will find out how to do that later yaa (hope that is possible). I get very bad cold (flu and couch) today, hiks.


 WL01


Hope this helps.

11.50. Finished 1st Report from Bangkok :).


Thx - Risman Adnan

Share this post: | | | |
Published Thursday, April 24, 2008 11:51 AM by Risman Adnan Mattotorang

Comments

# Day 1 - Windows Live Train the Trainer

Gak mau kalah dengan Pak Risman Adnan , Andri Yadi dan Agung Riyadi yang sudah mempost duluan tentang

Thursday, April 24, 2008 1:55 PM by Narenda Wicaksono

# Oleh-oleh dari Bangkok - Hari 1

Selama weekend ini saya fokus untuk mengikuti training for the trainer "Windows Live Platform"

Thursday, April 24, 2008 2:37 PM by Narenda Wicaksono

# Day 1 - Training in Bangkok

Currently, I'm writing this blog while the trainer gives an introduction about himself & what

Thursday, April 24, 2008 4:27 PM by Andri Yadi

# Oleh-oleh dari Bangkok - Hari 1

Selama weekend ini saya fokus untuk mengikuti training for the trainer "Windows Live Platform"

Friday, April 25, 2008 10:05 AM by Narenda Wicaksono