While I was experimenting with Forms Based Authentication for SharePoint 2010 I found that 2010 is still missing any user administration tools for FBA users. For SharePoint 2007 there is a project on CodePlex (http://fba.codeplex.com/) that is a good starting point for site level admin tools. The only problem is that as-is it will not work for SharePoint 2010.
This project turned out to be a good demo of what you may need to do to convert code from 2007 to 2010.
The key conversion steps:
- Update the referenced DLL from the 22.214.171.124 version to the 126.96.36.199 version of Windows.SharePoint assembly.
- Update the references in all of the ASPX pages from 188.8.131.52 to 184.108.40.206
- Replace the master page used in the ASPX files with the 2010 applicationV4.master.
- Set Visual Studio to compile the project using Framework 3.5 (2007 used 2.0, or 3.0 for workflow work) and compile the code. Make sure you target 64 Bit or “Any CPU”!
- Edit the files used to create the WSP (the CAB file)
- Edit the files used to deploy (to the 14 directories instead of the 12 directories)
- First setup a SharePoint 2010 application for FBA.
One way: http://techtrainingnotes.blogspot.com/2010/01/sharepoint-2010-forms-based.html
You will need to setup both the membership and the role providers to support the codeplex project.
Also, edit the XML for the membership provider and set requiresQuestionAndAnswer="false" as the codeplex project does not support that feature.
- Go to http://fba.codeplex.com/, click the Source Code tab and on the right under “Latest Version” click Download (confirm that you have found a ZIP file and not a WSP file)
- Extract the ZIP file. You should get a folder named FBABasic that contains the project
- Open the project in Visual Studio 2010 and let it do the project conversion (and let it remove the source “control bindings”)
(You could use VS 2005, VS 2008 or even Notepad if you wanted to)
- Change the Target Framework from 2.0 to 3.5 - Click the Project menu and select Properties
(Studio will have to close and reopen the project)
- In the Solution Explorer remove the Microsoft.SharePoint reference (this is for the 12 version)
- Add a reference to Microsoft.SharePoint 220.127.116.11 (was listed as Windows SharePoint Services in the 12 version)
- Do a Find and Replace through all of the ASPX files and change 18.104.22.168 to 22.214.171.124
(I found 5 per page, 35 total.)
- Do another Find and Replace through all of the ASPX files and change “application.master” to “applicationV4.master” to add the 2010 look and feel to the page.
- Edit the Deploy.cmd, DevDeploy and UnDeploy.cmd files and make two changes:
- Change the path from \12\ to \14\
- Change the sample URLs (“http://wssdev”) to your FBA test application (Mine was http://maxsp2010beta2:85)
- The project has two post build events.
Note: I personally don’t like to use Build Actions as you can’t see if they succeed or fail. Instead I manually run package.cmd and deploy.cmd in a command window so can see all of the messages.
- Package.cmd creates the CAB/WSP file and needs MAKECAB.exe to run. Find makecab.exe (C:\Windows\System32\makecab.exe) and either copy it to the project directory or edit Package.cmd and add the path for makecab.exe.
- Deploy you have already edited, but check it again.
- Make sure you are targeting “Any CPU” (or x64) and then build the application.
- If you are not using the post-build events then manually run package.cmd and deploy.cmd.
Don’t be concerned if the first run of the deploy.cmd file displays a lot of errors as it is trying to retract a solution that has not been deployed yet
- Launch your FBA test site, login and then go to Site Actions, Site Settings and see if “Manage FBA Users” and “Manage FBA Roles” is there.
Note that you will either get errors, or find no users, if you try to access these pages from the Windows Authenticated application.
- Test, test, test…
Things to do…
- Add error handling
- Add support for “requiresQuestionAndAnswer” and other Membership provider features
- Add detection for when the pages are displayed in a Windows Authenticated application.