Wednesday, 30 November 2011

Configuration of Forms Based Authentication for SharePoint 2010


I have much researched about configuring Forms Based Authentication by viewing different blogs. After i succeed, i have decided to write the detailed stepts with related troubleshooting in this blog.

In this blog, you will create a SQL Server database to hold users and roles, create a SharePoint Web Application that uses FBA, configure IIS and the web.config files for the Web App, Central Admin and the Security Token Service, create a test user in the database and test your setup.

SharePoint 2010 supports FBA, Like WSS 3.0 or MOSS 2007. It's a feature of ASP .Net which we use with SharePoint. SharePoint 2010 you can create web applications using Classic Based Authentication or Claims based Authentication. 
However, FBA can only be configured with web applications created using Claims Based Authentication.

Differences between Classic Mode Authentication and Claims based Authentication ?

Classic Mode Authentication: It refers to the integrated windows authentication. You cannot configure the Forms based authentication 
If your web application is using Classic Mode Authentication. You can convert a web application from Classic Mode Authentication to Claims Based Authentication. However, that can only be done using Power Shell commands and its an irreversible process. I have detailed steps to convert the web application from Classic Mode authentication to Claims Based Authentication.

Claims Based Authentication: SharePoint 2010 is built on Windows Identity Foundation. It enables authentication from windows as well as non-windows based systems. This also provides the capability to have multiple authentication in a single URL.

Configuration of FBA with SharePoint 2010 involves 5 major steps. The steps to configure the FBA with SQL membership Provider are 

below:

1. Configure SQL for membership store
  • Create database
  • Create SQL User
  • Add SQL user to database

2. Configure Central Admin to use SQL membership store -  Modify web config file

3. Configure Secure Store Web Service to use SQL membership store - Modify web config file

4. Create new Web Application for extranet site

5. Configure Extranet site to use SQL membership store - Modify web config file

1. Configure SQL for membership store :

The membership store is still created using the ASP.NET SQL Server Setup Wizard.  This is launched from the .NET 2.0 Framework folder 

on the server at:

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regsql.exe

This wizard will take you thorough the steps and will build out the SQL database for you.



Once you select to Configure SQL Server for application services, you will be prompted for the SQL Server name and database name. You can choose an existing database to add the membership elements to, or you can type in a new name and the database will be created for you.

Once the database is created, we’re going to create and add a SQL user, rather than use integrated authentication.
 If your SQL instance is not already running in mixed-mode, you can change it through Server properties in SQL Server Management Studio.  Right-click on Server in Object Explorer and select Properties, then navigate to the Security page.

Create SQL User :
In this case, we’ll be using SQL Server authentication. So create a new Login on the SQL Server. From SQL Server Management Studio, use the Object Explorer to navigate to the Security → Logins folder. Right click on the Logins folder to open the context menu and choose the menu item New Login…
This will open the Login – New dialog. Here, you specify a Login name, i.e. FBAService and a SQL Server authentication password, i.e. pwd. You can set your membership provider database as the Default database. Click OK to add the user. It will now show up in the list of logins.




To give the login access to the database, locate the database in the Object Explorer, under the Databases folder and expand the folder Security. Open the context menu from the Users folder and choose the option New User…

This opens the Database User – New dialog.

In this dialog, specify a name for the user and insert the login name that you created earlier (i.e. FBAService) in the Login name text field.

Assign the following Database roles to the user:

give the role as “db_owner”.
Click the OK button to add the user to the database.



To recap:

We created a database called aspnetdb.
We created a SQL user called FBAUser
We added FBAUser to aspnetdb database and gave them the db_owner role.
We’re done with SQL.

2. Configure Central Admin Web Site to use SQL Membership Provider


SharePoint web sites out of the box are configured to use Active Directory.  So you may be wondering why we’re configuring Central Admin to use FBA when we don’t really want to login in as an FBA user.  Well, we actually don’t want to configure it to login as a forms user, but we do need to be able to add users from out membership database when configuring site collection admins, and the like.

So all we want to do is tell the Central Admin web application to use our SQL membership provider as well as AD, so when you use the people picker to select users, it will provide results from our membership database.

