Tuesday, April 21, 2015

Workflow is not started by the first event

The workflow is not started by the first event ("item created" or "item changed"), after that it works well.

It only happens in one site collection.

Soon I found the error message in ULS: "The requested workflow task content type was not found on the SPWeb"

Google search leads to this post. But re-creating Tasks list didn't resolve the problem in my case. The other posts all recommend to reactivate "OffWFCommon" feature. But it still didn't help.

Then I realized where the problem is.

SharePoint structure is based on "template". From the error message in ULS, it's easy to guess that the site content type "Tasks" is corrupted somewhere. Reactivating "OffWFCommon" feature only fixes the site content type template, not the content type instance in the Tasks list.

So the solution is simple.

1. Reactivate "OffWFCommon" feature

stsadm -o deactivatefeature -filename OffWFCommon\feature.xml -url http://sp.domain.local/sites/site1
stsadm -o activatefeature -filename OffWFCommon\feature.xml -url http://sp.domain.local/sites/site1

2. Rebuild "Tasks" list


Any comments welcome!

Wednesday, April 1, 2015

How to enable "Asset library" template

After creating a new site collection based on "Blank" site template, I noticed that "Asset library" template is not there. Then I enabled "SharePoint Server Standard Site Collection features" and "SharePoint Server Standard Site features", with no luck. Then "Wiki Page Home Page" feature, still no luck.

Internet search brings me to this post, and a few other similar posts, which all says that we need to enable "SharePoint Server Publishing Infrastructure". I am pretty sure that would work. However, "Publishing" feature is really a big chunk of stuff, and we lose "save as template" functionality after enabling it. I don't want to do that.

Thanks for the post All SharePoint Features, we can simply enable "Asset Library" feature, through the PowerShell script below.

# 4bcccd62-dcaf-46dc-a7d4-e38277ef33f4
Enable-SPFeature -identity "AssetLibrary" -URL "http://SiteCollectionUrl.company.local"



Monday, March 30, 2015

The main causes of failing to enable publishing feature

Last year I submitted a post regrading how to properly disable/re-enable publishing feature. That's not the silver bullet, however.

Recently I got some more trouble shooting tasks. The error message appeared (attached below), when site collection administrators failed to enable publishing feature. After some investigation, I found there were a few possible problems.

1. Some (hidden) OOTB site columns are missing.

2. Some (hidden) OOTB site content types are missing.

3. Some (hidden) content types which are part of publishing feature are assigned to hidden document library, before enabling publishing feature.

4. Some (hidden) document libraries or lists are missing.

These are all caused by disabling publishing feature improperly.  I recommend to rebuild the site collection. But, if really necessary, it's still possible to fix the problem manually.


ULS log:

SPContentTypeBindingElement.ElementActivated(). An error occurred binding content type '0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811' to list '/sites/ONEBRAND/_catalogs/masterpage' on web 'http://projectsqa.domain.local/sites/ONEBRAND'.  Exception 'A duplicate content type "Page Layout" was found.'.

Publishing Resources Feature activation failed. Exception: Microsoft.SharePoint.SPException: Provisioning did not succeed. Details: Failed to create the '_catalogs/masterpage' library. OriginalException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.    
 at Microsoft.SharePoint.Publishing.PublishingSite.GetPageLayouts(Boolean excludeObsolete)    
 at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.ConfigureMasterPageGallery(SPList cacheProfiles)     -
 -- End of inner exception stack trace ---    
 at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.ConfigureMasterPageGallery(SPList cacheProfiles)    
 at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.b__0()    
 at Microsoft.Office.Server.Utilities.Security.SecurityUtilities.RunWithAllowUnsafeUpdates(SPWeb web, Action secureCode)    
 at Microsoft.SharePoint.Publishing.CmsSecurityUtilities.RunWithAllowUnsafeUpdates(SPWeb web, CodeToRun secureCode)    
 at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.Provision()    
 at Microsoft.SharePoint.Publishing.PublishingResourcesFeatureHandler.<>c__DisplayClass3.b__0()    
 at Microsoft.Office.Server.Utilities.CultureUtility.RunWithCultureScope(CodeToRunWithCultureScope code)    
 at Microsoft.SharePoint.Publishing.CmsSecurityUtilities.RunWithWebCulture(SPWeb web, CodeToRun webCultureDependentCode)    
 at Microsoft.SharePoint.Publishing.PublishingResourcesFeatureHandler.FeatureActivated(SPFeatureReceiverProperties receiverProperties).

