Thursday, April 9, 2015

SharePoint 2010: Event 7043 "Load control template file /_controltemplates/TaxonomyPicker.ascx failed"

Error Description

You install Microsoft SharePoint 2010 RTM on Windows 2008 R2, you receive the following error message multiple times in the application event log:

Event Type: Error
Event Source: SharePoint Foundation
Event Category: None
Event ID: 7043
Computer: SERVERNAME
Description: Load control template file /_controltemplates/TaxonomyPicker.ascx failed: Could not load type 'Microsoft.SharePoint.Portal.WebControls.TaxonomyPicker' from assembly 'Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.



Error Cause

The ULS log is created in a code path where all control templates are loaded into the web application. This is a one-time process which happens just before showing any UI to the user after an IISReset.The source of the problem looks like a stale control template in the control templates folder while the control itself has been removed from the code base.

Fix

This is not causing any issues except for a wrong ULS log message a single time in a web application process life time, the exception is caught and that template file is skipped. This message should be treated as log noise and can be ignored.
1. Navigate to /14/TEMPLATE/ControlTemplates/TaxonomyPicker.ascx user control
2. Open the user control in a text editor and locate the first line
3. Find the character string , and replace with a comma ‘,’ (without quotes).
4. Save the user control



How to create a new content database for a web application

New-SPContentDatabase

The New-SPContentDatabase cmdlet creates a new content database and attaches it to the specified Web application.

New-SPContentDatabase [-Name] <String> [-WebApplication] <SPWebApplicationPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-AssignNewDatabaseId <SwitchParameter>] [-ChangeSyncKnowledge <SwitchParameter>] [-ClearChangeLog <SwitchParameter>] [-Confirm [<SwitchParameter>]] [-DatabaseCredentials <PSCredential>] [-DatabaseServer <String>] [-MaxSiteCount <Int32>] [-WarningSiteCount <Int32>] [-WhatIf [<SwitchParameter>]]

Example

New-SPContentDatabase "MyDatabase" -DatabaseServer "MyServer" -WebApplication http://sitename


Wednesday, April 8, 2015

Cache settings operations in SharePoint Server

SharePoint Server provides four types of caches that help improve the speed at which web pages load in the browser:

2. Page output cache
4. Anonymous search results cache

The BLOB cache is enabled and configured in the Web.config file in the web application to which you want to apply the cache. The page output cache and object cache are usually configured in the user interface at the site collection level. Certain settings for these caches can also be configured at the web application level. The changes that you make to the Web.config file will be applied to all site collections and sites within the web application, and will supersede any configuration made at the site collection level or below.


Note : To use the page output cache or the object cache, you must be using the Publishing feature on your site.

BLOB cache
SharePoint Server provides a disk-based cache that stores files that are used by web pages to help them load quickly in the browser, and reduces the load on the database server when it uses those files. These files are known as binary large objects (BLOBs), and the cache is known as the BLOB cache. The BLOB cache is stored directly on the hard disk drive of a front-end web server computer. The first time that a web page is called, these files are copied from the database to the cache on the server hard disk drive, and all subsequent requests for those files are then served from the hard disk drive cache of the server. By default, the BLOB cache is off and must be enabled to use the functionality it provides. When you enable the BLOB cache on your front-end web server, you reduce the load on the SharePoint Server database server created by read requests from web browsers.

Page output cache profiles
The page output cache stores the rendered output of a page. It also stores different versions of the cached page, based on the permissions of the users who are requesting the page. Page output cache settings can be configured at the site collection level, at the site level, and for page layouts. By default, the page output cache is turned off. The page output cache uses cache profiles that specify how long items should be held in the cache. You can specify different cache profiles to be used for anonymous and authenticated users, which optimizes the use of the cache based on the authentication methods that are allowed on the site. You can configure cache profile settings for a web application by editing the Web.config file on the application server. The cache profile settings that you configure at the web application level will be used for all cache profiles in the site collections for that web application.

Object cache
The object cache reduces the amount of traffic between the web server and the SQL database by storing objects - such as lists and libraries, site settings, and page layouts - in memory on the front-end web server computer. As a result, the pages that require these items can be rendered quickly, increasing the speed with which pages are delivered to the client browser. Object cache settings can be configured at the web application level, and at the site collection level. By default, the object cache is on at the site collection level. You can optimize the object cache for a web application by specifying the size of the object cache. Specifying a larger number can enhance performance for some large sites at the cost of memory on each front-end web server. You can configure other settings for the object cache at site collection level.

Anonymous search results cache

The anonymous search results cache is primarily used by publishing sites that allow access to anonymous users. It saves search results from anonymous users and reuses them for later queries that are the same as the original query. This improves performance on site pages that use the Content Search Web Part.

Configure object cache user accounts in SharePoint Server

The object cache stores properties about items in SharePoint Server. Items in this cache are used by the publishing feature when it renders web pages. The goals of the object cache are to reduce the load on the computer on which SQL Server is running, and to improve request latency and throughput. The object cache makes its queries as one of two out-of-box user accounts: the Portal Super User and the Portal Super Reader. These user accounts must be properly configured to ensure that the object cache works correctly. The Portal Super User account must be an account that has Full Control access to the web application. The Portal Super Reader account must be an account that has Full Read access to the web application.

Note: The Portal Super User and Portal Super Reader accounts must be separate accounts, and they must not be accounts that will ever be used to log in to the site.

In SharePoint Server, querying for items is linked with the user account that makes the query. Various parts of the publishing feature make queries for which the results are cached in the object cache. These results are cached based on the user making the query. To optimize the cache hit rate and memory requirements, the queries must be based on whether a user can see draft items. When a publishing control requests the object cache to make a query to get data for the control, the cache makes the query, not as the user making the request, but instead it makes the query twice: once as the Portal Super User account and once as the Portal Super Reader account. The results of these two queries are stored in the object cache. The results for the Portal Super User account include draft items, and the results for the Portal Super Reader account include only published items. The object cache then checks the access control lists (ACLs) for the user who initiated the request and returns the appropriate results to that user based on whether that user can see draft items. By adding the Portal Super User and Portal Super Reader accounts to the web application, the cache must store results for only two users. This increases the number of results that are returned for a query and decreases the amount of memory that is needed to store the cache.

Note: By default, the Portal Super User account is the site’s System Account, and the Portal Super Reader account is NT Authority\Local Service. There are two main issues with using the out-of-box accounts.

1. The first issue is that some items get checked out to System Account, so when a query that includes these items is made, the checked out version of the item is returned instead of the latest published version. This is a problem because it is not what a user would expect to have returned, so the cache has to make a second query to fetch the correct version of the file. This negatively affects server performance for every request that includes these items. The same problem would occur for any user who has items checked out, if that user’s account was set to be the Portal Super User account. This is why the accounts configured to be the Portal Super User and the Portal Super Reader should not be user accounts that are used to log into the site. This ensures that the user does not inadvertently check items out and cause problems with performance.

2. The default Portal Super Reader account is NT Authority\Local Service, which is not correctly resolved in a claims authentication application. As a result, if the Portal Super Reader account is not explicitly configured for a claims authentication application, browsing to site collections under this application will result in an “Access Denied” error, even for the site administrator. This error will occur on any site that uses any feature that explicitly uses the object cache, such as the SharePoint Server Publishing Infrastructure, metadata navigation, the Content Query Web Part, or navigation.


1. Create the super user account and super reader account

Create 2 normal domain accounts and call them :

domain\superuser
domain\superreader

You can configure the user accounts for the object cache by using Central Administration and Windows PowerShell. You must first create the accounts in the Central Administration website and then add the accounts to the web application by using Windows PowerShell. You must add the user accounts to each web application.


2. To add the user accounts by using Central Administration

The domain\superuser account needs to have a User Policy set for that gives it Full Control to the entire web application. In order to do this you perform the following steps:

1. Go to Central Administration
2. Go to Application Management
3. Go to Manage Web Application
4. Select the web application
5. Click User Policy
6. Add Users
7. Click Next
8. Fill in domain\superuser
9. Select Full Control
10. Click Finish

The domain\superreader account needs to have a User Policy set for that gives it Full Read to the entire web application. In order to do this you perform the following steps:

1. Go to Central Administration
2. Go to Application Management
3. Go to Manage Web Application
4. Select the web application
5. Click User Policy
6. Add Users
7. Click Next
8. Fill in domain\superreader
9. Select Full Read
10. Click Finish

Make note of how the names for the Object Cache Super Reader and Object Cache Super User accounts are displayed in the User Name column. The displayed strings will be different depending on whether you are using claims authentication for the web application.

3. To add the user accounts to the web application by using Windows PowerShell

