Thursday, March 12, 2015

Permission Issues Opening/Editing Office Web Apps Documents SharePoint 2013


Symptoms:

Users provided access to SharePoint through Active Directory (AD) Security Groups may  not be able to edit documents via the browser using Office Web Apps (OWA) without error.

In this scenario, the error from the Word App is: "There's a configuration problem preventing us from getting your document.  If possible, try opening this document in Microsoft Word."

We may find the following information after analyzing the ULS logs from the Office web apps Server and SharePoint Server.

From Office web apps server: (OWA folder in Logs)

w3wp.exe (0x113C) | 0x31C0 | Office Web Apps | WAC Hosting Interaction |
 ajryn | Unexpected | WOPICheckFile,WACSERVER ConfigError [error:The
 SharePoint site appears to have its UPA in an improper sync state.  Please
 contact the SharePoint administrator.  The SharePoint site's WOPI handler
 has determined that the user permissions for this file/folder do not match
 the user permissions when wopiframe.aspx was loaded. |
 WOPICheckFile,WACSERVER | Host Status Code: Unauthorized | Host Error Info:
 SyncUPA, url:https://URLofSite/_vti_bin/wopi.ashx/files/GUID...., host
 correlation:]

w3wp.exe (0x113C) | 0x31C0 | Office Web Apps | WAC Hosting Interaction |
 adhsk | Unexpected | WOPI CheckFile: Catch-All Failure
 [exception:Microsoft.Office.Web.Common.EnvironmentAdapters.ConfigErrorExcept
 ion: The SharePoint site appears to have its UPA in an improper sync state.
 Please contact the SharePoint administrator.  The SharePoint site's WOPI
 handler has determined that the user permissions for this file/folder do not
 match the user permissions when wopiframe.aspx was loaded. |
 WOPICheckFile,WACSERVER | Host Status Code: Unauthorized | Host Error Info:
 SyncUPA

Cause:

http://support.microsoft.com/kb/2908321

This issue can occur if the User Profile Application (UPA) is out of sync.
 If a user profile and the relevant group memberships for the user are not
 synchronized, SharePoint Server 2013 may incorrectly deny access to a given
 resource.

Resolution:
  1. Delete the user from the User Profile database in SharePoint Central Administration
    1. SharePoint Central Administration
    2. Application Management
    3. Manage Service Applications
    4. User Profile Synchronization Service
    5. Manage User Profiles
    6. Search for user
  2. Go to top level site collection with admin privileges
  3. Open the page https://siteurl/_layouts/people.aspx?MembershipGroupId=0 (all users in the site collection)
  4. Find your user, right click the name, and copy shortcut (url to the user's profile page)
  5. Paste the shortcut into the browser address field and append to it (don't press Enter yet): append Force=True (http://servername/_layouts/userdisp.aspx?ID=25&Force=True), press Enter
  6. Click on "Delete User from site collection" link on the toolbar
  7. From Central Administration, start a Full User Profile Synchronization.  Wait until this finishes to continue.
  8. Check that the user now exists in the User Profile database
  9. SharePoint Central Administration
  10. Application Management
  11. Manage Service Applications
  12. User Profile Synchronization Service
  13. Manage User Profiles
  14. Search for user
  15. Add the same user back to the SharePoint group in the Site Collection
  16. Test

Monday, February 9, 2015

Use PowerShell to Delete SharePoint List Items Based on Parameters From an External File

Below is a PS script I wrote to take parameters from a .csv file, find matching SharePoint list items based on 2 parameters, and delete that list item. I am also writing to another external .txt file the parameters of any list items that were missed so I can investigate why there was no match (internal administration).

#Import the csv file that holds the parameters we need to filter the SharePoint
$csv = Import-Csv d:\temp\importfilename.csv

#An error file - Clear this file in case anything was there from a previous run Clear-Content d:\temp\checkTheseFailedDeletes.txt

#Get the SharePoint web(site)
$web = Get-SPWeb http://sharepointsite

#Get the SharePoint list
$list = $web.Lists["Your List Name Here"]

$itemsTotal = 0
$count = 0

#Loop through each row of the input .csv file
foreach ($rox in $csv)
{
     #Assign each column's value to a variable
     $thisParam1 = $row.Param1ColumnFromCSV
     $thisParam2 = $row.Param2ColumnFromCSV

     #Build the CAML query and execute it on the list
     $query = New-Object Microsoft.SharePoint.SPQuery
     $query.ViewAttributes = "Scope='Recursive'"
     $caml = "$thisParam1$thisParam2"
     $query.Query = $caml
     $items = $list.GetItems($query)

     #Delete the item from the list if found
     if ($items.Count -gt 0)
     {
          $items | % { list.GetItemById($_.Id).Delete() }
          $caml = ""
          $count++
     }
    
     #Write records that were not found in the list to a text file to manually check if necessary
     else
     {
          $caml = ""
          $writeString = $thisParam1 + ", " + $thisParam2
          Add-Content d:\temp\checkTheseFailedDeletes.txt $writeString
     }
    
     $itemsTotal++
}

Write-Host $itemsTotal "records processed ===> " $count "records deleted"
$web.Dispose()