SharePoint 2013:Subsite Creation Error

Leave a comment

Users with ‘Full Control’ permission on a site collection, even site collection administrators, could not create a subsite.

The only error they receive is “Sorry, you don’t have access to this page”SubSiteAccessDenied

First, I thought it had something to do with permissions on the hidden list (/Lists/TaxonomyHiddenList).  I granted the users ‘Full Control’ on this list.  Nope, that wasn’t it.

Then, I thought it was related to the Master Pages or Page Layouts.  I granted the users ‘Full Control’ on this list, too.  Nope, that wasn’t it either.

After digging through the ULS, I found the following entries.

FollowedContent.FollowItem:Exception:System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))     at Microsoft.SharePoint.Utilities.SPUtility.HandleAccessDenied(Exception ex)     at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bPreserveItemUIVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bUnRestrictedUpdateInProgress, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValida… 667d969d-3189-d082-cda8-1bb13d261267
…tionCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)     at Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)     at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents, String filename, Boolean bPreserveItemUIVersion)     at Microsoft.SharePo… 667d969d-3189-d082-cda8-1bb13d261267
…int.SPListItem.Update()     at Microsoft.Office.Server.UserProfiles.SPSocialDataStore.WriteFollowedItem(FollowedItem item, FollowedItemData data)     at Microsoft.Office.Server.UserProfiles.SPSocialDataStore.Follow(FollowedItem item, FollowedItemData data, Boolean checkLimit)     at Microsoft.Office.Server.UserProfiles.FollowedContent.FollowItem(FollowedItem item, Boolean isInternal) 667d969d-3189-d082-cda8-1bb13d261267
Could not follow the url http://myportal.local/dept/<SiteCollection/<Sub-Site>/ 667d969d-3189-d082-cda8-1bb13d261267
SiteFeedFeatureReceiver: exception thrown while trying to auto-follow the web: Microsoft.Office.Server.UserProfiles.FollowedContentException: InternalError : Could not follow the item http://myportal.local/dept/<SiteCollection>/<Sub-Site>/ at Microsoft.Office.Server.UserProfiles.FollowedContent.FollowItem(FollowedItem item, Boolean isInternal)     at Microsoft.Office.Server.UserProfiles.FollowedContent.Follow(Uri url, FollowedItemData data)     at Microsoft.SharePoint.Portal.SiteFeedFeatureReceiver.AutoFollowWeb(SPWeb web) 667d969d-3189-d082-cda8-1bb13d261267
Feature receiver assembly ‘Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’, class ‘Microsoft.SharePoint.Portal.SiteFeedFeatureReceiver’, method ‘FeatureActivated’ for feature ’15a572c6-e545-4d32-897a-bab6f5846e18′ threw an exception: System.Threading.ThreadAbortException: Thread was being aborted.     at Microsoft.SharePoint.Portal.SiteFeedFeatureReceiver.AutoFollowWeb(SPWeb web)     at Microsoft.SharePoint.Portal.SiteFeedFeatureReceiver.FeatureActivated(SPFeatureReceiverProperties properties)     at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce) 667d969d-3189-d082-cda8-1bb13d261267
Feature Activation: Threw an exception, attempting to roll back.  Feature ‘SiteFeed’ (ID: ’15a572c6-e545-4d32-897a-bab6f5846e18′).  Exception: System.Threading.ThreadAbortException: Thread was being aborted.     at Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce)     at Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, SPFeatureActivateFlags activateFlags, Boolean fForce) 667d969d-3189-d082-cda8-1bb13d261267

From what I can translate, the “Site Feed” feature was not able to be activated thus not allowing the new site to appear (or written) to “Sites you’re following” on the user’s My Site. This is true when selecting a Team Site, Project Site, or Community Site template.

I realized that all My Sites have been set to read-only (Governance Policy).  By switching from ‘Read-only’ to ‘Not locked’ via Central Admin, the users were able to create subsites successfully.

Read-Only

Learn more about Centric’s Portals and Collaboration Practice

Automating Site Directory in SharePoint 2013

Leave a comment

A while ago I posted on how to display Sites or Site Collections using Content Search Web Part here.

Well, since CSWP periodically displays “Sorry, something went wrong”, users are not happy with this solution.

So, I wrote a PowerShell script to update a list called “Site Directory”, and placed it on the home page.  I then added one additional logic to get new site collections created from the previous day.  After adding the script to Task Scheduler, I didn’t have to worry about missing newly created site collections.

To get all of the site collections created from the previous day, I used:


$Today = [DateTime]::Today
$Yesterday = $Today.AddDays(-1)

$siteCollections = Get-SPWebApplication http://demosite.vee.local | Get-SPSite -limit ALL | where {$_.RootWeb.Created -ge $Yesterday}

Now keep in mind, $Today will return today’s date at midnight and the same goes for $Yesterday (yesterday’s date at midnight).  I pointed this out to make sure that when you schedule this script in the Task Scheduler, you set it to run accordingly.  And, of course, replace the Web application with your Web application.

Writing it to a list was pretty straightforward, I added a category to the list, so I would have an additional option to display different views on the page.

In this list (Site Directory), there’s a hyperlink column.  I wanted the users to click on the hyperlink using a display name instead of the URL.  So, the $hyperlink in the script, will display the “friendly name”(ex: Coffee Beans) instead of the URL (ex: http://demosite.vee.local/dept/coffee%20beans).


foreach($siteCollection in $siteCollections)
{
  $web=$siteCollection.Rootweb;

  $web.Title + "," + $siteCollection.Url + "," + $web.Created | Out-File -Encoding Default -Append -FilePath $outFile;
  
  $siteCollection.Dispose()
};

$newItem = @{}
$sites = Import-Csv -path $outFile

$web = Get-SPWeb "http://demosite.vee.local";
$list = $web.GetList("http://demosite.vee.local/lists/Site Directory");

foreach($site in $sites)
{
  $siteURL =  $site.URL
  
  if($siteURL -match "/apps/")
  {
    $category = "APPS"
  }
  elseif($siteURL -match "/dept/")
  {
    $category = "DEPT"
  }
  else
  {
    $category = "DEFAULT"
  }
    $newItem = $list.items.Add();
    $newItem["Title"] = $site.'Title'
    $hyperlink = $site.URL + ", " + $site.Title
    $newItem["SiteURL2"] = $hyperlink
    $newItem["Category"] = $category
        
  #$newItem.Update();
  $web.Dispose();
};

Well, since I made this change, the users are happy.  No complaints! 🙂

 

CSWP: Display Template Listing Sites/Site Collections

1 Comment

One of the clients I’m working with wanted to list all of their site collections and place a “directory” on a single page with some groupings (based on managed paths).

The easiest way I could think of was to use Content Search Web Parts (CSWPs).

I used the following query:

QueryBuilderSiteCollection

My search result looked like this.

SiteCollectionPreview2

Note: You can change the query to display all sites within a site collection by using STS_Web instead of STS_Site.

The OOTB list of sortable items of the Query Builder didn’t have an option for me to sort the site title alphabetically.  So, I made a change to the SiteTitle in Search Scope (Managed Properties) to include sortable.  And I waited until Search finished crawling/indexing the modified setting.

After Search finished indexing, I was able to select the the setting I needed to sort the sites by their titles.

I selected the Two Lines Display Template.  However, the OOTB display was not exactly what the client was looking for.

TwoLineDT2

So I started modifying the display template to get rid of the icon/image displayed in front of each link and the spacing between the links.

I renamed my Display Template to “Item_NoImageOneLine.html”, changed the Title to “No Image One Line”, added a style tag, and commented out the image section.

<div class="cbs-Item" id="_#= containerId =#_" data-displaytemplate="Item1Line" style="padding-bottom:5px">
<!--<a class="cbs-ItemLink" title="_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_" id="_#= pictureLinkId =#_">
<img class="cbs-Thumbnail" src="_#= $urlHtmlEncode(iconURL) =#_" alt="_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_" id="_#= pictureId =#_" />
</a>-->
<div class="cbs-Detail" id="_#= dataContainerId =#_">
<a class="cbs-Line1Link ms-noWrap ms-displayBlock" href="_#= linkURL =#_" title="_#= $htmlEncode(line1.defaultValueRenderer(line1)) =#_" id="_#= line1LinkId =#_">_#= line1 =#_</a>
<!--#_

Here’s the final result.

TwoLineDTFinal

Learn more about Centric’s Portals and Collaboration Practice

SharePoint 2016 – Change MinRole Error a72id

Leave a comment

After hearing and reading a whole lot about the new MinRole in SharePoint 2016, I had to see what it’s all about by building my own VM.

For this post, I installed SQL Server 2014 and SharePoint 2016 Beta on the same VM server.  I ran the SharePoint Configuration Wizard to get all services and Central Admin provisioned.

I selected the ‘Single-Server Farm’ in the Server Role wizard.

SP2016ServerRole

I checked ‘Servers in this farm’, so far so good.

SP2016ServerFarm

I then tried to convert from ‘Single-Server Farm’ to ‘Application’ using Central Administration.  I got this lovely ‘Sorry, something went wrong’ message.

ConvertToApp

So, I searched the ULS and found these two entries.

12/29/2015 09:21:35.41         OWSTIMER.EXE (0x109C)                           0x316C        SharePoint Foundation                 Topology                             a72id        Exception        Failed converting server ‘VMSP2016T’ from ‘Application’ to ‘Application’ role. System.InvalidOperationException: Invalid search service unprovisioning: application ‘Search Service Application’ still has a ready component ‘in search service instance’ on server ‘VMSP2016T’.     at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.ThrowIfComponentsRunning()     at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Unprovision()     at Microsoft.SharePoint.Administration.SPServerRoleManager.<>c__DisplayClass4.<UnprovisionServiceInstance>b__3()     at Microsoft.SharePoint.Administration.SPServerRoleManager.ConfigureServiceInstanceInternal(SPServiceInstance serviceInstance, Action configureAction)     at Microsoft.SharePoint.Administration.SPServerRoleManager.C…        9b04509d-281a-f0ea-9175-4a569f8e73cf

12/29/2015 09:21:35.41*        OWSTIMER.EXE (0x109C)                           0x316C        SharePoint Foundation                 Topology                             a72id        Exception        …onfigureServiceInstance(SPServiceInstance serviceInstance)     at Microsoft.SharePoint.Administration.SPServerRoleManager.ConfigureServer(Boolean throwOnFailure)     at Microsoft.SharePoint.Administration.SPServerRoleConversionJobDefinition.Execute(Guid targetInstanceId) StackTrace: at onetnative.dll: (sig=55ee5f49-67a4-4a49-9862-19eec61e14d2|2|onetnative.pdb, offset=3712D) at onetnative.dll: (offset=1E35E)        9b04509d-281a-f0ea-9175-4a569f8e73cf

I tried unprovisioning, re-provisioning Search and all of its components, and tried and tried without success to convert to the ‘Application’ role.

I ended up disconnecting and reconnecting the server from its configuration database via PowerShell.  Credit for this solution goes to Nik Charlebois.

Disconnect-SPConfigurationDatabase -Confirm:$False

Connect-SPConfigurationDatabase -DatabaseServer SharePointDB -DatabaseName SharePoint_Config -Passphrase (ConvertTo-SecureString “P@ssw0rd1” -AsPlainText -Force) -LocalServerRole “Application”

Get-SPServer

DisconnectReconnectServer

As you can see from the Get-SPServer command that the server is now running as an ‘Application’ role.

Just to re-validate, I launched Central Admin and voila!  My server is now configured as ‘Application’.

SP2016AppRole

 

Add E-mail to People Search Display Template

2 Comments

This is a follow up to my previous post on adding phone extension to people results page (PeopleResults.aspx).

This post provides steps on how I added e-mail with action (mailto) to people search.

WorkEmail is one of the default user profile properties already mapped in SharePoint both in User Profile Property and in Search Schema. This makes my job a bit easier because all I have to do is modify my Display Template to include this value.  Some of the steps listed here are the same as my previous post.  I hope this makes things easier than flipping back and forth between the two.

  1. If you already have a custom display template for Item_Person, skip to step 6.  If this is the first time you need to edit the display template for people results, continue to the next step.
  2. From Search Center, select the following:
    • Site Settings
    • Master pages and page layouts
    • Display templates
    • Search
  3. Download ‘Item_Person.html’, save it on your local drive with a different name (ex: My_Item_Person.html)
  4. Modify Title. This will be used later when I modify the People Search Core Results Web Part.
  5. <title>My People Item</title>
  6. In <div id=”ContactInfo”>tag, add
<!--#_ 
                                        if(has_email == true) {
_#-->
                                            <div id="WorkEmailField">
<!--#_ 
                                                var encodedWorkEmail = $htmlEncode(ctx.CurrentItem.WorkEmail);
                                                var displayWorkEmail = Srch.U.getSingleHHXMLNodeValue(hhProps, "workemail");
                                                if ($isEmptyString(displayWorkEmail)) { displayWorkEmail = encodedWorkEmail }
_#--> 
                                                <div id="WorkEmailValue" class="ms-srch-ellipsis" title="_#= encodedWorkEmail =#_"><a href="mailto:_#= encodedWorkEmail =#_"> _#= displayWorkEmail =#_ </a></div>
                                            </div>
<!--#_ 
                                        }
_#-->

7.  Save My_Item_Person.html, upload it to the Display Template/Search gallery, and publish it

8.  From Search Center, type in a query term (ex: Executive)

9.  From ‘Site Settings’, select ‘Edit Page’

10.  Edit ‘People Search Core Results’ Web Part

11.  Expand ‘Display Templates’, select ‘Use a single template to display items’, select My People Item, then select ‘OK’

12.  Check In and Publish the People Results page (PeopleResults.aspx)

Your results page shoud look similar to the following.  Note that the OOTB results page only displays Name, Title, and Department

PeopleResults

Again, these steps may not be the greatest, but they worked for me.

Add Phone Extension to Display Template for People Search

Leave a comment

One of the clients I worked with store users’ phone extension in a string (Multi value) field in their Active Directory, though this value could be stored in a regular string field. Regardless of where the value is stored, my objective was to display this value in people search (PeopleResults.aspx). Steps I used below may not be the greatest, but they worked for me.

  1. Map a SharePoint user profile property to this AD attribute. I used ‘PhoneExtension’ for this one.
  2. Start Full Profile Synchronization
  3. Start Full or Incremental Crawl in Search
  4. From Search Service Application, select ‘Search Schema’
  5. Select ‘Crawled Properties’ and search for ‘PhoneExtension’. I did this step to verify that the property I created was crawled, and to allow me to move to the next step. You should see ‘People:PhoneExtension’ for your search.
  6. Select ‘Managed Properties’, then select ‘New Managed Property’. I created ‘PhoneExtension’ as a ‘Text’ type, and selected the following:
    • Queryable
    • Retrievable
    • Safe
  7. Select ‘Add a Mapping’, type ‘PhoneExtension’ in the ‘Crawled property selection’ window
  8. Select ‘People:PhoneExtension’, then click ‘OK’ to close the ‘Crawled propety selection’ window
  9. Click ‘OK’ again to close the ‘New Managed Property’ window
  10. Start Full Crawl, wait for this to complete
  11. From Search Center, select the following:
    • Site Settings
    • Master pages and page layouts
    • Display Templates
    • Search
  12. Download ‘Item_Person.html’, save it on your local drive with a different name (ex: <Client>_Item_Person.html)
  13. Modify title. This will be used later when I modify the People Search Core Results Web Part.
<title>Client People Item</title>

14.  Add ‘PhoneExtension’:’PhoneExtension’ to the end of the mso:ManagedPropertyMapping line (about line 13 or so).  Since ‘WorkPhone’ is already mapped in SharePoint as one of the default user property mappings, I added it here as well.

ManagedPropertyMapping

<mso:ManagedPropertyMapping msdt:dt="string">'AboutMe':'AboutMe','AccountName':'AccountName','BaseOfficeLocation':'BaseOfficeLocation','Department':'Department','HitHighlightedProperties':'HitHighlightedProperties','Interests':'Interests','JobTitle':'JobTitle','LastModifiedTime':'LastModifiedTime','Memberships':'Memberships','PastProjects':'PastProjects','Path':'Path','PictureURL':'PictureURL','PreferredName':'PreferredName','Responsibilities':'Responsibilities','Schools':'Schools','ServiceApplicationID':'ServiceApplicationID','SipAddress':'SipAddress','Skills':'Skills','UserProfile_GUID':'UserProfile_GUID','WorkEmail':'WorkEmail','WorkId':'WorkId','YomiDisplayName':'YomiDisplayName','WorkPhone':'WorkPhone','PhoneExtension':'PhoneExtension'</mso:ManagedPropertyMapping>

15.  In <body><div id=”Item_Person”> tag, add var has_wphone = !$isEmptyString(ctx.CurrentItem.WorkPhone);
var has_ext = !$isEmptyString(ctx.CurrentItem.PhoneExtension);

Item_PersonDiv

16.  In <div id=”ContactInfo”> tag, add

<!--#_ if(has_wphone == true) { _#-->



<div id="WorkPhone">
<!--#_ var encodedwphone = $htmlEncode(ctx.CurrentItem.WorkPhone); var displaywphone = Srch.U.getSingleHHXMLNodeValue(hhProps, "WorkPhone"); if ($isEmptyString(displaywphone)) { displaywphone = encodedwphone } _#-->



<div id="WorkPhoneValue" class="ms-srch-ellipsis" title="_#= encodedwphone =#_"> _#= displaywphone =#_ </div>



</div>



<!--#_ } _#-->
<!--#_ if(has_ext == true) { _#-->



<div id="PhoneExtension">
<!--#_ var encodedext = $htmlEncode(ctx.CurrentItem.PhoneExtension); var displayext = Srch.U.getSingleHHXMLNodeValue(hhProps, "PhoneExtension"); if ($isEmptyString(displayext)) { displayext = encodedext } _#-->



<div id="PhoneExtensionValue" class="ms-srch-ellipsis" title="_#= encodedext =#_"> _#= displayext =#_ </div>



</div>



<!--#_ } _#-->

ContactInfoDiv

17.  Save Client_Item_Person.html, upload it to the Display Templates/Search gallery, and publish it

18.  From Search Center, type in a query term (ex: Executive)

19.  From ‘Site Settings’, select ‘Edit Page’

20.  Edit ‘People Search Core Results’ Web Part

21.  Expand ‘Display Templates’, select ‘Use a single template to display items’, select Client_People_Item, then select ‘OK’

22.  Check In and Publish the People Results page (PeopleResults.aspx)

Your results page should look similar to the following.  Note that the OOTB only displays Name, Title, and Department.

PeopleResults

On my next post, I’ll cover how to add the e-mail to People Results page.

Happy search editing.

SharePoint 2013 Include People in Search Results – Duplicate Results

Leave a comment

I followed instructions in Steve Mann’s post on how to add people results in ‘Everything’ search results page.  All is well when you type in only first name or last name of the person.

When I typed in first and last name, two results are shown.

TwoPeopleResults

One titled ‘People Results’ came from the newly created query rule (People in Everything), and one titled ‘People Named’ came from OOTB SharePoint query rule.

This is not the desired results for me.  I only want one people results returned.

I modifed the ‘People in Everthing’ query rule to match either first or last name (unless you have the same first and last name, this rule will not work).

{subjectTerms} (LastName:”{subjectTerms}” OR FirstName:”{subjectTerms}”)

PeopleQueryRule

The search results now looks like this.

OnePeopleResultsBlock

Happy searching!

Older Entries