Open IIS Manager on the WFE server (if more than one, then this needs to be done on every FWE that has Central Admin.  The same goes for the proceeding steps for the other web applications).

Select the SharePoint Central Administration v4 site.  On the Home Page, you’ll see many options for ASP.NET and IIS.  The ones we’re concerned with are

Open the Connection Strings Page.  Under Actions menu on the right, select Add… to create a new connection string.  Provide the details for the membership database for the new connection string.
In the web.config, you’ll see sections for the connection string. You should also see a <connectionStrings> section close to the bottom of the web.config file. like as below


Add Role Provider:

Go back to the Web Application page and open up Providers page.  Here we will create a provider for Roles and Users. In top most left Set feature to .NET Roles and click Add… in the Actions pane to add a new role provider.  I called it FBARoleProvider and selected the right type and connection string.

Ensure you provide an ApplicationName so the provider knows what uses to authenticate.  For a good explanation on why you need this, see Scott Guthrie’s blog.



Add Membership Provider:

Now set feature to .NET Users and click Add… from the actions pane to add a membership provider.

Select the correct type and connection string, and whatever behaviors you choose.
That’s it for the providers for Central Admin.
To verify that all looks ok, we can check the web.config of the web application.  To get to the right web.config, right-click on the web application(Central Administration) under sites, and select Explore.

In the web.config, you’ll see sections for the connection string. You should see a <roleManager> and <membership> section of the web.config file. like as below

3. Configure Secure Store Web Service to use SQL Membership Provider

Everything we did for Central Admin site, we are going to do for the SecurityTokenServiceAppliaation which is in the SharePoint Web Services application.

do Same as what we did for Central administration site

Create the connection string
Add the .NET role provider
Add the .NET users provider
Verify connection by editing config.xml.



In the web.config, you’ll see sections for the connection string and the providers.  The <connectionStrings> <roleManager> and <membership> sections should look like:


4. Create Extranet Web Application

Finally we are ready to create our web application (called SharePoint – FBA) that will use FBA authentication.

In Central Admin, Select the Application Management page, and select Manage web applications.  Select New from the ribbon to create a new web application.
Select Claims Based Mode Authentication as Authentication Type.  Select values for all the other options until you get to the “Enable Forms Based Authentication”.

Add the values we created earlier in the section “Enable Forms Based Authentication” for role - FBARoleProvider and membership provider - FBAMembershipProvider.

Once the application is created, we should create a site collection.


Create Site Collection

Go to the Create Site Collection page from the Manage Applications section in Central Admin.  Select the team (or blank, or whichever you choose) template then select the site collection administrator. 


Configure Membership Providers for Web App through IIS

In IIS Manager, browse to the new site SharePoint – FBA. For our new FBA site we need to do the following:
Again same what we did before

  • Add connection string
  • Add Providers for members and roles
  • Configure .NET Roles
  • Configure .NET Users
  • Set Authentication to Forms and Integrated
  • Add User as Site Collection Admin



1. 1. Add Connection String     -   Same as we have done before.

2. Add role and user providers -   Again, same as what we did before.  Open Providers page and add an entry for our role and user providers.

3. Configure .NET Roles
This and the next steps are not required for the other two web applications we configured (Central Admin and SSS).
Open the .NET Roles page for our web application.  You will receive a warning that the default role provider is not trusted.

This and the next steps are not required for the other two web applications we configured (Central Admin and SSS).

Open the .NET Roles page for our web application. You will receive a warning that the default role provider is not trusted. WE just need to set our default role provider from 'C' to 'FBARoleProvider'


We do not have any roles in our database at this point, so let’s create two (StandardUser, SuperUser) by clicking Add… in the actions pane.






4. Configure .NET Users
Assuming you don’t let’s add some. Click Add… from the Actions pane to add users, and assign them roles.

Now we need to do the same for .NET Users. Open the .NET Users page. You will get a similar warning saying the default is not

trusted. Set the default provider to FBAMembershipProvider. If you had members in the database, you would now see them listed.



Assuming you don’t let’s add some. Click Add… from the Actions pane to add users, and assign them roles.




5. Set Authentication

SharePoint should have done this when you created the web application, but let’s confirm. From the web application home page in IIS Manager, select Authentication under the IIS section. Confirm that the web application has both Integrated and Forms enabled.


