Transfer Users from one SQL Server to another including SID’s the easy way

Before I wrote an article regarding this one but it seem that was the hard way of doing it.  See the article here http://anyrest.wordpress.com/2012/10/11/how-to-synchronize-loginsusers-between-mirrored-servers/ , but recently I was playing with SSIS in Visual Studio and found out that there is an easy way of doing it without complicated scripting and can all be achieved in a matter of 4 easy steps.

This will be really helpful for those Mirroring a lot of databases and synchronizing their users down to SID’s and permissions.  For this to happen you need Visual Studio with Business Intelligence Project Templates attached to it.  Let’s start.

1. Create an Integration Services project 

1 New Project

2. Use the Transfer Login task

2 Transfer Login Task

3. Setup your Connection

3 Connection

4 Connection Properties

4. Set up the Transfer task properties

In this section you since you are mirroring the users credentials from the database its best to use only “AllLoginsFromSelectedDatabases” and choose the databases you need to copy the logins from.

For Mirroring it is important to set “CopySid” to “true” so your application will run seamless without encountering an access denied issue as it will copy the users exactly how it is on the main SQL Server

5 Transfer Properties

see its really easy, why haven’t I used it like this before

Migrate Team Foundation Server’s SQL Server to another SQL Server (same or new version)

Yesterday we migrated SharePoint’s SQL Server to a new instance today we will be migrating Team Foundation Server (TFS) SQL database to new SQL instance.
In this example we are migrating it to a new version of SQL Server which is from SQL 2008 R2 to SQL 2012, this will also work on the same SQL version.

What we had done here is a very simple step by step instructions and this is what I’ve done with our live environment. I only migrated the Project Collection and Configuration Database so if you have the same scenario you can follow this with care of course. So let’s start.

Moving TFS Project Collections

1. Detach Project Collection

1 Detach Project Collection

Go to Team Foundation Server Administration Console -> Application Tier -> Team Project Collections then choose the collection you want to migrate. Once chosen choose detach then click next on each following step to confirm.

Once finished you will see a Window similar to this, click Complete then close.

1b Detach Project Collection

2. Detach you TFS_Configuration Database in SQL Server

2 Detach SQL Server Instance

3. Copy the Database Related Files

Copy all database related files (.mdf, .ldf) to the New SQL Server

3 Copy Detached Database Files to New SQL Server

4. Attach the Database in the new SQL Server

4 Attach Database

5. Attach Project Collection

Go to Team Foundation Server Administration Console -> Application Tier -> Team Project Collections then choose Attach Collection.

5 Attach Project Collection

5b Attach Project Collection

Once finished you will see a Window similar to this, click Complete then close.

5c Attach Project Collection

At this stage try doing a check in and check out to see if everthing worked, compare file history as well to double check

Moving TFS Configuration Database

1. Stop IIS on TFS Server

Using the Admin context execute “iisreset /stop” at the command prompt.

If you can’t stop IIS there is another alternative. Just stop the TFS related sites and application pool in the Server

Stop TFS Website on Server

1 Stop TFS Website

Stop Application Pools, those two highlighted in the screenshot below

2 Stop TFS Application Pools

2. Stop TFS Job Agent service

You can stop this via services.msc or execute “net stop TfsJobAgent” at the command prompt.

3 Stop TFS Services

3. Detach the Tfs_Configuration database

Do it similarly with the step 2 on migrating the project collection

4. Attach the Tfs_Configuration to the new SQL Server instance

5. Prepare new SQL for TFS instance

Using Admin context open again Command Prompt if you had closed it then navigate to “C:\Program Files\Microsoft Team Foundation Server 2010\Tools”
Execute “TfsConfig prepSql /sqlInstance:{your_new_server_name_here}”

3 Prepare SQL Server for TFS

6. Register new SQL for TFS instance

In the same command prompt instance Execute “TfsConfig registerDb /sqlInstance:{your_new_server_name_here} /databaseName:Tfs_Configuration”

4 Register SQL Server instance for TFS

7. Reapply Service Account

Go to Team Foundation Server Administration Console -> Application Tier then click on Reapply Account.
Select the account you use then click OK

5 Reapply Account

 

If successful you will see something like this

5 Reapply Account Message

8. Start the TFS Job Agent service

Start the TFS Job Agent service via services.msc or execute “net start TfsJobAgent” at the command prompt.

9. Start IIS on TFS Server

Using the Admin context execute “iisreset /start” at the command prompt.
If earlier you just stopped the TFS related sites and application pool just run it all back again.

You have now successfully migrated your database.

Migrate SharePoint’s SQL Server to another SQL Server (same or new version)

This is a step by step guide on how you migrate your SharePoint’s (I used 2010 version in this instance) SQL Server to an new SQL Server host.  In this exercise I tried migrating it in a new version of SQL server which is 2012 from 2008 R2, also had tried it in the same version.  There are only 9 steps to perform this task but it takes into consideration you already have a new SQL Server provisioned.

Lets start

1. Stop all SharePoint and IIS Related Services

  • SharePoint 2010 Administration
  • SharePoint 2010 Timer
  • SharePoint 2010 Tracing
  • SharePoint 2010 User Code Host
  • SharePoint 2010 VSS Writer
  • SharePoint Foundation Search V4
  • World Wide Web Publishing Service
  • SharePoint Server Search 14
  • Web Analytics Data Processing Service
  • Web Analytics Web Service

1 Stop Services

2. Stop IIS
At the command prompt under admin context, type iisreset /stop

3. Detach all related SQL Server databases

  • Configuration database
  • Central Administration content database
  • Content databases
  • Service application databases

i.e.
Bdc_Service_DB_xxxxxxxxxxxxxx
SharePoint_AdminContent_xxxxxxxxxxxxx
SharePoint_Config
WSS_Content
WSS_Logging
WSS_Search_xxxxxxxxxxxxxx

2 Detach Database

4. Move all database files (.mdf, .ldf, and .ndf) to the new server.

Place it in the data folder of the SQL Server instance of the new host.

3-copy-database-files

5. Set up same user permissions on the new SQL server

best way to do this is when you use AD accounts is by scripting the users on the old server and running that script on the new server. If you are not using AD accounts then you will have issues with passwords so best way to do that is to follow this -> http://support.microsoft.com/kb/918992

6. Attach your databases to the new SQL Server

4 Attach Database

5 Attach Database 2

7. Verify what ports your New SQL is using

If it’s using a dynamic port change it to static. To do this go to SQL Server Configuration Manager and into the SQL Server Network Configuration Section choose the instance you will be using. Go to the TCP/IP section and if TCP Dynamic Ports are set to 0 (zero) then remove that and assign a static port into the TCP Port Section on all IP’s. For this sample we will be using 14330 <- notice I just added 0 at the end from the default port. Note that as we will need that on the next section also if you changed the port number from dynamic to static you will need to restart your SQL Server before it can take effect.

6 Port Allocation

8. Go to your SharePoint server and create your SQL Server Alias

If SQL Configuration Manager is installed just head over to the SQL Native Client 10.0 configuration then into Aliases. Create a new alias that points to your new SQL Server by right clicking on the Alias. You need to do this on both 32 and 64 bit instances.

7 Alias Configuration

  • On the Alias name put your old SQL Server IP or Name
  • On the Port the port you indicated on step 7, in this case 14330
  • Protocol should be TCP/IP
  • And on Server the new SQL Server IP or Name together with its instance name if there is any. In our case it’s SQL2012

7 Alias Configuration 2

If you don’t have SQL Configuration Manager in your SharePoint Server then run the CLICONFIG again on both 32 and 64 bit instances. For 32 bit go to run command and execute this “%SystemRoot%/SysWow64/CliConfg.exe” and for 64 just this “CLICONFG” all without quotes of course. Add the same info as above.

7 Alias Configuration b

9. Start all your SharePoint services, now you have successfully migrated your database.  

  • SharePoint 2010 Administration
  • SharePoint 2010 Timer
  • SharePoint 2010 Tracing
  • SharePoint 2010 User Code Host
  • SharePoint 2010 VSS Writer
  • SharePoint Foundation Search V4
  • World Wide Web Publishing Service
  • SharePoint Server Search 14
  • Web Analytics Data Processing Service
  • Web Analytics Web Service

At the command prompt under admin context, type iisreset /start.

How to create an Editable Sharepoint Datasheet View with Content Approval Turned on

Have you tried creating a Datasheet view in Sharepoint then suddenly found out that you can’t edit it even it says “View data in an editable spreadsheet format that is convenient for bulk editing and quick customization”?

Well don’t worry you are not crazy it really works like that when Content Approval turned on in the list.

While a lot of sites out there suggest that you to turn it off and states that “The Datasheet View control does not support making edits to lists that have Content Approval turned on” well that’s not quite correct.  This is even listed on Microsoft Support at http://support.microsoft.com/kb/2274841

Though the solution given by those sites work, it will turn of the functionality that you placed in the first place “the Content Approval”.

Now what I will show you is a solution that will work even with Content Approval turned on as the current solutions out there is not good enough specially when you really have a reason to turn on the Content Approval and want a bulk editing mode, I am not sure though whether this is the best practice but it works.  You don’t need programming in this solution and its simple.  Lets start.

What you need is the Sharepoint Designer, you can download it here http://sharepoint.microsoft.com/en-us/product/related-technologies/pages/sharepoint-designer.aspx.  Once downloaded open the site where the list you want to create a view on is located.

Once in the site structure, go to All Files -> List -> Your List (in our example it is called “Some List”) -> then you will see an aspx file called mod-view.aspx.  Copy, Paste and Rename it to what you want.  That file is used as a template for Approve/reject items if you are wondering.

I will call mine “Editable Grid View Working” that’s all you need in Sharepoint designer.  Now go to your list’s default view.  Go to your copied aspx file manually by your web browsers URL. i.e http://yoursharepoint.com/yoursite/List/yourlist/yourcopiedfile.aspx) <- Change the red ones

Once there choose Modify View

Rename the view, it will have the Name property of the Old one, in this example we named it as “Editable Grid View Working” similar to its aspx filename.  Then choose any setting that you want.

Click OK then you can see the new view now

Go to the Datasheet View and Presto! You can now edit in the grid view with Content Approval on.

Now you might be wondering why don’t we just create it from Web UI using the “Start from an existing view” method.  Well that would not work as I had tried that option as well.

Notes:

1. You need to give the user permission to approve and reject items so that they can edit it.
2. I only tried this on Sharepoint 2010 Foundation

Moving a Sharepoint Sub Site to its own Site Collection in 3 easy steps

Moving a Sharepoint Sub Site to its own Site Collection why should I do that?  Well there might be a lot of reasons on doing this but for me its more handing over the Site collection Administration to the business which enables business owners to choose themes, manage security within the site collection, manage activated solutions and deploy other customizations.  Another good reason for me is about Quota Management which I can’t do in a Sub Site model.  How about you whats you reason?

So whatever your reason is I guess you either want to do it or thought of doing it that is why you are reading this article.  So let’s get started and perform that 3 easy steps in moving your Sub Site in its own Site Collection.

On this demo we will be moving a Sub Site called “Sandbox” which is located in http://someURL/SomeTeamSite/sandbox


Step 1: Export your subsite by using the Export-SPWeb command.

You can do this on your Sharepoint Server and run the command using the SharePoint 2010 Management Shell.  For this sample I had used the following command

Export-SPWeb -Identity "http://someURL/SomeTeamSite/sandbox/" -Path "C:\Exported Sub Site\SandboxSubsSite.cmp" -IncludeUserSecurity -IncludeVersions all

What that command does is basically export the sub site to a .cmp file where we included all Security Settings and Versions for more options check out Export-SPWeb on TechNet

You will notice once it exports you will have a log file showing you whats been done during the export process.

Step 2: Create you site collection.  This is where you will host your new site.  

Still on the Sharepoint Server (you can also do this remotely), go to “SharePoint 2010 Central Administration” then into “Application Management” then “Site Collections” then “Create a Site Collection”.

Indicate all of the properties needed

Take note you can also create managed paths, which means you can create a site at a specific path. To do that click on “Define Manage Paths” under the “Web Site Address”.

Once everything is set up properly you will receive a confirmation that your site collection was created.

Step 3: Import your Content Migration Package (CMP) file that you exported using Import-SPWeb.

Still in the Sharepoint Server using the SharePoint 2010 Management Shell issue the Import-SPWeb command, for this sample it would be something like this

Import-SPWeb "http://someURL/sites/Sandbox" –Path "C:\Exported Sub Site\SandboxSubsSite.cmp"

Like Export-SPWeb the Import-SPWeb can have several parameters which you can see on TechNet

It will also create an Import log and once the import finishes your all good to go.

Now check your new site collection and compare to the sub site, and if your happy feel free to remove the subsite.

Follow

Get every new post delivered to your Inbox.

Join 773 other followers