Tuesday, 1 September 2015

Fix: Cannot use the special principal ‘sa’. Microsoft SQL Server, Error: 15405

When importing a database in your SQL instance you would find yourself with Cannot use the special principal 'sa'. Microsoft SQL Server, Error: 15405 popping out when setting the sa user as the DBO of the database. To fix this,

Open SQL Management Studio and Click New Query. Type:

USE mydatabase
 exec sp_changedbowner 'sa', 'true'



Wednesday, 5 August 2015

Getting more than 30 Days of SharePoint Usage Report Data

One of the clients that I was working with needed some extensibility to the out of the box SharePoint Usage Reports.

The data displayed on the reports didn’t meet their requirements, first, they needed to match the data with the user data in SAP in order to get the reports by Region and other parameters, and second, they needed historical data, and not only the last 30 days of information.

The first requirement was not a problem, and at the beginning we didn’t think the second would be a problem either, but oh we were wrong.

Using the out of the box usage reports provided by SharePoint was of course not even an option, we needed a way to get the data and create our own reports.

I spent some time doing research and this is what I found:
  • Using the Object Model. The SPWeb object contains the method GetUsageData(). This is the method called by the Usage Repor pages in sharePoint. It Returns a table that contains information about the usage of a Web site, based on a time interval. Unfurtunately there are only two options for the time interval, either today or last month. So, no way to get more than 30 days of information using the Object model.
  • Web Services. No web service exposes usage report data, so I thought about using owssvr.dll, but again, you can only get the last 30 days of data.

Usage Report data is stored in log files in the IIS and also in the Shared Services database, and not only for the last 30 days, but for all the time since the usage reports were activated, so how is it possible that SharePoint doesn’t have a way to expose this data? Well, that’s how the world works.

Working directly with the SharePoint Databases is not supported by Microsoft, so it seemed that my only option was to create a program to read the IIS files. Have you taken a look at those files? Well, they are quite a mess and I didn’t want to have to do anything with them. So I consulted one of my closest friends: “Reflector”, and once again he gave me the solution I was looking for :)

I found out that the PortalContext object contains a reference to the Shared Services Database through the property “AnalyticsSqlSession”, using this property you get a connection to the database without having to worry about server name, database name, etc.

Since all the usage data is stored in the Shared Services database this was definitely helpful, but let’s not forget that working directly with the databases is not supported, and although I was not accessing directly the database using SQL server, I was however connecting to it and making some queries (READ ONLY).

We presented our solution to Microsoft, and to our surprise, the solution was accepted because somehow we were using the Object Model to get the data, nice!

Having the solution and Microsoft approval, everything got easier. These are the tables in the database that are related to the usage reports:



As you can see, everything is in there! We can do the queries we want and get the data we are looking for.

Going back to the AnalyticsSqlSession property of the PortalContext object, this is how I got it:




Worked like a charm!

Wednesday, 1 July 2015

SharePoint 2010: Create new Search Services with Custom DB names Powershell

When you try to create Search services in SharePoint 2010 using the wizard, it gives you nightmare with the Database names with horrible GUIDs...

here is a simple script to ease your life:

## Parameters used

## change the variables below to your own servers and naming conventions



$databaseServerName = "shrpt-db-server"

$searchServerName = "shrpt-apps-server"

$searchSAName = "Search Service Application"

$saAppPoolName = "SharePoint Web Services Default"

$searchDBName = "Search_Services_Application_DB"



## First remove the old search

## This will require an id - namely a guid so get the service guid before doing this



$spapp = Get-SPServiceApplication -Name $searchSAName

Remove-SPServiceApplication $spapp -RemoveData



##START SEARCH

Write-Host "Creating Search Service and Proxy..."

Write-Host "  Starting Services..."

Start-SPEnterpriseSearchServiceInstance $searchServerName

Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $searchServerName



Write-Host "  Creating Search Application..."

$searchApp = New-SPEnterpriseSearchServiceApplication -Name $searchSAName -ApplicationPool $saAppPoolName -DatabaseServer $databaseServerName -DatabaseName $searchDBName

$searchInstance = Get-SPEnterpriseSearchServiceInstance $searchServerName



Write-Host "  Creating Administration Component..."

$searchApp | Get-SPEnterpriseSearchAdministrationComponent | Set-SPEnterpriseSearchAdministrationComponent -SearchServiceInstance $searchInstance



