Home Contact

The Frog Pond of Technology

Ripples of Knowledge for SharePoint and Other .Net Technologies


My blog has moved to WordPress at BrianTJackett.com. Any pages will automatically redirect to the new address in 7 seconds. Please excuse an issues during this migration.

 Subscribe to this blog

About Me

Brian T. Jackett
Columbus, OH

Find me on...

Tag Cloud


Post Categories


Single Sign-On Across .Net Web Apps Using Forms Based Authentication

     <foreword>Please read this explanation of Forms Based Authentication (FBA) first if you are unfamiliar with how FBA works or is implemented. </foreword>

    Achieving single sign-on capabilities using Forms Based Authentication is much easier than I had initially expected, yet it took awhile to find the exact settings required.  To get FBA working in SharePoint click here for a good starter from the SharePoint team blog.  I also used this article from MSDN as a reference for ultimately determining what settings were necessary in our environment.

    Small back story for what we are doing.  We have a SharePoint farm that has split authentication: Windows Integrated for users on the network at the office and FBA for users out in the field on the extranet.  Separate from our SharePoint farm is a .Net web application to assist with password reset and registration.  When the user logs in to SharePoint via FBA they are redirected to the external application if there is any problem with their account.  We wanted to implement single sign-on between the applications so that a user wasn’t re-prompted for credentials after the redirect.

     The general solution involved the following main items:

  • Changes to both applications’ web.config files
  • Configuring host headers for each app to be in the same domain lookup
  • 1 line of code to read authentication cookie


    So let’s review what was added to get this working starting with the web.config entries.

   <authentication mode="Forms">
      <forms name="nameOfCookie"
   <machineKey validationKey="value" decryptionKey="value"
       validation="value" decryption="value" />

    For the web.config entries you’ll need to ensure that both apps are set to Forms authentication.  Next specify a “name” value which will be used to identify your authentication cookie on the receiving application.  By default this value is “.ASPXAUTH”.  Specify the domain that each web application will be run under.  Using host headers your site URLs might look like "site1.mydomain.com” and “site2.mydomain.com”.  Specify protection=”All” so that the authentication cookie is encrypted using the machineKey value that you specify.  Lastly provide identical machineKey entries on each web application so that both can read the authentication cookie provided by each other.  I used a free random machine key generator in my development environment, but you’ll probably want your security team to handle generating and keeping track of keys for non-development environments.

    The next step involved configuring each site to use host headers assigned to the same domain.  This article from TechNet gives a brief intro to get you started.  As stated just above, I configured the web app URLs to appear as “site1.mydomain.com” and “site2.mydomain.com” to match my entries in the web.config.
    Lastly is the code required to read the authentication cookie.  If you read the explanation article linked in the foreword above you’ll read that after logging in using forms authentication, the authentication cookie containing the currently authenticated user (along with other data) is passed along with responses back to the server.  Due to this fact, on the receiving page in the other web application we can decrypt the cookie and read who is currently authentication even though they never logged in again to the the other application.  Here is the code to explicitly reference that cookie.
string loggedInUser = FormsAuthentication.Decrypt(Request.Cookies.Get("cookieName").Value).Name
    And that wraps up the changes to my web apps to allow single sign-on for forms based authentication.  If your web applications are SSL enabled I believe there are a few additional settings you’ll need, but they should be covered in the links I provided.  I hope this helps you or at least gives you some good resources to refer to for FBA.  If you have any questions, comments, or other feedback feel free to leave it below.
    -Frog Out

Thursday, September 3, 2009 3:55 PM


# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication

thanks for share 7/13/2010 11:36 PM | worldcupjersey

# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication


Here it is said that you need to manually fetch authenticated user data from cookies on SharePoint side.

Does it mean that SharePoint does not do it automatically?

My problem is that when I log in on asp.net login form, then the sharepoint starts throwing 500 internal server error, and on login page it says argument exception. It seems to be related to claims, but I'm not sure.