6. Add User as Site Collection Admin

Now that we have everything hopefully configured correctly, we can go back to SharePoint Central Admin and add our new FBA user as the Site Collection Administrator.  From Central Admin Application Management page, click Change site collection administrators.  Select SharePoint – FBA root site collection, and add our new user.

In order for you to use IIS Manager to manage your SQL users, you need to set the default provider to our Forms provider, i.e. FBAMembershipProvider.  In order for it to work we need to set it to the SharePoint claims provider.  Go back to .NET Users and reset the default provider from ' FBAMembershipProvider ' to ' i ' ,  and Reset the default provider from 'FBARoleProvider' to ' c '.



Monday, 28 November 2011

Compare SharePoint 2007 – SharePoint 2010 development

SharePoint 2007SharePoint 2010

ENVIRONMENT
Windows Server 2003 or
Windows Server 2008

32 bit or 64 bit

.NET 3.0 (IIS 6.0 above)

WSS 3.0

MOSS 2007
Windows Server 2008 or 2008 R2 (Production), W4indows 7 or Vista SP2 (dev)

64 bit 64 bit only

.NET 3.5 and above, IIS 7.0

SharePoint Foundation 2010 (SPF)

SharePoint Server 2010

WORKLOADS OR FUNCTIONAL AREAS

SharePoint provisioning & Collaboration lists

Wikis, blogs, user profiles, my sites














Excel Services
SQL Reporting services Performance
Point Add-On



BDC


Sites

Communities
Social networking
Enterprise metadata tagging

Content
WCM
ECM
DM
RM

Search
Built in search
FAST Search (enterprise)
FAST Search Center

Insights
Excel Services
Performance Point Services
Cohesive BI integration
Reporting

Composites
Business connectivity
services (CRUD)
External content type


IMPROVEMENTS

Visual Studio 2008 (Visual studio extensions
for wss 3.0 & codeplex utilities)

.NET Framework 3.5

stsadm command line

No LINQ support (caml support)

Full HTTP Requests (postback)





no need to write CAML queries

Workflow on lists and documents

New MOSS to access External data

SSPs



Solution Package

Visual Studio 2010 (SharePoint projects, SharePoint explorer)

.NET Framework 4.0

PowerShell scripts (stsadm backward compatibility)

WSS Integration with LINQ

Ajax requests & SilverLight support
Server-side ribbon and In-Place editing

Improvements to Lists and Events (events for child site, large lists, throttling)

New client object model

Workflows on sites

External data can be accessed with SPF

SPF support Service applications
extensible Service Application architecture,
Scalability

Sandbox Solutions and Partially trusted code,
build solution and upload to site collection

Claims based security (saml support, support Live ID)

Developer Dashboard
request run-time length
even handlers fired
sequence of event handlers

SPD improvements
SPD objects have relationships
Intuitive navigation between SPD objects
SPD work migrates to Visual Studio 2010
SPD customization work exported to .wsp
.wsp files imported into Visual Studio 2010
Reusable workflows (customization)
Site Workflows (Workflow designer)

PowerShell Support
Replaces stsadm
powerful scripts
develop custom PowerShell
snap-ins (provider-based model) Microsoft.SharePoint.PowerShell

Terminology review (still remains the same)

Farm (SPFarm)

Web Application (SPWebApplication)

Site Collection (SPSite)

SPSite (SPWeb)

List (SPList)
Item (SPListItem)

Document Library (SPDocumentLibrary)

File (SPFile)

Folder (SPFolder)

Sunday, 27 November 2011

Menimum requirements to install SharePoint 2010

Here are 10 menimum requirements to install SharePoint 2010.

Though Microsoft SharePoint 2010 provides a lot of installation schenerious, we will discuss some minimum hardware and software requirement to install SharePoint 2010.


