Nick Swan's SharePoint Blog

a day in the life of a Sharepoint and .NET guy!

My Links

News




Post Categories

Archives

Blog Stats

Blogroll

Books

VB-tech website

VB-tech work

Xbox

WSSv3, MOSS 2007 Forms Based Authentication importing users, forums and posts

I tried to think about a useful title for this that would allow people to find it via searches and the above was the best I could come up with. Things detailed below refer to both MOSS 2007 and WSS v3 but I’m only going mention WSS v3.

Basically this is a post (probably a number of a couple) to let you know what I learn from trying to move a website based of ASP.NET 2.0 membership and roles database to Windows SharePoint Services v3. This is going to be a one off move so I’m not going to make it a downloadable ‘one click’ application, but you’ll hopefully get enough of an idea that if you wanted to do the same you can do.

Luckily Forms Based Authentication for MOSS 2007/WSS v3 uses the ASP.NET 2.0 roles and membership database so moving users over isn’t too difficult from any other aspnetdb type db. The main prerequesit before you can do anything that I mention in this post is have WSSv3 up and running with Forms Based Authentication and a role defined as registeredUser. As I mentioned before you can sort this out by watching Ted Pattisons video here:

http://channel9.msdn.com/ShowPost.aspx?PostID=229709

Just a few terms to make it easier!
aspnetdb-new is going to be the aspnetdb we are going to be running WSSv3 off
aspnetdb-old is the old membership and roles db from whatever site we are looking to migrate from.

So the state we are in is aspnetdb-new has an application created in aspnet_Applications and one user record which is split across the tables aspnet_Users and aspnet_Membership. Delete the record in aspnet_Membership and aspnet_Users. Now go to aspnetdb-old and open aspnet_Applications. Copy the value from the column ApplicationId and paste it into the record in aspnet_Applications in aspnetdb-new. Now we have the applicationId that all the users in aspnetdb-old relate to, we can import these users. Do this simply by using SQL 2005 Management Studio by right clicking on a table and choosing Import/Export data depending on which way you are doing it. Once the users have been moved across you can do the same with the data from aspnet_Membership. Once that’s done you have all the information you need transfered across. Users that have been transfered across will now be able to login to the WSS v3 site with their old username and password, but they won’t actually be able to do anything. To allow them to do things there are a few extra things we need to do…

First thing is to assign all the Users we moved across to the registeredUser role. This can either be done with code run in a webpart on the WSS v3 site (more on that later), or run in a ASP.NET 2.0 website that refers to aspnetdb-new. Either way here’s the code you’ll need to execute…

MembershipUserCollection membershipCol = Membership.GetAllUsers();
foreach (MembershipUser member in membershipCol)
{
    Roles.AddUserToRole(member.UserName, "registeredUser");
}

This gets all the users in aspnetdb-new adding them to the registeredUser role.

Remember the user we deleted from aspnet_Users and aspnet_Membership earlier before moving aspnetdb-old users across? Well that user was defined as a site collection administrator in central admin for our WSS v3 site. We need to set one of our newly migrated users as the site collection administrator. Login to central admin and go to…

Application Management -> Site Collection Administrators

and pick the site collection we are dealing with. Enter a new name into the Primary site collection administrator textbox and press CTRL + K to validate the user against the membership database. Hurray, now that works go to your WSS v3 and to the login page and sign in as the user you made site collection administrator. Once logged in you should see the ‘Site Actions’ menu, go…

Site Actions –> Site Settings -> People and Groups -> Select the ‘Team site members’ group -> New -> Add User

In the Users/Groups textbox add the registeredUser role, and leave the ‘Team Site Members’ as the permission set. Click OK. Now everybody who logs into your site with a username and password you imported across will have contributor access to the site!!! :-)

 

posted on Thursday, October 05, 2006 1:45 PM

Get email alerts when this blog is updated!

Feedback

# re: WSSv3, MOSS 2007 Forms Based Authentication importing users, forums and posts 10/10/2006 4:09 PM jelena

I am getting error when open Security Tab under
Web Site Administration Tool.
-----------------------------
There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: Unable to read the security policy file for trust level 'WSS_Minimal'.
----------------------------------------
I appreciate any help.

# re: WSSv3, MOSS 2007 Forms Based Authentication importing users, forums and posts 1/23/2007 3:48 PM Ion Singh

I have add "registeredUser" to "Team Site Members" SharePoint Group. And then have set "Team Site Members" as an audience in a web part. This does not appear to work.

Does anyone have workaround for this.

Title  
Name  
Url
Comments - All Comments are moderated and will not be displayed until approved by this blog's author    
Enter the code you see: