Microsoft Developer Network > Forums Home > Windows Live Developer Forums Forums > Windows Live ID: Development > How to get CID when using Delegated Authentication with the Live Messenger IM Control?
Ask a questionAsk a question
 

AnswerHow to get CID when using Delegated Authentication with the Live Messenger IM Control?

  • Friday, November 06, 2009 5:49 AMAlan Zhao Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I want to create a page containning a Live Messager IM Control. After delegated authentication, I got a valid token object(I used the code in c# sample). But I need the CID in order to use IM Control. How to get it? Using ProcessToken method of WindowsLiveLogin class? I tried, but the returned user object is null. What should I do to get the cid?

Answers

  • Tuesday, November 10, 2009 4:50 PMChrisW_ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code

    Hello Alan,

    The CID is the same as the Location ID provided with Delegated Authentication; the only difference is that the Location ID is in hexadecimal format while the CID should be in signed decimal format.

    The following code sample converts a Location ID to a CID:

    WindowsLiveLogin.ConsentToken consentToken = <your token>;
    long cid;
    
    if (!Int64.TryParse(consentToken.LocationID,
        System.Globalization.NumberStyles.HexNumber, null, out cid))
        throw new InvalidOperationException("The Location ID is not a hexadecimal number");
    
    // Variable cid now contains a valid decimal number which you can use as CID.
    
    • Proposed As Answer byChrisW_ Tuesday, November 10, 2009 4:50 PM
    • Marked As Answer byAlan Zhao Wednesday, November 11, 2009 1:48 AM
    •  

All Replies

  • Tuesday, November 10, 2009 4:50 PMChrisW_ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code

    Hello Alan,

    The CID is the same as the Location ID provided with Delegated Authentication; the only difference is that the Location ID is in hexadecimal format while the CID should be in signed decimal format.

    The following code sample converts a Location ID to a CID:

    WindowsLiveLogin.ConsentToken consentToken = <your token>;
    long cid;
    
    if (!Int64.TryParse(consentToken.LocationID,
        System.Globalization.NumberStyles.HexNumber, null, out cid))
        throw new InvalidOperationException("The Location ID is not a hexadecimal number");
    
    // Variable cid now contains a valid decimal number which you can use as CID.
    
    • Proposed As Answer byChrisW_ Tuesday, November 10, 2009 4:50 PM
    • Marked As Answer byAlan Zhao Wednesday, November 11, 2009 1:48 AM
    •  
  • Wednesday, November 11, 2009 2:53 AMAlan Zhao Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes, it's the answer. Thanks to ChrisW_.