Feature receiver assembly 'Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c', class 'Microsoft.SharePoint.Publishing.PublishingResourcesFeatureHandler', method 'FeatureActivated' for feature 'aebc918d-b20f-4a11-a1db-9ed84d79c87e' threw an exception: Microsoft.SharePoint.SPException: Provisioning did not succeed. Details: Failed to create the '_catalogs/masterpage' library. OriginalException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.    
 at Microsoft.SharePoint.Publishing.PublishingSite.GetPageLayouts(Boolean excludeObsolete)    
 at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.ConfigureMasterPageGallery(SPList cacheProfiles)     -
 -- End of inner exception stack trace ---    
 at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.ConfigureMasterPageGallery(SPList cacheProfiles)    
 at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.b__0()    
 at Microsoft.Office.Server.Utilities.Security.SecurityUtilities.RunWithAllowUnsafeUpdates(SPWeb web, Action secureCode)    
 at Microsoft.SharePoint.Publishing.CmsSecurityUtilities.RunWithAllowUnsafeUpdates(SPWeb web, CodeToRun secureCode)    
 at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.Provision()    
 at Microsoft.SharePoint.Publishing.PublishingResourcesFeatureHandler.<>c__DisplayClass3.b__0()    
 at Microsoft.Office.Server.Utilities.CultureUtility.RunWithCultureScope(CodeToRunWithCultureScope code)    
 at Microsoft.SharePoint.Publishing.CmsSecurityUtilities.RunWithWebCulture(SPWeb web, CodeToRun webCultureDependentCode)    
 at Microsoft.SharePoint.Publishing.PublishingResourcesFeatureHandler.FeatureActivated(SPFeatureReceiverProperties receiverProperties)    
 at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce)

Windows events log:

Event log message was: 'Failed to create the '_catalogs/masterpage' library.'. Exception was: 'System.NullReferenceException: Object reference not set to an instance of an object.    
 at Microsoft.SharePoint.Publishing.PublishingSite.GetPageLayouts(Boolean excludeObsolete)    
 at Microsoft.SharePoint.Publishing.Internal.RootProvisioner.ConfigureMasterPageGallery(SPList cacheProfiles)'




Customize Access Denied page for all Web Application Alternative Urls

We can customize Access Denied page for a web application through PowerShell script below.

$site = get-spsite "http://intranet.company.local"
$webApp = $site.WebApplication
$webApp.UpdateMappedPage(1, "/_layouts/MyAccessDenied.aspx")
$webApp.Update()

However, there is one problem.

Users may access the site without domain name, such as "http://intranet". In that case, the customized Access Denied page is ignored, and users will see the OOTB page.

How to fix this issue? We have two options.

1. Create a separate zone for the web application, specify "intranet" in Host Header.



2. In IIS Site Bindings, add "Intranet" to the site.


Which one is better?  It depends on how many WFE servers are there, and how much RAM a WFE server has, and, whether the SharePoint Administrator want to modify IIS settings manually.

Wednesday, February 18, 2015

SharePoint 2010 - User Profile Synchronization - "Unable to process Put message"

I got this error quite a few times before, when trying to configure User Profile Synchronization Connection. Normally it's caused by permission issue, as this post explained.

This time it's different.

After some investigation, I think that resetting Sync DB may fix the problem. But what's wrong with that database?

In windows events log, I found the error message attached at the end of this post. The highlight part says, "Cannot insert duplicate key row in object 'dbo.mms_partition' with unique index 'IX_mms_partitionma_idpartition_name'. The duplicate key value is (f6faef68-af32-4387-ad64-aed58ba98394, DC=pw2,DC=local)"

I cannot believe that I missed it at the very beginning!

Run SQL Query "SELECT * FROM [SP_SyncDB].[dbo].[mms_partition]" on SharePoint database server, it's clear that "f6faef68-af32-4387-ad64-aed58ba98394" is already there in the field "ma_id". 

My guess is, for some unknown reason, SharePoint User Profile Service tries to create a new "Connection" instead of utilizing existing one.

So I deleted the existing User Profile Synchronization Connection through Central Admin site, then recreated it.

It works well. :-)

============= Error message in windows events log ==============

The server encountered an unexpected error while performing an operation for a management agent.

 "ERR: MMS(4596): sql.cpp(5714): Query (insert into [mms_partition] ([ma_id],[partition_id],[partition_name],[version_number],[ma_custom_data_xml],[is_selected],[filter_xml],[filter_hints_xml],[creation_date],[modification_date],[allowed_operations_flag],[current_export_batch_number],[current_export_sequence_number],[last_successful_export_batch_number]) values ( 'F6FAEF68-AF32-4387-AD64-AED58BA98394','F54CA4AE-2FFA-4517-BF61-7173795CE0B5',N'DC=pw2,DC=local',1,N'DC=pw2,DC=localpw2.local{901bed2e-5007-4849-8904-1b868995a6b6}1101',1,N'

  contact
  container
  domainDNS
  group
  inetOrgPerson
  user
  crossRef
  organizationalUnit


 
   CN=Computers,DC=pw2,DC=local
   OU=Domain Controllers,DC=pw2,DC=local
   CN=ForeignSecurityPrincipals,DC=pw2,DC=local
   CN=Managed Service Accounts,DC=pw2,DC=local
   OU=Microsoft Exchange Security Groups,DC=pw2,DC=local
   CN=Microsoft Exchange System Objects,DC=pw2,DC=local
   CN=Program Data,DC=pw2,DC=local
   CN=System,DC=pw2,DC=local
   CN=Builtin,DC=pw2,DC=local
   CN=Infrastructure,DC=pw2,DC=local
   CN=LostAndFound,DC=pw2,DC=local
   CN=NTDS Quotas,DC=pw2,DC=local
   CN=TPM Devices,DC=pw2,DC=local
   DC=ForestDnsZones,DC=pw2,DC=local
   DC=DomainDnsZones,DC=pw2,DC=local
   CN=Configuration,DC=pw2,DC=local
 
 
   CN=Users,DC=pw2,DC=local
 


',N'

 
   contact
   
    top
    person
    organizationalPerson
    contact
 
   1
 
 
   container
   
    top
    container
 
   1
 
 
   domainDNS
   
    top
    domain
    domainDNS
 
   1
 
 
   group
   
    top
    group
 
   1
 
 
   inetOrgPerson
   
    top
    person
    organizationalPerson
    user
    inetOrgPerson
 
   1
 
 
   user
   
    top
    person
    organizationalPerson
    user
 
   1
 
 
   crossRef
   
    top
    crossRef
 
   1
 
 
   organizationalUnit
   
    top
    organizationalUnit
 
   1
 
 
   msExchTransportSettings
   
    top
    container
    msExchTransportSettings
 
   0
 
 
   msImaging-PSPs
   
    top
    container
    msImaging-PSPs
 
   0
 
 
   msExchProtocolCfgProtocolContainer
   
    top
    container
    msExchProtocolCfgProtocolContainer
 
   0
 
 
   msExchMDBContainer
   
    top
    container
    msExchMDBContainer
 
   0
 
 
   msExchProtocolCfgHTTPFilters
   
    top
    container
    msExchProtocolCfgHTTPFilters
 
   0
 
 
   msExchAddressListServiceContainer
   
    top
    container
    msExchAddressListServiceContainer
 
   0
 
 
   msExchInformationStore
   
    top
    container
    msExchInformationStore
 
   0
 
 
   msExchOmaDeviceType
   
    top
    container
    msExchOmaDeviceType
 
   0
 
 
   msExchContainer
   
    top
    container
    msExchContainer
 
   0
 
 
   msExchAvailabilityConfig
   
    top
    container
    msExchAvailabilityConfig
 
   0
 
 
   msExchOmaConfigurationContainer
   
    top
    container
    msExchOmaConfigurationContainer
 
   0
 
 
   msExchAdvancedSecurityContainer
   
    top
    container
    msExchAdvancedSecurityContainer
 
   0
 
 
   msExchPublicFolderTreeContainer
   
    top
    container
    msExchPublicFolderTreeContainer
 
   0
 
 
   msExchStorageGroup
   
    top
    container
    msExchStorageGroup
 
   0
 
 
   msExchAddressRewriteConfiguration
   
    top
    container
    msExchAddressRewriteConfiguration
 
   0
 
 
   msExchOmaContainer
   
    top
    container
    msExchOmaContainer
 
   0
 
 
   msExchOmaDataSource
   
    top
    container
    msExchOmaDataSource
 
   0
 
 
   msExchOmaDeliveryProvider
   
    top
    container
    msExchOmaDeliveryProvider
 
   0
 
 
   msExchChatVirtualNetwork
   
    top
    container
    msExchChatVirtualNetwork
 
   0
 
 
   msExchContentConfigContainer
   
    top
    container
    msExchContentConfigContainer
 
   0
 
 
   msExchTransportRuleCollection
   
    top
    container
    msExchTransportRuleCollection
 
   0
 
 
   rpcContainer
   
    top
    container
    rpcContainer
 
   0
 
 
   msExchReplicationConnectorContainer
   
    top
    container
    msExchReplicationConnectorContainer
 
   0
 
 
   msExchChatNetwork
   
    top
    container
    msExchChatNetwork
 
   0
 
 
   msExchServersContainer
   
    top
    container
    msExchServersContainer
 
   0
 
 
   msExchRoutingGroupContainer
   
    top
    container
    msExchRoutingGroupContainer
 
   0
 
 
   msExchPoliciesContainer
   
    top
    container
    msExchPoliciesContainer
 
   0
 
 
   msExchConnectors
   
    top
    container
    msExchConnectors
 
   0
 
 
   msExchMDBAvailabilityGroupContainer
   
    top
    container
    msExchMDBAvailabilityGroupContainer
 
   0
 
 
   msExchProtocolCfgSMTPIPAddressContainer
   
    top
    container
    msExchProtocolCfgSMTPIPAddressContainer
 
   0
 
 
   msExchMonitorsContainer
   
    top
    container
    msExchMonitorsContainer
 
   0
 
 
   msExchIMGlobalSettingsContainer
   
    top
    container
    msExchIMGlobalSettingsContainer
 
   0
 
 
   msExchConfigurationContainer
   
    top
    container
    msExchConfigurationContainer
 
   0
 
 
   msExchOmaCarrier
   
    top
    container
    msExchOmaCarrier
 
   0
 
 
   msExchOmaDeviceCapability
   
    top
    container
    msExchOmaDeviceCapability
 
   0
 
 
   msExchProtocolCfgSharedContainer
   
    top
    container
    msExchProtocolCfgSharedContainer
 
   0
 
 
   msExchSystemObjectsContainer
   
    top
    container
    msExchSystemObjectsContainer
 
   0
 
 
   msExchAdminGroupContainer
   
    top
    container
    msExchAdminGroupContainer
 
   0
 
 
   msExchRoutingGroup
   
    top
    container
    msExchRoutingGroup
 
   0
 
 
   groupPolicyContainer
   
    top
    container
    groupPolicyContainer
 
   0
 
 
   msExchOrganizationContainer
   
    top
    container
    msExchOrganizationContainer
 
   0
 
 
   msExchConferenceContainer
   
    top
    container
    msExchConferenceContainer
 
   0
 
 
   computer
   
    top
    person
    organizationalPerson
    user
    computer
 
   0
 
 
   msPKI-Key-Recovery-Agent
   
    top
    person
    organizationalPerson
    user
    msPKI-Key-Recovery-Agent
 
   0
 
 
   msExchDepartment
   
    top
    organizationalUnit
    msExchDepartment
 
   0
 


','2015-02-17 23:23:17.924','2015-02-17 23:23:17.924',1073741854,1,0,0)) performed with error
ERR: MMS(4596): sql.cpp(5767): The statement has been terminated.
ERR: MMS(4596): sql.cpp(5775): hrError: 0x80040e2f, dwMinor: 3621
ERR: MMS(4596): sql.cpp(5930): SQL error: 01000, native: 3621
ERR: MMS(4596): sql.cpp(5767): Cannot insert duplicate key row in object 'dbo.mms_partition' with unique index 'IX_mms_partitionma_idpartition_name'. The duplicate key value is (f6faef68-af32-4387-ad64-aed58ba98394, DC=pw2,DC=local).
ERR: MMS(4596): sql.cpp(5775): hrError: 0x80040e2f, dwMinor: 2601
ERR: MMS(4596): sql.cpp(5930): SQL error: 23000, native: 2601
BAIL: MMS(4596): sql.cpp(3742): 0x80040e2f
BAIL: MMS(4596): sql.cpp(3639): 0x80040e2f
BAIL: MMS(4596): partition.cpp(2095): 0x80040e2f
BAIL: MMS(4596): mastate.cpp(4605): 0x80040e2f
BAIL: MMS(4596): ma.cpp(1521): 0x80040e2f
Forefront Identity Manager 4.0.2450.49"

Friday, January 9, 2015

ProfileSubtypeProperty, CoreProperty, ProfileTypeProperty and syncConnection PropertyMapping

Some attributes belong to ProfileSubtypeProperty object, some belong to CoreProperty, and some belong to ProfileTypeProperty.

It would be nice to see which one belongs to which one.

Below is the script I built to help.

======== list user profile properties and syncConnection PropertyMapping ========

