Monday, June 9, 2008

In FBA When I open document from Document Library Login Page Display in document itself.

Hi,
some time you may come accross the situation when you are using Form Base Authentication(FBA) and after Login when you open document from document library document itself open login page inside.
Problem is because of IE (internet explorer) when you login using form base authentication cookie is saved inside browser not on your machine.so that cookie is not available to your document which open outside browser.
To overcome this problem save cookie on your machine. or persist
In FireFox it will not happen.

8 comments:

Anonymous said...

How is it possible to save a cookie on the machine?

An on word for Firefox users: When using Firefox, you can have Office Integration at all.

Regards, David

Jayesh Prajapati said...

Hi David,
Here is solution.
Make entry in web.config
authentication mode="Forms"
forms loginUrl="/_layouts/xyzLogin.aspx" timeout="30" slidingExpiration="true" cookieless="UseCookies"


Case 1.
when you are using Default login page provided by wss 3.o i.e. Login.aspx in this case you should make sure that Sign me automatically is checked. it will store cookie on machine.
follow this link to do this.
http://www.eggheadcafe.com/software/aspnet/31773546/fba-login-form-customizat.aspx

Case 2.
when you are using your own custom login page in this case you need to persist your cookie through code.

FormsAuthentication.SetAuthCookie(LogiIn.UserName, true);

on above method second parameter is for persist cookie.

hope it will work for you..
and your second question is For FireFox see For office integration Internet Explorer use ActiveX that are by default not in Add-ons in FireFox. you can check this Add-Ons in Internet Explorer From Tools->Manage Add-Ons.

Let me know your review.

Jayesh Prajapati said...

case 1: Link is
http://www.eggheadcafe.com/
software/aspnet/31773546/fba-login-form-customizat.aspx

Jayesh Prajapati said...

Case 2: If you are using your own Custom login page and ASP.NET 2.0 Login control. Then use the following code for Login Control OnAuthenticated Event.

protected void Authenticate(object sender, AuthenticateEventArgs e)
{
try
{
if (Membership.Provider.ValidateUser
(LogiIn.UserName, LogiIn.Password))
{
FormsAuthentication.SetAuthCookie
(LogiIn.UserName, true);
Response.Redirect("~/Default.aspx");
}

}
catch (Exception ex)
{
throw (new Exception(ex.Message));
}
}

Anonymous said...

Thanks..the same bug for me in WSS 3.0 and win 2008 server (FBA) and it is fixed..

- sivabalan11@hotmail.com

Indrajeet Kumpavat said...

I am using custom login page and i am facing the same issue for opening the document.

I have update my web.config file as well as custom login page.

Although i am not able to open document from browser.

What else i can try out?

Please advise.

Thanks,
indrajeet.

Anonymous said...

Hi..

Thanks a lot for such a great help.

It works on my site. I am able to open documents now.

Although i am facing one issue with ANONYMOUS ACCESS.

PROBLEM is like this:

I have given anonymous view access to a document library.
When i try to open document from this document library, it succeed to open document.
But before openning the document it shows me my custom SIGN IN page.
After ignoring that sign in page i am able to see the document.

Can you please suggest me that what could be the reason for the same and how to fix it?

Anonymous said...

Thank you so much for this article. I had this problem and this fixed it right away!




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com