Community Server: Single Sign-On in reverse

Community Server's Single-Sign-On modules handle the case where:

  • You have an ASP.NET website with an adjoining Community Server website
  • Members log into your main ASP.NET website and you want Community Server to recognize that site's authentication of the member

What if members log into your Community Server website but not your main ASP.NET website? Over the past week, I've encountered two people who want membership to be handled by Community Server. But their main website needs to determine whether the member is authenticated via User.Identity.IsAuthenticated and User.Identity.Name.

It's possible to do so. I tested the scenario where the main website is at www.yourdomain.com and the community is at community.yourdomain.com. Both sites use forms authentication.

In order for www.yourdomain.com to see the authenticated user, you must make sure that two elements within the web.config file of each website are compatible.

In the <forms> element of the <authentication> element, the protection attributes must have identical values and the path attributes must have compatible values. In the <machineKey> element, the validationKey, decryptionKey, and validation attributes must have identical values. The following example shows the elements:

<authentication mode="Forms">
 <
forms name=".CommunityServerpath="/" protection="Alltimeout="60000"
    loginUrl="CS login Url" slidingExpiration="true" />
</
authentication>

 <machineKey
  validationKey = " [your validation key]"
  decryptionKey = " [your decryption key]"
  validation = " SHA1" />

This is described with a little more detail in the .NET Framework Developer's Guide, topic Forms Authentication Across Applications.