Question: is it possible to share the authentication cookies between asp.net and sp2010 without manually getting the cookie user from cookies?

Thanks. 2/23/2011 5:38 AM | Tengiz Tutisani

# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication


This article was written for SharePoint 2007 Forms Based Authentication, but many of the concepts apply to 2010 as well. I'm still new to Claims Based Authentication so I'm not sure how that changes up what happens at the lower levels.

As for passing cookies between the applications, if they contain the same machineKey values in the <system.web> entry in the web.config then they should be automatically opened by each other.

My line to manually decrypt the cookie was so that we could get the user name in the destination application. It is not necessary for this sharing to work. Let me know if you have further questions.
2/23/2011 9:18 AM | Brian T. Jackett

# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication


Thanks for your reply.

Actually, when making machinekey elements look the same way the cookie gets passed through, but the sharepoint throws an error saying "ArgumentException - parameter name: encodedValue". - This proves that the cookie gets passed correctly; and as soon as I remove the cookie (by signing out on asp.net site), the error on sharepoint dissapears.

That makes me think that sharepoint makes some special kind of encoding/decoding, which is not compatible with asp.net standard way.

So, I guess cookie needs to be created on asp.net side using some special way. And right now I have no clue what to do with it. 2/24/2011 5:55 AM | Tengiz

# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication

i also tried to implement same way as in this article, was as Tengiz is doing..
Login with asp.net Application and redirect to sharepoint site after Validation and write authentication cookies...

<authentication mode="Forms">
<forms loginUrl="http://btwin7:1000/Login.aspx?APPS=http://btwin7:8000" enableCrossAppRedirects="true" path="/" protection ="All" timeout="2880" />
Getting same issue.. 500 internal server error
i traced authenticaton cookie using fiddler tool. both time applcation(sharepoint and asp.net applcation) gives differrent size of authenticaton cookie.

help us to implement this... 2/24/2011 10:54 AM | Praveen Sharma

# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication


I'm sorry to say that I'm not sure where your error is occurring. This topic is not one of my strong areas of expertise. I relied on other sources (like the two articles I linked to above) for most of my information.
2/24/2011 7:43 PM | Brian T. Jackett

# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication

Hi Guys

Did any of you had implemented this in Share Point 2010 and made it working .If not do you know of any alternative method because i had implemented this in 2007 and it works just fine but in 2010 i am getting errors 5/16/2011 11:59 AM | anil

# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication

has anybody succeeded in implementing SSO between asp.net and Sharepoint 2010 FBA configured with ldapmembership? 7/19/2013 1:35 AM | Ramprasad

# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication

Hello Brian,
Good post .I have a question .I have a Sharepoint application that uses split authentication . Once the user is logged in Sharepoint (they could be internal users from the AD or external users validated against a custom table ) ,I need to redirect the user from Sharepoint to custom web app and pass the authentication cookie to the web app. In your post you talk about redirection only when the users login via FBA in Sharepoint.Would this work in both the following scenarios

1)User A is validated against AD in Sharepoint and when logged in is redirected to Web App .
2)User B logs in to Sharepoint.Being an external user
, they are validated against a table and then once logged in ,they are a directed to Web App.

Are there additional steps I need to do for this ?

I appreciate your help.


Raja 12/10/2013 6:30 PM | Raja

# re: Single Sign-On Across .Net Web Apps Using Forms Based Authentication


How are external users logging in? Are they using NTLM, FBA, ADFS, or another authentication provider?

If you set your web application to allow multiple authentication providers (ex. NTLM and FBA), you will automatically get a login page where they will choose their authentication method. You can place logic on that page to handle different sets of users in different fashions (ex. any request from a user with an internal IP address follows route 1 in your scenario and external IPs follow route 2).

You can create a custom login page using the steps on this blog post:
12/17/2013 12:59 PM | Brian T. Jackett

Post A Comment