This project has moved. For the latest updates, please go here.

Transfer 3000 + users from old website database into SharePoint 2010 FBA configured site

Jan 21, 2013 at 10:25 PM
Edited Jan 21, 2013 at 10:30 PM

Is there any way to mass import users from an old website database into a newly created SharePoint 2010 website configured with FBA and the FBA Pack has also been installed on it.

There are about 3000+ users from the old website.

There is no way I would be able to individually enter each user into the new site manually.

How would I be able to get those users and their info (email, etc.) into the FBA configured (FBAPack installed as well) SharePoint site.

Is there some PowerShell command that can help with this? Or am i looking at programming in C#?

Any advice / help is greatly appreciated.

Thank you.

Coordinator
Jan 21, 2013 at 10:39 PM

So you want to import the users from a SharePoint Site Collection, to a different SharePoint Site Collection?

You can do this with PowerShell - i've done similar things for clients before - adding users from other sites or from excel/csv spreadsheets.  Unfortunately I don't believe there's just a single command that will do this for you - you'll have to put a script together yourself - loop through the source list of users - read their values and then add them to the target list.  Here's a script for deleting users - adding users would be similar:

http://blogs.visigo.com/chriscoulson/bulk-delete-sharepoint-site-users-with-powershell/

 

Jan 21, 2013 at 11:00 PM

Thank you for the very quick response.

I will attempt this and see what happens. Currently I was able to query the old database and copy the user information into an excel file.

Now I just need to somehow enter that into the new SharePoint site.

Thank you.

Jan 29, 2013 at 6:24 PM

Hi ccoulson,

I was able to add uses into my SharePoint Site from a csv file, thanks to a snippet of code from this site [http://social.msdn.microsoft.com/Forums/eu/sharepointdevelopment/thread/86d20692-e53c-4e48-990e-7beeb498d7e0]

[system.reflection.assembly]::LoadWithPartialName("Microsoft.Sharepoint")

#importing users from CSV file and adding each user to sharepoint site ex: http://dev:8888

$SPSite = New-Object Microsoft.SharePoint.SPSite("http://dev:8888");

$OpenWeb = $SpSite.OpenWeb();

$viewersGroup = $OpenWeb.SiteGroups | Where-Object {$_.Name -match "NewGroup3"};


            if($viewersGroup -eq $null)

            {

 

            }

            else

            {

            foreach ( $row in import-csv users.CSV | Select sAMAccountName, mail, FullName )   

                        { 
			       $viewersGroup.AddUser($row.sAMAccountName,$row.mail,$row.FullName,"");

                        } 

            }

$OpenWeb.Update();

$OpenWeb.Dispose();  

$SPSite.Dispose();

 

But this method bypasses the FBA Membership process (which is expected) and the user doesn’t show up in the ‘aspnetdb’ database.

The bulk delete option you suggested in your previous reply, also looks like it directly removes users from a certain SharePoint group.

Is there any way to actually make the users appear (using powershell) in the FBA database as well as the SharePoint (WSS_Content) database?

I was exploring your FBA Pack code and noticed that the user is actually created in your MembershipRequest.cs file.

 

In line 389 of the file,

newUser = membership.CreateUser(request.UserName, request.Password, request.UserEmail, request.PasswordQuestion, request.PasswordAnswer, true, null, out createStatus);

is where the new user appears to be created.

Would I have to use powershell to replicate this action (as well as define the variables for MembershipRequest variables)?

From what I understand,

  • ·         ‘membership’ variable is a variable of type MembershipProvider.
  • ·         ‘request’ is a variable of type MembershipRequest.

Thank you for your time. Advice is greatly appreciated.

Coordinator
Jan 29, 2013 at 6:38 PM

You could use this function in your powershell script to add the user to the membership database.  You are correct about membership and request.  For the request items, you would just use your $row values.

Do you actually have to move them/add them like this though? Is it possible to simply either tell SharePoint to use the old aspnetdb database? Or a copy of the aspnetdb database?  Then you can skip this part.