1. The first requirement is we will need 64 bit processor not 32 bit.
2. RAM of 4GB for development use and 8 GB for production use.
3. Minimum 80GB hard disk needed.
4. Needed 64-bit edition of Microsoft SQL Server 2008 R2 (Preferable)
5. 64-bit edition of Windows Server 2008 R2 preferable
6. Microsoft .NET Framework version 3.5 SP1
7. Microsoft Chart Controls for the Microsoft .NET Framework 3.5 (You need to install this patch before SharePoint 2010 installation)
8. Windows PowerShell 2.0
9. For Windows Server 2008 R2, Windows6.1-KB979917-x64.msu patch is necessary before SharePoint 2010 installation
10. Microsoft SQL Server 2008 Native Client. This can be downloaded from http://go.microsoft.com/fwlink/p/?LinkId=166505

Saturday, 26 November 2011

How to get the assembly name of a custom web part in SharePoint 2010?

Here the way you can get the 4 part assembly name of your custom web part.

First of all add the web part to the SharePoint site by edit the page and click on the add a web part link on your web part zone. Once you will add the web part, go to Edit web part as shown in the figure below.


Then from the web part properties go to Advance and then in the Export mode Select Export all data as shown in the figure below.


Then click on OK.
After that click on Export... as shown in the figure below.

Then it will ask you to save the web part. Just save the webpart and after that open that file in notepad. It will give you everything about the webpart.

I got this information from OnlySharePoint2010

Error in SharePoint 2010 designer while saving

If you create a site page with in the site created with Teamsite template the sharepoint look and feel for that site on save,Some time you will get  this error:"Content in the embedded form may be changed by the the server to remove unsafe content.Do you want to reload your page to see the results of the save"
and when you say reload,the server removes some parts of page,
e.g onclick event of html,asp buttons.

Actually It's not an error;

It's a warning, and you'll get it on Wiki pages.  It's for security purposes specifically on Wiki pages.
After much searching i decided that the team site has a wiki page with some kind of input form in it. and sharepoint thinks you are submitting the image or content.

By creating a blank page and put the same content in the blank page, there will no problem saving or displaying.

While searching i have seen a good reply, such as below

There does seems to be something wrong with pages based off of a wiki master page. Any content I put in with Sharepoint Designer (whether editing in advanced mode or not) comes up with "Content in the embedded form field may be changed by the server to remove unsafe content. Do you want to reload your page to see the results of the save". But if I create a blank page and put the same content in the blank page, there is no problem saving or displaying.

The most frustrating thing about this is the cryptic message itself. It isn't an error, it's a warning, yet it appears to strip out work, potentially hours worth of work. Someone could have worked for 6 hours on a page and it would appear that Sharepoint Designer just wiped it all out.

Sharepoint Designer looks and feels like a well polished product, but it doesn't act like a mature product at all. If there is a problem with content like a jpg being considered unsafe, for what ever reason, the product should say more about the problem and specifically point out the items that are in question like Visual Studio would with lines of code. My wild guess at this particular issue is that is is related to some kind of controls/restrictions (perhaps unwittingly) placed on content in the placeholder(s) at the master page level. As I said, if you create a blank page and put in the same content, there is no apparent problem.

Friday, 25 November 2011

Telerik Rad Menu type is not registered as safe

To leverage RadControls for ASP.NET Ajax, some required files must be deployed to each SharePoint Web Front End (WFE) server.

Once the required files are deployed, our ASP.NET AJAX can be added to the site by editing the site’s master page(s).

This section outlines the required steps that need to be taken to deploy RadControls for ASP.NET AJAX prior to implementing it within an existing SharePoint web site.

1. First you need to install Telerik.Web.UI.dll and Telerik.Web.Design.dll in the GAC (Global Assembly Cache) of your SharePoint server. There are two ways to do this:

a. Drag and drop Telerik.Web.UI.dll and Telerik.Web.Design.dll into C:\Windows\Assembly (in Windows Explorer)

b. Open Visual Studio 2005/2008/2010 Command Prompt and run the following commands (assuming Telerik.Web.UI.dll and Telerik.Web.Design.dll are in c:\Telerik)gacutil -i c:\Telerik\Telerik.Web.UI.dll

                  gacutil -i c:\Telerik\Telerik.Web.Design.dll

By adding the Telerik controls to sharepoint site, you hould tell SharePoint that the controls from the Telerik.Web.UI.dll (and Telerik.Web.Design.dll) are safe to use.

If not we will get this below error


