Share via


PassportIdentity.GetProfileObject

PassportIdentity.GetProfileObject

Gets Microsoft® .NET Passport profile attributes, and returns profile information for the specified profile attribute.

Syntax

public object GetProfileObject( string strProfileName )

Parameters

  • strProfileName
    Required. The .NET Passport profile attribute to return.

Return value

The value of the .NET Passport profile attribute specified by the strProfileName parameter.

Example

The following C# example gets three different attributes using both the Item property and the GetProfileObject method. The output of the Item property and the GetProfileObject methods is identical.

<%@ Page Language="C#"%>
<HTML>
<HEAD><TITLE>Mysample - Exercise - CS</TITLE></HEAD>
<Script language="C#" runat="server">
 PassportIdentity oMgr;

 protected void Page_Load(Object src, EventArgs e) {
  oMgr = (PassportIdentity)User.Identity;
 }
</Script>
<%
if (oMgr.GetIsAuthenticated(3600,0,-1)) {
 //At least two ways to output the same information
 Response.Write ("You are authenticated.");
 Response.Write ("<br><br>oMgr['Firstname'] = " + oMgr["Firstname"]);
 Response.Write ("<br>oMgr.GetProfileObject('Firstname') = " + 

 oMgr.GetProfileObject("Firstname"));
 Response.Write ("<br><br>oMgr['memberName'] = " + oMgr["memberName"]);
 Response.Write ("<br>oMgr.GetProfileObject('memberName') = " + 

 oMgr.GetProfileObject("memberName"));
 Response.Write ("<br><br>oMgr['memberIdHigh'] = " + oMgr["memberIdHigh"]);
 Response.Write ("<br>oMgr.GetProfileObject('memberIdHigh') = " + 

 oMgr.GetProfileObject("memberIdHigh"));
 Response.Write ("<br><br>oMgr['country'] = " + oMgr["country"]);
 Response.Write ("<br>oMgr.GetProfileObject('country') = " + 

 oMgr.GetProfileObject("country"));
}
else {
 Response.Write ("You have not been authenticated within the last hour.");
}
%>
</HTML>

Output for an authenticated user will be similar to the following:

You are authenticated.

    oMgr['Firstname'] = Myname
    oMgr.GetProfileObject('Firstname') = Myname

    oMgr['memberName'] = Customer!@passport-ppe.com
    oMgr.GetProfileObject('memberName') = Customer!@passport-ppe.com

    oMgr['memberIdHigh'] = 229376
    oMgr.GetProfileObject('memberIdHigh') = 229376

    oMgr['country'] = US
    oMgr.GetProfileObject('country') = US 

Remarks

A read-only method. Calling this method is the equivalent of calling the Item property.

Valid attribute names are determined by the Profile schema sent to participating sites in the Partner.xml Component Configuration Document (CCD). Asking for an strProfileName that does not exist will give a run-time error.

Some attributes may not be able to be retrieved, depending on settings in the profile itself. That is, attempting to retrieve the Firstname attribute will result in a null if the Share my first and last names box in the user's profile is not selected.

See Also

Passport PassportIdentity Object | PassportIdentity.Item | Core Profile Table