There was a question over at the MSDN forum that intrigued me so I thought I would take a crack at it.
The question was: "Looking at the ADFS sdk I found ClaimsAwareWebsite in C#. Is there an example in VB.net as well?".
Disclaimer - the last time I used VB was many, many moons ago.
Ok - so ADFS is the same, WIF is the same, the .NET Framework is the same so it shouldn't be that difficult - right?
I used VS 2012 with "Identity and Access Tool" added.
Take a look here:
How To: Build Claims-Aware ASP.NET Application Using Forms-Based Authentication.
OK so we create a new project but select "Other languages / Visual Basic / Web. Then select "ASP.NET Web Forms Application". You could go MVC - I'm more at home with Forms (Yeah - I know :-) ).
OK, that gives us the base project. Now use the "Identity and Access Tool" to "bind" your application to ADFS or wherever. Many references of the web to do this - it's language agnostic. And remember to add your new application as a RP in ADFS.
When you run up your application, you should be prompted for the logon screen.
Sweet!
Now in Step 2 in the above link, add the html exactly as described to Default.aspx.
Remember F7 / Shift F7 swops between code and designer.
You can convert the C# code-behind in Step 2 to VB using e.g.
Convert C# to VB.NET .
My page (for reference) was:
------------------------------
Imports System.Web.UI
Imports System.Security.Claims
Public Class _Default
Inherits Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim claimsPrincipal As ClaimsPrincipal = TryCast(Page.User, ClaimsPrincipal)
If claimsPrincipal IsNot Nothing Then
Me.ClaimsGridView.DataSource = claimsPrincipal.Claims
Me.ClaimsGridView.DataBind()
End If
End Sub
End Class
---------------------------
After you have been redirected to the home page after logging in, you should see a table that includes the
Issuer,
OriginalIssuer,
Type,
Value, and
ValueType claims information about your account.
Enjoy!