Welcome to MSDN Blogs Sign in | Join | Help

Pranab Paul's Blog - SharePoint 2007 (MOSS/WSS 3.0) Development Tips

------------------------------------------Web Parts, Workflow, InfoPath Form Services, Features, Site Definition, Event Receivers, Excel Services, Business Data Catalog (BDC), Search

News

Using HTTP Module for SharePoint 2007 (MOSS/WSS) site using FBA And RSA

Requirement: I am using WSS site with Form Based Authentication (FBA) with a custom login page which reads username from RSA cookie and calls the FormsAuthentication.RedirectFromLoginPage method. So that user does not have to re-enter the credentials.

 

Problem comes up when the user clicks the “Sign Out” or “Sign in as a Different User” links and redirected to the login page. When the user is redirected to the login page, it detects the RSA authentication cookie still exists and logs the user back in.

 

So all we need is to remove the RSA cookie somehow before they redirected to login page.

 

One solution (work-around) for this issue I found is by using HTTP Module.

 

Whenever you do a logout or sign as a different user, SharePoint takes you to these 2 pages:

 

/_layouts/SignOut.aspx

 

And

/_layouts/AccessDenied.aspx

 

Now I have created a HTTP Module to handle it. The code goes like:

 

using System;

using System.Web;

using System.Web.UI;

using System.IO;

 

public class LogoutModule : IHttpModule

{

    public void Init(HttpApplication app)

    {

        app.PreRequestHandlerExecute += new EventHandler(app_PreRequestHandlerExecute);

    }

    void app_PreRequestHandlerExecute(object sender, EventArgs e)

    {

       

        HttpContext context = HttpContext.Current;

        if (context.Request.Path.Contains("/_layouts/SignOut.aspx") || context.Request.Path.Contains("/_layouts/AccessDenied.aspx"))

        {

            // Code to remove RSA cookie goes here

        }

    }

   

    public void Dispose()

    {

    }

}

 

There could be better and easier solution for this. Please let me know your ideas.

 

Update Note: There is minor modification in the code above, thanks to Andy Spears

 

//see if the user clicked the "Sign in as a different user" or "Sign Out" menu options

if ( context.Request.Url.PathAndQuery.ToLower( ).Contains( "/_layouts/accessdenied.aspx?loginasanotheruser=true" ) || context.Request.Path.ToLower( ).Contains( "/_layouts/signout.aspx" ) )

{

// Code to remove RSA cookie goes here

 

}

 

I had to look for the “loginasanotheruser” url parameter, otherwise whenever a user accessed a page they didn’t have permissions on, they would be logged out.

Posted: Thursday, December 13, 2007 8:47 PM by pranab

Comments

Maria Joseph said:

HI,

I have one doubt about http module. I want to create one http module for my sharepoint site, then how can we implement the functionality in our sharepoint site

Thanks

Maria

# December 14, 2007 12:02 AM

Pranab Paul's Blog - SharePoint 2007 (MOSS/WSS 3.0) Development Tips said:

SharePoint 2007 (MOSS/WSS) FBA and RSA Unanswered Questions Since my last post Using HTTP Module for

# February 7, 2008 1:47 PM

Noticias externas said:

Since my last post Using HTTP Module for SharePoint 2007 (MOSS/WSS) site using FBA And RSA , I received

# February 7, 2008 2:39 PM

DTDweller said:

Great solution!  My problem is slightly different.  I get a 403 Forbidden when selecting Sign Out.  The Url for SignOut.aspx includes the workspace address within the Site Collection, a location which requires authentication to access.  If I remove the workspace portion of the Url such that the Url now points to the root the page loads properly.  Thus, I am thinking that the best solution might be to use the HttpModule to redirect the page.  Is this the best/easiest way to solve the problem?  If so, do you have an example of what the redirect code might look like?

Many, many thanks.

Doug

# May 20, 2009 12:18 PM

Etienne said:

Hi there,

Since 2009, RSA provide some "RSA Solution for SharePoint".

http://www.rsa.com/sharepoint

This supposed to include the RSA SecurID authentication method through SharePoint.

Even though there is still no usefull information on how to do that.

RSA is pretty much easy to integrate with ISA 2006.

But there is no walkthrough to forward the authentication to the sharepoint website using the ISA publication rule and no SharePoint FBA but just Windows authentication.

Anyone does have any update on this ?

Regards,

Etienne.

# June 2, 2009 12:11 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker