Friday, 13 January 2012

Sharepoint Workspace - Not all views sync

Working on a library in Sharepoint Workspace I noticed that not all views for that Library were syncing.


I found a few posts that said custom views with filters could not sync however this was not correct. All of the views in the library had filters but four of them were missing from Workspace. I looked further and found that the views that were missing were filtering on a date calculation or on a column criteria not being blank.


Removing the date or entering a value fixes this issue and the views sync but this changes the behaviour, so the users may have to do without in Workspace. 


Sorting can also cause the view not to appear in Workspace. Sorting on Modified for example works but sorting on Owner or custom columns.






Friday, 6 January 2012

Save Template Error - No Windows Identity for DOMAIN\User

When trying to save a template today I encountered an error, I never had an issue saving templates before so I had a look in the logs to check what was causing it. In the logs I found the following error:


SPSecurityContext.WindowsIdentity: Could not retrieve a valid windows identity for NTName='DOMAIN\User', UPN='User@domain.com'. UPN is required when Kerberos constrained delegation is used. Exception: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: WTS0003: The caller is not authorized to access the service. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.UnauthorizedAccessException: WTS0003: The caller is not authorized to access the service.    at Microsoft.IdentityModel.WindowsTokenService.CallerSecurity.CheckCaller(WindowsIdentity callerIdentity)     at Microsoft.IdentityModel.WindowsTokenService.S4UServiceContract.PerformLogon(Func`1 logonOperation, Int32 pid)     at SyncInvokeUpnLogon(Object , Object[] , Object[] )     at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)     at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)     at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)     at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)     at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet))

Claims Authentication  No windows identity for domain\user.

Looking online gave me no answers until I came across this blog by Doug Ware which talked about a change made by KB979917.

In the Application Settings for my Sharepoint Site I changed the aspnet:AllowAnonymousImpersonation to false and then performed an iisreset (beware that this will cause disruptions to your sharepoint website so either take the servers out of the load balancer one at a time or organise downtime).

After that I tried to save a site as a template and got a rather pleasing Operation Completed Successfully.


On my UAT environment I got a further error:

VtemplateManager::loadUncustomizedFormSchema failed with error code 0x80004005.    a93fecf5-fef9-4498-ae66-569b5872f930

CFormWebPartXmlFromRowSetData::Parse failed with 0x80004005    a93fecf5-fef9-4498-ae66-569b5872f930

CWebPartXmlBuilder::Add failed with 0x80004005    a93fecf5-fef9-4498-ae66-569b5872f930

Cannot complete this action.  Please try again.    a93fecf5-fef9-4498-ae66-569b5872f930

Which I fixed by running the script in my post about fixing broken discussion boards. After running the script I tried to save the template and it completed successfully.

Tuesday, 3 January 2012

Retention Policy for Sharepoint Foundation 2010

There are no Retention Policies available for Sharepoint Foundation 2010 but you can get around this if you are a little bit creative. I have created a Powershell script that will delete files from a library that have not been modified within a specified time.
In our case we wanted to setup a temporary library for files that would be deleted if they had not been modified in the past three months.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$SPWeb = Get-SPWeb http://yourSiteURL/
$list=$SPWeb.Lists["Documents Library Name"]
$listItems = $list.Items
$listItemsTotal = $listItems.Count

$ThreeMonthsAgo = ((get-date).AddMonths(-3))

for ($x=$listItemsTotal-1;$x -ge 0; $x--)
{
    if([System.DateTime]$listItems[$x]["Modified"] -lt $ThreeMonthsAgo)
    {
        $listItems[$x].Delete()
    }
}
 
This script will delete the files but you could send them to the Recyle Bin instead using

$listItems[$x].Recycle()
 
You can change the expiry date using there properties to best fit your requirements.

 AddDays
 AddHours
 AddMilliseconds
 AddMinutes
 AddMonths
 AddSeconds
 AddTicks
 AddYears
 
After that I simply setup a Scheduled Task to run the Powershell script daily and I now have a Retention Policy on our temporary library.