To do so you should add a few <SafeControl> entries within the <SafeControls> section in your IS --> SharePoint Site's web.config:

<SafeControl Assembly="Telerik.Web.UI, Version=x.x.x.x, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TypeName="*" Safe="True" />

<SafeControl Assembly="Telerik.Web.UI, Version=x.x.x.x, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.Design" TypeName="*" Safe="True" />


Note that the version of the assembly is specified in each <SafeControl> tag. If deploying a different version of RadControls for ASP.NET Ajax, ensure that the version number is correct here.

Using Telerik Ajax controls in Custom-built SharePoint 2010 Web Part

I am trying to use Telerik Ajax, which is very powerful UI component, in custom-built SharePoint 2010 Web Part.

After a few days’ try & error, finally found how to config Telerik Ajax in SharePoint 2010.
The settings below is for Telerik Ajax 2010 Q2 sp1. For other versions, the value of version number shall be changed accordingly. (Note: PublicKeyToken is always the same value of ’121fae78165ba3d4′ for all versions, so no need change)

1. First you need to install Telerik.Web.UI.dll and Telrik.Web.Design.dll in the GAC. The simplest way is to drag & drop the file to ‘windows\assembly’ folder.`


2. Next you should tell SharePoint that the controls from the Telerik.Web.UI.dll is safe to use.
To do so you should add a few <SafeControl> entries within the <SafeControls> section in your web.config:

<SafeControl Assembly=”Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ Namespace=”Telerik.Web.UI” TypeName=”*” Safe=”True” SafeAgainstScript=”False” />
<SafeControl Assembly=”Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ Namespace=”Telerik.Web.UI.Editor” TypeName=”*” Safe=”True” SafeAgainstScript=”False” />
<SafeControl Assembly=”Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ Namespace=”Telerik.Web.UI.Widgets” TypeName=”*” Safe=”True” SafeAgainstScript=”False” />
<SafeControl Assembly=”Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ Namespace=”Telerik.Web.Design” TypeName=”*” Safe=”True” SafeAgainstScript=”False” />

3. (Optional) Register  upload and compression module in SharePoint 2010 web.config file under modules tag

<modules>
<remove name=”RadUploadModule” />

<add name=”RadUploadModule” type=”Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ preCondition=”integratedMode” />

<remove name=”RadCompression” />

<add name=”RadCompression” type=”Telerik.Web.UI.RadCompression, Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ preCondition=”integratedMode” />
</modules>

4. (Optional) Register handlers in SharePoint 2010 web.config file under handlers tag

<handlers>
<add name=“ChartImage.axd_*” path=“ChartImage.axd” verb=“*” type=“Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ preCondition=“integratedMode” />

<add name=“Telerik.Web.UI.SpellCheckHandler.axd_*” path=“Telerik.Web.UI.SpellCheckHandler.axd” verb=“*” type=“Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ preCondition=“integratedMode” />

<add name=“Telerik.Web.UI.DialogHandler.aspx_*” path=“Telerik.Web.UI.DialogHandler.aspx” verb=“*” type=“Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ preCondition=“integratedMode” />

<add name=“Telerik.RadUploadProgressHandler.ashx_*” path=“Telerik.RadUploadProgressHandler.ashx” verb=“*” type=“Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI” preCondition=“integratedMode” />

<add name=“Telerik.Web.UI.WebResource.axd_*” path=“Telerik.Web.UI.WebResource.axd” verb=“*” type=“Telerik.Web.UI.WebResource, Telerik.Web.UI” preCondition=“integratedMode” />
</handlers>

5. Register ‘Telerik’ prefix

When drag Telerik Ajax component onto user control (.ascx), Visual Studio will automatically add the following to the top of ascx file:

<%@ Register assembly=”Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ namespace=”Telerik.Web.UI” tagprefix=”telerik” %>

This is recommended approach so that Visual Studio can parse the Telerik related syntax correctly.
This clause need to be manually added to master page, if we need Telerik component, such as Telerik Menu, in master page.

Alternative way is adding the clause below to SharePoint 2010 web.config file.

<pages>
<controls>
<add tagPrefix=”telerik” namespace="Telerik.Web.UI” assembly="Telerik.Web.UI, Version=2010.1.519.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4″ />
</controls>
</pages>