Поделиться через


PassportIdentity.Item

PassportIdentity.Item

Gets Microsoft® .NET Passport profile attributes and returns profile information for the specified profile attribute. This property is the indexer for the PassportIdentity class.

Syntax

public string Item(string strProfileName) [get]

Parameters

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

Property value

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

Example

The following C# example gets four attributes of a user's .NET Passport profile using both the Item property and the GetProfileObject method. The output of the Item property and the GetProfileObject methods are 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>

An authenticated user will provide an output 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 property. Calling this property is the equivalent of calling the GetProfileObject method.

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.

See Also

Passport PassportIdentity Object | PassportIdentity.GetProfileObject | Core Profile Table