Displaying User-Specific Content


Displaying User -Specific Content

When a user creates an account with Passport, he or she is creating a profile with Passport. This profile contains information such as nicknames, e-mail addresses, and/or geographical information.

Note  

Passport strictly guards profile information. Please see the Passport documentation or the Passport Web site for privacy concerns regarding this information.

You can use the Passport profile information constructively in many ways. You can add a high degree of user-friendliness to your application by using a user s nickname or automatically filling out an address form based on the user s profile information. You can access profile information in Passport .NET by name . Please see the latest Passport SDK documentation for a full list of valid profile names .

To conclude the CPassportHandlerT class, you ll add a stencil tag called {{Passport_GetProfile}} . This stencil tag will accept a name as a parameter, and assuming that name is a valid profile name, it will return the value for it. This tag can be used in a stencil as follows :

 Hello {{Passport_GetProfile( "nickname")}}! Thanks for using ATL Server! 

Adding this stencil tag means adding to your replacement tag as follows:

 BEGIN_REPLACEMENT_METHOD_MAP(THandler)       REPLACEMENT_METHOD_ENTRY("Passport_LogoTag", OnLogoTag)       REPLACEMENT_METHOD_ENTRY("Passport_IsAuthenticated", OnIsAuthenticated)       REPLACEMENT_METHOD_ENTRY_EX_STR("Passport_GetProfile", OnGetProfile)  END_REPLACEMENT_METHOD_MAP() 

You ll notice this time that you use the REPLACEMENT_METHOD_ENTRY_EX_STR macro. This macro allows you to create a tag that takes a string parameter. Now you have the tag {{Passport_GetProfile}} associated with the method OnGetProfile , which takes a single string parameter. Listing 21-6 shows how to implement this method.

Listing 21.6: Getting Passport Profile Information
start example
 1 HTTP_CODE OnGetProfile(char *profileName)  2 {  3     CComVariant value;  4  5     if (FAILED(m_passportManager->get_Profile(CComBSTR(profileName), &value)))  6     {  7          return HTTP_S_FALSE;  8     }  9  10    switch (value.vt)  11    {  12         case VT_I1:  13             m_HttpResponse << value.cVal;  14              break;  15         case VT_I4:  16             m_HttpResponse << value.intVal;  17             break;  18         case VT_BSTR:  19             m_HttpResponse << value.bstrVal;  20             break;  21         default:  22             m_HttpResponse << "Unknown type!";  23             break;  24    }  25  26    return HTTP_SUCCESS;  27 } 
end example
 

IPassportManager2 exposes get_Profile , which makes your job quite simple. You just have to call this method with the profile name given to use in the profileName parameter and try to display its value. The switch statements in lines 10 through 24 don t cover all the possible data types; for the sake of brevity, the code just converts the most likely ones.

Now you ve added all the functionality you need to implement this scenario. In the next section you ll take a look at the complete code listing for your new class.




ATL Server. High Performance C++ on. NET
Observing the User Experience: A Practitioners Guide to User Research
ISBN: B006Z372QQ
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net