##Crawl



Write-Host "  Creating Crawl Component..."

$InitialCrawlTopology = $searchApp | Get-SPEnterpriseSearchCrawlTopology -Active

$CrawlTopology = $searchApp | New-SPEnterpriseSearchCrawlTopology

$CrawlDatabase = ([array]($searchApp | Get-SPEnterpriseSearchCrawlDatabase))[0]

$CrawlComponent = New-SPEnterpriseSearchCrawlComponent -CrawlTopology $CrawlTopology -CrawlDatabase $CrawlDatabase -SearchServiceInstance $searchInstance

$CrawlTopology | Set-SPEnterpriseSearchCrawlTopology -Active



Write-Host -ForegroundColor white "  Waiting for the old crawl topology to become inactive" -NoNewline

do {write-host -NoNewline .;Start-Sleep 6;} while ($InitialCrawlTopology.State -ne "Inactive")

$InitialCrawlTopology | Remove-SPEnterpriseSearchCrawlTopology -Confirm:$false

Write-Host  



##Query



Write-Host "  Creating Query Component..."

$InitialQueryTopology = $searchApp | Get-SPEnterpriseSearchQueryTopology -Active

$QueryTopology = $searchApp | New-SPEnterpriseSearchQueryTopology -Partitions 1

$IndexPartition= (Get-SPEnterpriseSearchIndexPartition -QueryTopology $QueryTopology)

$QueryComponent = New-SPEnterpriseSearchQuerycomponent -QueryTopology $QueryTopology -IndexPartition $IndexPartition -SearchServiceInstance $searchInstance

$PropertyDatabase = ([array]($searchApp | Get-SPEnterpriseSearchPropertyDatabase))[0]

$IndexPartition | Set-SPEnterpriseSearchIndexPartition -PropertyDatabase $PropertyDatabase

$QueryTopology | Set-SPEnterpriseSearchQueryTopology -Active

## Proxy



Write-Host "  Creating Proxy..."

$searchAppProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$searchSAName Proxy" -SearchApplication $searchSAName > $null



#####END SEARCH   

Wednesday, 3 June 2015

There was a problem retrieving data for this field. Updating values in this field is disabled temporarily. You can still update values in other fields.

While trying to update user profile of a user in SharePoint 2010 I got this error  "There was a problem retrieving data for this field. Updating values in this field is disabled temporarily. You can still update values in other fields.".





The SharePoint farm was using cross-farm services. The "Managed Metadata Web Service" was shared between the farms. This issue can be resolved by enabling "This service application is the default storage location for Keywords." option for the "Managed Metadata Web Service Proxy".



Wednesday, 6 May 2015

SharePoint Excel Serivces Error

So if you have seen this error:

Excel Services:
We're sorry. We ran into a problem completing your request. Please try that again in a few minutes.


Believe me even if you tried again in few minutes it might not work...

Few suggestions:
Check in central admin if your excel services is running.
Check if you have an Excel Service application in your service applications.

In Central Administration



Go to Application Management



And then in Manage Web Application



I select my web site (Share Point - 80) and then select 'Service Connection'



Finally I Checked Excel Service Application And it work for me.




Wednesday, 15 April 2015

SharePoint 2010: Remove the My Site Host Location URL





So if you have seen the above screen and wondering if it is ever possible to remove my site host location follow simple power-shell to remove it.

$site = Get-SPSite "http://<url of your admin site>"

$context = Get-SPServiceContext($site)

$upm = New-Object -TypeName Microsoft.Office.Server.UserProfiles.UserProfileManager -ArgumentList $context

$upm.MySiteHostURL="";

Tuesday, 3 March 2015

Sharepoint 2010 error opening .pdf files




When you try to open a PDF document from your standard SharePoint library, as it tries to open it in Acrobat viewer and you encounter the error:

There was an error opening this document. The filename, directory name, or volume label syntax is incorrect.

You can fix it read below:

DON'T


  • Change Client Integration
  • Change File handling methods

DO

Go to the following Path:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML

Edit the DOCICON.XML file 

Find this entry

<Mapping Key="pdf" Value="icpdf.png" OpenControl="PdfFile.OpenDocuments"/>




and edit it to 

<Mapping Key="pdf" Value="icpdf.png" OpenControl="SharePoint.OpenDocuments"/>





Hope this fixes your problem