$w = Get-SPWebApplication "http://<server>/"
$w.Properties["portalsuperuseraccount"] = "domain\superuser"
$w.Properties["portalsuperreaderaccount"] = "domain\superreader"
$w.Update()

If you are using claims based authentication run these cmdlets on one of your SharePoint servers:

$w = Get-SPWebApplication "http://<server>/"
$w.Properties["portalsuperuseraccount"] = "i:0#.w|domain\superuser"
$w.Properties["portalsuperreaderaccount"] = "i:0#.w|domain\superreader"
$w.Update()





Server Error in '/' Application” my profile in Mysite.

Issue Description

Error 1
I was browsing to the .../_layouts/settings.aspx page of my Mysite and was getting the below error

Error
An unexpected error has occurred.
Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: ed701c42-8302-42d4-8886-121e92484460
Date and Time: 5/28/2014 4:58:36 PM
 Go back to site

Error 2
Getting an error “Server Error in '/' Application” when tried to click my profile in Mysite.

Issue Details

On checking the logs and server event viewer I got the below error messages:

Error Logs



The user does not exist or is not unique.
Object Cache: The super user account utilized by the cache is not configured. This can increase the number of cache misses, which causes the page requests to consume unneccesary system resources.  To configure the account use the following command 'stsadm -o setproperty -propertyname portalsuperuseraccount -propertyvalue account -url webappurl'. The account should be any account that has Full Control access to the SharePoint databases but is not an application pool account.  Additional Data:  Current default super user account: SHAREPOINT\system


Could not get token super user token, reverting to system account.  User is "UserName"
stsadm -o setproperty -propertyname portalsuperuseraccount -propertyvalue account -url webappurl'
PortalSiteMapProvider was unable to fetch root node, request URL: /_layouts/settings.aspx, message: The user does not exist or is not unique., stack trace:  
 at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)   
 at Microsoft.SharePoint.Library.SPRequest.GetUserToken(String bstrUrl, String bstrLogin)   
 at Microsoft.SharePoint.SPWeb.GetUserToken(String userName)   
 at Microsoft.SharePoint.Publishing.CacheManager.<.ctor>b__0(SPSite newSite)   
 at Microsoft.SharePoint.Publishing.CommonUtilities.<>c__DisplayClass1.<RunWithElevatedSite>b__0()   
 at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()   
 at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)    
 at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)   
 at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)   
 at Microsoft.SharePoint.Publishing.CommonUtilities.RunWithElevatedSite(SPSite siteNonElev, Boolean allowUnsafeUpdates, ElevatedSiteProcessor callWithElevatedSite)   
 at Microsoft.SharePoint.Publishing.CacheManager..ctor(SPSite site)   
 at Microsoft.SharePoint.Publishing.CacheManager.GetManager(SPSite site, Boolean useContextSite, Boolean allowContextSiteOptimization)   
 at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.get_ObjectFactory()   
 at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.get_TryGetRootNode()