# https://gallery.technet.microsoft.com/office/SP2010-PowerShell-to-0fda04f7
# http://phadnisblog.com/2012/03/13/how-do-i-add-custom-user-profile-properties-with-powershell/
# http://sharepoint.stackexchange.com/questions/56972/delete-sharepoint-userprofile-property-using-powershell
# http://msdn.microsoft.com/en-us/library/office/ms496130(v=office.14).aspx
# http://blogs.msdn.com/b/chandru/archive/2011/09/17/powershell-script-to-create-a-new-user-profile-property.aspx
# http://sp2007hut.wordpress.com/2012/02/11/creating-sharepoint-2010-upa-properties-via-powershell/

cls

$connectionName="user profile sync connection Name"

function Get-SPServiceContext([Microsoft.SharePoint.Administration.SPServiceApplication] $profileApp)
{
    $profileApp = @(Get-SPServiceApplication | ? {$_.TypeName -eq "User Profile Service Application"})[0]
    return [Microsoft.SharePoint.SPServiceContext]::GetContext($profileApp.ServiceApplicationProxyGroup, [Microsoft.SharePoint.SPSiteSubscriptionIdentifier]::Default)
}

$serviceContext = Get-SPServiceContext
$userProfileConfigManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext)

Write-Host "PropertyMapping, connectionName="$connectionName -ForegroundColor Yellow
$syncConnectionManager = $userProfileConfigManager.ConnectionManager[$connectionName]
$syncConnectionPropertyMapping = $syncConnectionManager.PropertyMapping
foreach ($itemPropertyMapping in $syncConnectionPropertyMapping.GetEnumerator())
{
    #if ($itemPropertyMapping.ProfileProperty.Name -NotMatch "SPS")
    #{
        #$itemPropertyMapping | fl *
        $itemPropertyMapping | select-object @{Name="Property Name"; Expression={$_.ProfileProperty.Name}}, DataSourcePropertyName, IsImport, IsExport
        break
    #}
}

$userProfilePropertyManager = $userProfileConfigManager.ProfilePropertyManager

$defaultSubType = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)

$coreProperties = $userProfilePropertyManager.GetCoreProperties()
Write-Host "coreProperties.Count="$coreProperties.Count -ForegroundColor Yellow

$userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User)
$userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubTypeManager]::Get($serviceContext)
$userProfileSubtype = $global:userProfileSubTypeManager.GetProfileSubtype($defaultSubType)

Write-Host "userProfileTypeProperties.Count="$userProfileTypeProperties.Count -ForegroundColor Yellow
Write-Host "userProfileSubtype.PropertiesWithSection.Count="$userProfileSubtype.PropertiesWithSection.Count -ForegroundColor Yellow
Write-Host "userProfileSubtype.Properties.Count="$userProfileSubtype.Properties.Count -ForegroundColor Yellow

Write-Host "Display first coreProperty" -ForegroundColor Green
foreach ($profileCoreProperty in $coreProperties)
{
    $profileCoreProperty | fl *
    break
}

foreach ($profileSubtypeProperty in $userProfileSubtype.Properties)
{
Write-Host "Display first SubtypeProperty" -ForegroundColor Green
    $profileSubtypeProperty | fl *
Write-Host "Display first TypeProperty" -ForegroundColor Green
    $profileSubtypeProperty.TypeProperty | fl *
    break
}

Write-Host "Display first coreProperty with no TypeProperty" -ForegroundColor Green
foreach ($profileCoreProperty in $coreProperties)
{
    $profileSubtypeProperty = $userProfileSubtype.Properties.GetPropertyByName($profileCoreProperty.Name)
    if ($profileSubtypeProperty -eq $null)
    {
        $profileCoreProperty | fl *
        break
    }
}





Wednesday, January 7, 2015

SharePoint 2010 installation error: The specified value for the LocStringId parameter is outside the bounds of this enum

After re-installing Windows Server 2008 R2 SP1, I downloaded SharePoint 2010 with SP2 installation media from MSDN ( "en_sharepoint_server_2010_with_service_pack_2_x64_dvd_4178583.iso"), then tried to install a new test farm.

The installation succeeded. However, AutoSPInstaller configuration script threw out error message "Install-SPService : The specified value for the LocStringId parameter is outside the bounds of this enum."

So I deleted the relevant databases created by AutoSPInstaller, then ran "SharePoint 2010 Products Configuration Wizard" to initialize the farm. Similar error showed up in ULS log: "The specified value for the LocStringId parameter is outside the bounds of this enum."

After some investigation, I gave it up. There are a few people got the same problem, but no solution. So I uninstalled SharePoint 2010 with SP2 from the server, and then installed SharePoint 2010 RTM, then SP2, then CU201412.

It worked very well.

The problem is fixed.

Just curious: Is there any one knows what caused this problem? Any one use "SharePoint 2010 with SP2 installation media" to install SharePoint successfully?