HomeRealmDiscoveryPage Class Overview
The HomeRealmDiscovery.aspx
page shows a drop-down list that contains the list of trusted claims providers configured for the Active Directory® Federation Services (AD FS) 2.0 server. The code-behind class for this page derives from the HomeRealmDiscoveryPage class.
The HomeRealmDiscoveryPage class provides the ClaimsProviders property to retrieve the list of claims providers that are trusted by the core security token service. (These are the claims providers configured under Claims Provider Trusts in the AD FS 2.0 Management Console.) It also provides the HomeRealmDiscoveryPage.SelectHomeRealm method to redirect the user to the selected claims provider.
The HomeRealmDiscoveryPage class provides the PassiveProtocolPage.SignIn method, which it inherits from the PassiveProtocolPage class, to sign the user in with a posted token.
Example: Showing Claims Providers as a List of Links
This example shows how to modify the HomeRealmDiscovery.aspx
page and its code-behind class to display the list of trusted claims providers as a list of links instead of a drop-down list.
Warning
We recommend that you make backup copies of the HomeRealmDiscovery.aspx
and HomeRealmDiscovery.aspx.cs
files before you modify them.
First, in the HomeRealmDiscovery.aspx
, remove the drop-down list and the Submit button control:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="GroupXLargeMargin">
<asp:Label Text="<%$
Resources
:CommonResources, HomeRealmSelectionText%>
" runat="server" />
</div>
<div class="GroupXXLargeMargin">
<!-- Remove this element. -->
<asp:DropDownList ID="PassiveIdentityProvidersDropDownList" DataTextField="Name" DataValueField="Id" runat="server"></asp:DropDownList>
<div>
<!-- Remove this element. -->
<asp:Button runat="server" ID="PassiveSignInButton" Text="Continue to Sign In" EnableViewState="False"
OnClick="PassiveSignInButton_Click" CssClass="Resizable"/>
</div>
</div>
<!-- ... -->
</asp:Content>
Next, add a Repeater
control where the drop-down list used to be.
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script type="text/javascript" src="FederationPassiveJScript.js"></script>
<div class="GroupXLargeMargin">
The site that you are accessing requires you to sign in. Select your organization from the following list.
</div>
<div class="GroupXXLargeMargin">
<div>
<!-- Add this. -->
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<div>
<asp:LinkButton ID="LinkButton1" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "ID") %>
'
runat="server"><%#DataBinder.Eval(Container.DataItem, "Name") %>
</asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
<!-- ... -->
</asp:Content>
Note that you define the ItemTemplate
of the Repeater
control to generate a LinkButton
control. The CommandArgument
of each LinkButton
control takes the value of the ID
column from a data binding, which you set up in the next step. The text of the link is taken from the Name
column from this data binding.
Next, in the HomeRealmDiscovery.aspx.cs
page, bind the Repeater
control to HomeRealmDiscoveryPage.ClaimsProviders
in the Page_Init
event handler.
public partial class HomeRealmDiscovery : Microsoft.IdentityServer.Web.UI.HomeRealmDiscoveryPage
{
protected void Page_Init( object sender, EventArgs e )
{
// This was the data binding used by the drop-down list that you removed.
// PassiveIdentityProvidersDropDownList.DataSource = base.ClaimsProviders;
// PassiveIdentityProvidersDropDownList.DataBind();
// This is the data binding for the Repeater control.
Repeater1.DataSource = base.ClaimsProviders;
Repeater1.DataBind();
}
}
Finally, remove the PassiveSignInButton_Click
event handler, and add an event handler for the ItemCommand
event of the Repeater
control. Pass the CommandArgument
that was assigned to the LinkButton
control (which the user clicked) as the parameter to the HomeRealmDiscoveryPage.SelectHomeRealm method.
// Remove this.
protected void PassiveSignInButton_Click( object sender, EventArgs e )
{
SelectHomeRealm( PassiveIdentityProvidersDropDownList.SelectedItem.Value );
}
// Add this.
protected void Repeater1_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
SelectHomeRealm((string)e.CommandArgument);
}