Failed to create a custom control 'PublishingSiteActionsMenuCustomizer', feature 'Publishing' (id:22a9ef51-737b-4ff2-9346-694633fe4416) using attributes (ControlSrc='', ControlAssembly='Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c', ControlClass='Microsoft.SharePoint.Publishing.WebControls.PublishingSiteActionsMenuCustomizer': System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.SharePoint.SPException: The user does not exist or is not unique. ---> System.Runtime.InteropServices.COMException (0x81020054): The user does not exist or is not unique.   
System.Web.HttpException: The DataSourceID of 'TopNavigationMenu' must be the ID of a control of type IHierarchicalDataSource.  A control with ID 'topSiteMap' could not be found.  


Issue Resolution

I analyzed that the issue was “object caching accounts don’t have the correct permission on the Mysite web application”. It was the superuser and superreader accounts-however, the issue was not that they weren't configured correctly.

1. Ran the below mentioned following commands:
stsadm -o getproperty -pn portalsuperuseraccount -url https://mysites.url.com/
stsadm -o getproperty -pn portalsuperreaderaccount -url https://mysites.url.com/

Above commands returned below output:
<Property Exist="Yes" Value="superuser"/>
<Property Exist="Yes" Value="superreader”/>

Did you notice that it was not of the format "domain\username”. This was the issue

2. Remove existing
I ran the below commands to remove the existing values set for the super user & superreader using below power shell command:
$wa = Get-SPWebApplication "https://mysites.url.com"
$wa.Properties.Remove("portalsuperuseraccount")
$wa.Properties.Remove("portalsuperreaderaccount")
$wa.update()

3. Verify
After this, I verified the status using below power shell commands:
stsadm -o getproperty -pn portalsuperuseraccount -url https://mysites.url.com/
stsadm -o getproperty -pn portalsuperreaderaccount -url https://mysites.url.com/

This returned below value for super user & superreader:
<Property Exists="No" />PS C:\Users\ domain\superuser >
<Property Exists="No" />PS C:\Users\ domain\superreader>

4. Add new
Then I ran the command to set new values for the super user & superreader using below power shell commands:
$wa = Get-SPWebApplication " https://mysites.url.com"
$wa.Properties["portalsuperuseraccount"] = " domain\superuser "
$wa.Properties["portalsuperreaderaccount"] = " domain\superreader"
$wa.update()




Event ID 6398 and 5586 : Could not find stored procedure 'dbo.Search_GetRecentStats'.

Issue Description

On checking the SharePoint server event viewer, I was seeing the below errors every minute.

Event 6398
The Execute method of job definition Microsoft.Office.Server.Search.Monitoring.HealthStatUpdateJobDefinition (ID 67ac9b25-4559-4847-849f-16f05cee73c9) threw an exception. More information is included below.
Could not find stored procedure 'dbo.Search_GetRecentStats'.



Event 5586
Unknown SQL Exception 2812 occurred. Additional error information from SQL Server is included below.
Could not find stored procedure 'dbo.Search_GetRecentStats'.



Fix

Go to Central Administration -> Monitoring -> Configure usage and health data collection -> Enable health data collection

Tuesday, April 7, 2015

Backup a SharePoint Site

Backup SharePoint Site
Backup-SPSite http://sitename -Path E:\Backup\site_name.bak

NAME
    Backup-SPSite

SYNOPSIS
    Performs a backup of a site collection.

SYNTAX
    Backup-SPSite [-Identity] <SPSitePipeBind> -Path <String> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-NoSiteLock <SwitchParameter>] [-UseSqlSnapshot <SwitchParameter>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

DESCRIPTION

The Backup-SPSite cmdlet performs a backup of the site collection when the Identity parameter is used. By default, the site collection will be set to read-only for the duration of the backup to reduce the potential for user activity during the backup operation to corrupt the backup. 

Restore a SharePoint site to a specific database

Restore a SharePoint site
Restore-SPSite http://sitename -Path "E:\Backup\file.bak" -Force

Restore a SharePoint site to a specific database

Restore-SPSite http://sitename -Path "E:\Backup\file.bak" -Force -DatabaseName "Database"

NAME
    Restore-SPSite

SYNOPSIS
    Restores a site collection.

SYNTAX
  Restore-SPSite [-Identity] <String> -Path <String> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-ContentDatabase <SPContentDatabasePipeBind>] [-Force <SwitchParameter>] [-GradualDelete <SwitchParameter>] [-HostHeaderWebApplication <String>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

Restore-SPSite [-Identity] <String> -Path <String> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-DatabaseName <String>] [-DatabaseServer <String>] [-Force <SwitchParameter>] [-GradualDelete<SwitchParameter>] [-HostHeaderWebApplication <String>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

DESCRIPTION

The Restore-SPSite cmdlet performs a restoration of the site collection to a location specified by the Identity parameter. A content database may only contain one copy of a site collection. If a site collection is backed up and restored to a different URL location within the same Web application, an additional content database must be available to hold the restored copy of the site collection.

SharePoint Solution deployment stuck on deploying

Problem description

I was deploying the solution in our production environment and faced some strange issue.The status never changes from deploying.

Fix

1.  Log on to all the SharePoint servers in the farm -> Start -> Run -> services.msc 


2.   Check for SharePoint Timer service and make sure it’s in started mode. (This service should be started on all the web servers  as well as application server)

How to Remove a site collection Normally and Forcefully

To Remove a site collection Normally

Remove-SPSite "http://sitename/"

Apparently, the Remove-SPSite cmdlet cannot delete a site collection which is not fully provisioned, and this cmdlet doesn’t have a force flag.

To forcefully delete a site collection, use the SPContentDatabase.ForceDeleteSite method

$siteUrl = "http://sitename/"
$site = get-spsite $siteUrl
$siteId = $site.Id
$siteDatabase = $site.ContentDatabase
$siteDatabase.ForceDeleteSite($siteId, $false, $false)