Friday, May 29, 2009

Form Based Authentication (FBA) in Sharepoint

The default authentication in sharepoint is Active Directory. In cases when you have a internet portal where your user is mainly from internet, you might consider to use Form based authentication. This is not an uncommon scenario.



The good news is, it is possible to leverage on the existing ASP.NET Membership provider in .net framework 2.0 onwards. The next question will be HOW TO do it ...



1. Create membership provider database by executing [aspnet_regsql.exe] from [C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727]



2. Give a name for the database, it is always better not to use the default name to avoid conflict of database, and continue the wizards to create the tables, stored procedures needed for membership providers



3. After you created the database, you need to add your first user. There are two ways:

a. Execute



declare @now datetimeset

@now= GETDATE()

exec aspnet_Membership_CreateUser '/', 'userlogin','password','','email@somewhere.com','','',1,@now,@now,0,0,null



b. Use VS to modify the ASP.NET Web configuration


4. Append three sections in web application web.config

<>

< name=" FBAConnectionString " connectionstring=" Data Source=.;Initial Catalog= MOSS_FBA;Integrated Security=True ">

< / connectionStrings >

< defaultprovider= " FBAMember ">

<>

< connectionstringname= " FBAConnectionString " enablepasswordretrieval=" false " enablepasswordreset=" true ">

requiresQuestionAndAnswer=" false "

applicationName="/"

requiresUniqueEmail="false"

passwordFormat=" Hashed "

maxInvalidPasswordAttempts="5"

minRequiredPasswordLength="1"

minRequiredNonalphanumericCharacters="0"

passwordAttemptWindow="10"

passwordStrengthRegularExpression=""

name="FBAMember" type="System.Web.Security.SqlMembershipProvider,System.Web,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" /> < / providers >< / membership >


< mode=" Forms ">

< / authentication >

<> <> < key="FBAMember" value="%"> < / PeoplePickerWildcards >


5. Make the same changes in web.config for central admin

6. Central Admin --> Application Management --> Site Collection Owner, Add the user that you created in step 3

7. Central Admin --> Application Management --> Authentication Providers , you should see two entry. Click on the default zone.

8. Change the authentication to 'FORM' and update the Membership provider name:
9. You should be able to login now.

Wednesday, May 27, 2009

Sharepoint 2007 Boundaries (limitation)

It is always important to understand the limitation or boundary of the system. For example, you cant be creating item in the list without any limit.

Check it out from here

It provides you a better idea on how to plan your system

Sunday, May 24, 2009

Sharepoint content publishing

One of the key feature in sharepoint is about content publishing, which means it provides you the flexibility to separate authoring and publishing environment.

Then you may ask one question. HOW TO DO IT !!!

It is very simple, just follow the steps below:

On Target
1. Create a new web application in target.
2. Create a empty site, preferably using
stsadm -o createsite -url http://targetSiteUrl/ -ownerlogin yrLogin -owneremail yrEmail
--If you dont use blank site, you are expected to see error
3. Then you should go to central admin --> Operation --> Content Deployment Settings to turn on "Accept incoming content deployment jobs"

On Source
1. Go to central admin --> Operation --> Content Deployment Paths and jobs
2. Create new path
3. Create new job
4. Execute the job

One very important notes !!!
If you have feature deployed on the source, MAKE SURE YOU HAVE IT INSTALL IN TARGET AS WELL before the deployment started.

Some basic readings that you might want to start off before you perform publishing deployment
1. Basic Idea
2. Basic Walkthrough
3. Pre-deployment
4. Best Practice

Friday, May 22, 2009

Sharepoint Timer Error

After you deploy the solution file and when you try to deploy the solution, you see the following error message.

You should check your [Windows Sharepoint Service Administration] if it is activated. !!! After you activated the service, make sure you run the command below to execute the timer job directly instead of wasting your time to wait for sharepoint to pick up the job.

STSADM –O execadmsvcjobs

The timer job for this operation has been created, but it will fail because the administrative service for this server is not enabled. If the timer job is scheduled to run at a later time, you can run the jobs all at once using stsadm.exe -o execadmsvcjobs. To avoid this problem in the future, enable the Windows SharePoint Services administrative service, or run your operation through the STSADM.exe command line utility

Wednesday, May 20, 2009

List Deleting event

Surprise to see this, but I'm going to disappoint you. Sharepoint does not provide any list deleting event. In fact, there is no event for list creation, deletion events.

One possible workaround that i found from sharepointking is to make use of itemDeleting events.

When list is deleted, itemDeleting event will be triggered. And the ListItem id will be 0.

Monday, May 18, 2009

How to activate a feature when site is created

If you have a feature that can only be activated in web level and you need the feature to be activated when the site is created, then you might need to read the following.

The key word is feature stapler, which allows you to tight a feature that you need to activate to a site template.

In summary,
1. you create a new feature that set the scope to "farm" level
2. in the element.xml, you create


FeatureSiteTemplateAssociation Id="2B3451F0-BC93-41A4-9FAD-3A81861D651A" TemplateName="STS#0"/
2B3451F0-BC93-41A4-9FAD-3A81861D651A : feature to be activated when site is created
STS#0 : STS is the template name, and 0 is the configuration ID in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\XML

Refer to http://sharepointmagazine.net/technical/development/introduction-to-sharepoint-feature-stapling-part-1

Saturday, May 16, 2009

How to change the bloodly PAGES when you create publishing page in page library

If you realize when you use page content type, regardless of where the document library is location, the path is always pointing to PAGES folder, it makes your path become very ugly in the URL..

www.yoursite.com/site1/pages/myPage.aspx
www.yoursite.com/site1/pages/myPage2.aspx

Below article highlights on how to customize this behaviour. Instead of using the default createPage.aspx, we will change it to something else. And make modification from there.

Before you start, one point to take note, YOU MUST ADD THE FOLLOWING NAMESPACE IN THE NEW PAGE ELSE YOU WILL SPEND HOUR ON DEBUGGING

Import Namespace="Microsoft.SharePoint.Publishing"


<%@ Import Namespace="Microsoft.SharePoint.Publishing" %>

http://blogs.msdn.com/syedi/archive/2008/07/18/why-should-one-save-publishing-pages-in-pages-list-always-in-moss-bend-it.aspx