Wednesday, November 29, 2017

CREATING HOST-NAMED SITE COLLECTIONS IN SHAREPOINT 2013

 

Host-Named Site Collection (HNSC) is actually a means to have a separate DNS for each site collection rather than having all the site collections follow the URL of the web application (path-based site collections).

Host-named site collections are the preferred method to deploy sites in SharePoint 2013 and many features (like Apps) are optimized for HNSC.

For instance if I want to create 3 site collections, I can now have dedicated URLS :

o   http://portal.contoso.com

o   http://portal.contoso.com/teams/SPGovernance

o   http://portal.contoso.com/projects/SPPoc

Microsoft recommends this by default and makes use of it in Office 365; as far as I know all site collections we create in Office 365 are Host-Named Site Collections (HSNC). It is fully tested by millions of customers every day : –)

o   The main reason for that is that HNSC make your farm design simpler to design, to setup and to operate.

o   Another reason is that since resources are not used to support multiple application pools and web applications, the farm will be more stable.

o   …and another obvious reason is that since less/no custom code (that can potentially harm the farm) is used in SharePoint 2013, there is also less risk that a single application pool get corrupted. In O365, only Apps or sandbox code (deprecated) is tolerated.

A SharePoint 2013 KISS design (Keep it Simple, Stupid) today means : 1 farm, 1 web app, HNSC and 1 zone.

o   1 farm : I still have to find real projects where my custom needs several farms.

o   1 web app : even the MySites can be hosted with other SharePoint Sites

o   1 zone :You can implement multiple authentication providers on a single zone but you need at least the Windows Authentication (NTLM) provider on the default zone (for the crawler, more details later).

Host Name Site collections are hosted in web applications that don’t have host headers.

ok hands-on now :

Step 1. Create a hosting web application without any host header and preferably on port 80.

This means that we will now avoid host header binding in IIS and responsible for resolving the correct site for the address based upon the incoming request passed through IIS.You MUST avoid host header in the “host” web app.

Step 2. In this Web App, we have to create a “normal” site collection

 

Step 3. Create DNS entries

Let’s go to the DNS server and create a new A Host with the portal.contoso.comFQDN and pointing to the web front end

 

Step 4. Create the Host Named Site Collection http://portal.contoso.com

 

In SP2013, HSNC can only be created via the New-SPSite PowerShell command; the –HostHeaderWebApplication option specifies that we are creating an HSNC and provides the link to the corresponding webapplication.

Let’s type the following command:

New-SPSite ‘http://portal.contoso.com’ -HostHeaderWebApplication ‘http://eurosp/’ -Name ‘Portal’ -Description ‘Customer root’ -OwnerAlias ‘contoso\administrator’ -language 1033 -Template ‘STS#0’

 

 

Even if HNSC can only be created via PowerShell, they can be managed from Central Administration like other site collections. For instance, our newly created HSNC will show up in the Site Collection list (Central Admin) :

Step 5. Managed Path for HNSC

http://portal.contoso.com/teams/SPGovernance and http://portal.contoso.com/projects/SPPoc

(we can add more HNSC like a HNSC for the Search center, another one for the MySites,…)

Since there will be several sites collections under  http://portal.contoso.com/teams/  and http://portal.contoso.com/projects/ we have to rely on implicit Managed Path

Creating Managed path for HNSC can be done with the New-SPManagedPathPowershell command.

Let’s type :

New-SPManagedPath ‘teams’ –Hostheader

New-SPManagedPath ‘projects’ –Hostheader

 

Step 6. Creating Hosted-Named Site Collections

let’s create our 2 site collections:

New-SPSite ‘http://portal.contoso.com/teams/SPGovernance’ -HostHeaderWebApplication ‘http://eurosp/’ -Name ‘SharePoint Governance team’ -Description ‘SP governance team’ -OwnerAlias ‘contoso\administrator’ -language 1033 -Template ‘STS#0’

New-SPSite ‘http://portal.contoso.com/projects/SPPoc’ -HostHeaderWebApplication ‘http://eurosp/’ -Name ‘SharePoint Proof of concept’ -Description ‘SharePoint Proof of concept’ -OwnerAlias ‘contoso\administrator’ -language 1033 -Template ‘STS#0’

Now, 3 important remarks :

1.     The maximum number of Managed paths for HNSC : 20 for the whole farm !  (yes only 20!)

2.     You cannot list HNSC with managed Path in Central Administration.

3.     The equivalent of alternate access mapping cannot be applied to HSNC with Managed path as described below

Step 7. URL Mapping and Hosted-Named Site Collections

if for instance, we want the url http://contosointranet to be mapped to an existing url like http://portal.contoso.com but in a different zone, we can use something similar to what Alternate Access mapping provides (but focused on Hosted-Named site collections) :

Url Mapping.

Here again, we need to rely on PowerShell :

set-SPSiteUrl

Let’s create a contosointranet.contoso.com DNS entry

 

Type :

Set-SPSiteUrl (Get-SPSite ‘http://portal.contoso.com/’) -Url ‘http://contosointranet.contoso.com’ -Zone Intranet

…and the portal can be reached via http://portal.contoso.com or via http://contosointranet.contoso.com

As mentioned before, url mapping cannot be applied to HSNC with managed path : for instance we cannot map http://governance to http://portal.contoso.com/teams/spgovernance

Since we are mentioning zones, don’t forget that the default zone url must be always used by the crawler (and with windows authentication, not claim authentication); this is not clearly documented in the TechNet except here. if you don’t do this you might face issues with the Query search results (operated from from other zones).

 

Thursday, November 2, 2017

SharePoint 2013 Distributed Cache service

This post is meant to give SharePoint Administrators an deeper look into the Distributed Cache along with some links to other resources on the internet.

Background
SharePoint 2013 uses the AppFabric (Caching) by Microsoft. Read here for a background on AppFabric. AppFabric Caching stores serialised managed objects in a ‘cache cluster’. The cache cluster consists of one or more machines (Cache Hosts) that pool their available physical memory. This pooled memory is presented  and used by SharePoint as a single source of caching memory.

How is it used in SharePoint
SharePoint uses the Distributed Cache to store data for very fast retrieval across all entities. The Distributed Cache service provides in-memory caching services to several features in SharePoint Server 2013. Some of the features that use the Distributed Cache service include:
· Newsfeeds
· Authentication
· OneNote client access
· Security Trimming
· Page load performance

In SharePoint Server 2013, there are several caches that exist, all of which depend on the Distributed Cache service.
Different caches that depend on the Distributed Cache service as indicated in the following table:

Name

Cache name

Login Token Cache

DistributedLogonTokenCache

Feed Cache

DistributedActivityFeedCache

This cache stores activities and conversations for use by the feeds on a user’s My Site.

Last Modified Time Cache

DistributedActivityFeedLMTCache

This cache stores time stamp information for all Feed Cache entities

OneNote Throttling

DistributedBouncerCache

Access Cache

DistributedAccessCache

Search Query Web Part

DistributedSearchCache

Security Trimming Cache

DistributedSecurityTrimmingCache

App Token Cache

DistributedServerToAppServerAccessTokenCache

View State Cache

DistributedViewStateCache

Default Cache

DistributedDefaultCache

This cache can be used by any feature.

Source: http://technet.microsoft.com/en-us/library/jj219700.aspx

Installation
AppFabric is a required component for SharePoint 2013 and is installed as part of the prerequisite installer. Thus each server automatically becomes part of the ‘cache cluster’. There is nothing to configure here as SharePoint does this automatically.

Farm Architecture – modes
Here is some terminology that will be useful when talking SharePoint architecture and topology:
There are two ‘modes’ for Distributed Cache – A collocated mode or a dedicated mode. The Distributed Cache is started and run on all WFE and APP servers by default. If you have over 10000 users, you should look into a dedicated server (dedicated mode) Distributed Cache. Dedicated Mode simply means all other services are turned off and more memory is allocated to the Distributed Cache.

Farm design
While designing your topology, could consider starting the Distributed Cache service on your WFE servers (for redundancy) and stop the Distributed Cache Service on the APP server if you are concerned with ‘overhead’ caused by all the other services running on the APP server. You can consider a scale up plan if you are low on resources or scale out (by starting the Distributed Cache on other servers in the farm).
Finally it boils down to memory allocation at the end of the day. By default, the Distributed memory allocation size defaults to a value of 10 percent of total physical memory when SharePoint Server 2013 installs. You can change the memory allocation with the Update-SPDistributedCacheSize cmdlet.

Here is a link that may help on the ‘right approach’: http://technet.microsoft.com/library/jj219572%28office.15%29.aspx (note the ‘Capacity planning for the Distributed Cache service’ section).

Management
The Distributed Cache service can be stopped or started via the Central Administration or via PowerShell.

Servers can be added or removed from the ‘Cache cluster’ too. When removing the server, the Distributed Cache service is stopped, then unregistered from the server. Unregistering the Distributed Cache service means that you will not see the Distributed Cache service listed on the Services on Server page in Central Administration. Adding a server means that you will see the Distributed Cache service listed on Services on Server page in Central Administration.

To add a server and start the service in PowerShell: Add-SPDistributedCacheServiceInstance

To remove a server and stop the service in PowerShell:
Remove-SPDistributedCacheServiceInstance

To stop (not remove) the Distributed Cache service by using Central Administration: In Central Administration, click Application Management. In Service Applications, click Manage Services on Server. On the Services on Server page, locate the Distributed Cache service. If the Distributed Cache service is started and you want to stop the service, under Action, click Stop.

To stop (not remove) the Distributed Cache service by using Windows PowerShell: At the Windows PowerShell command prompt, run the following command: $instanceName =”SPDistributedCacheService Name=AppFabricCachingService” $serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername} $serviceInstance.Unprovision()

To check existing memory allocation of the Distributed Cache Host:
Use-CacheCluster
Get-AFCacheHostConfiguration -ComputerName ComputerName -CachePort “22233”

To reconfigure the cache size of the Distributed Cache Service:
Update-SPDistributedCacheSize -CacheSizeInMB CacheSize


Firewall configuration considerations

The Distributed Cache service uses the following communication ports:
22233
22234
22235
22236

Monitoring
The Distributed Cache can be monitored using below performance counters in Perfmon:


SharePoint Distributed Cache Counters
Cache Data Transferred Per Sec
Cache Hit Count
Cache Hit Ratio
Cache Miss Count
Cache Read Requests per sec
Cache Write Requests per sec
Total Cache Read Requests
Total Cache Write Requests


Additionally, there are three groups of ‘AppFabric’ counters available. Note there are multiple instances – indicating the different caches present in the Distributed Cache.
AppFabric Caching:Cache
AppFabric Caching:Host
AppFabric Caching:Secondary Host

Important Distributed Cache resource
Manage the Distributed Cache service in SharePoint Server 2013
Plan for feeds and the Distributed Cache service in SharePoint Server 2013

The above link shows how you can:

  • Change the memory allocation of the Distributed Cache service
  • Add or remove a server in a Distributed Cache cluster
  • Perform a graceful shutdown of the Distributed Cache service
  • Change the service account
  • Repair a cache host

 

Friday, February 10, 2017

SharePoint Alert Notifications Not Working - Checklist for Troubleshooting

Before proceeding with the checklist, analyze and isolate the issue:

  • Whether E-mail Infrastructure is working on your environment
  • Whether in all SharePoint web applications alerts are not working? SharePoint alerts not working for one site?
  • SharePoint alerts not working after upgrade or migration 
  • Alerts not working after restore or Service pack?
  • Alerts not working all the time? or Stopped working Recently?
  • SharePoint alerts not being sent to All the user? or some users? or distribution groups, ad group members?
  • Whether SharePoint alerts not working for document library? list alerts not working? calendar alerts not working ? or everywhere?
  • Only SharePoint daily alerts not working? etc. 
This will help you to troubleshoot the SharePoint email alerts not working issue, quickly.

Here is the checklist for troubleshooting:
1. Check alerts are enabled for your web application:
How to check? execute this stsadm in your SharePoint Server:
Stsadm.exe -o getproperty -url http://SharePoint-web-App-URL -pn alerts-enabled

This should return <Property Exist="Yes" Value="yes" />

If you don't get this, Enable alerts by:
stsadm.exe -o setproperty -pn alerts-enabled -pv "true" -url http://SharePoint-web-App-URL

If its already enabled, try turn off and turn on it back.

2. Is your SharePoint Server configured for Out-going E-Mail settings?
Go to Central Administration > Operations > Click on Outgoing e-mail settings Link under Topology and Services, Make sure you have valid settings for these fields. Usually you have to provide your Exchange server's HUB or any valid SMTP server's address.

3. Is your Exchange server allows SharePoint to Send Mails? 
In Exchange Server, If anonymous Relay settings is not enabled, then you must add your WFE/App Servers to the Exchange Server allowed hosts relay list! Make sure your ALL Sharepoint WFE's IPs are added in allowed Relays or Receive connectors in Exchange Server. If you use multiple domains, add all of them.
http://technet.microsoft.com/en-us/library/cc288949.aspx
Watch the  'DROP' folder in the mailroot of the SMTP server.

4. If you are using SMTP Server for E-mail communication, Make sure SharePoint Servers are allowed to Send Mails and Port 25 is open.Go to SMTP Virtual Server Properties >> Setting >> Access TAB >> Select "All except the list below"

5. Verify the Timer Jobs & Properties:

MOSS 2007:  Central Administration > Operations > Timer Job Definitions (under Global Configuration)
In SharePoint 2010: Central Administration > Monitoring > Review Job Definitions 

Check whether the "Immediate Alerts" job is enabled for your web application. check these properties:
  1. job-immediate-alerts
  2. job-daily-alerts 
  3. job-weekly-alerts
stsadm.exe -o getproperty -url "http://Your-SharePoint-web-App-URL" -pn job-immediate-alerts

The expected output is:

<Property Exist="Yes" Value="every 5 minutes between 0 and 59"/>.  

If you don't get this, run the following command to change its value.

stsadm.exe -o setproperty -pn job-immediate-alerts -pv "every 2 minutes between 0 and 59" -url http://Your-SharePoint-web-App-URL
More info: http://technet.microsoft.com/en-us/library/cc262432.aspx

6. Whether the user account subscribed for alerts has E-mail account associated?
In one of my case, user has two accounts, One normal account and another one for Administrative
purpose. He logged in with Admin account, created alerts, and then complained that he didn't receive
alerts! LOL

7. Try these Resets:
Do stsadm -o execadmsvcjobs. Do restart SharePoint Timer services and IISReset.
Is it happening only to a particular user? try remove/re-add em.

8. Check the Permissions: 
The initial alert is not security trimmed. Whether the user has access to the list or not, He will receive the initial alert. If the user is not getting alert for any changes, then check whether the user has at-least Read permission on the list/library.

If item level permission and Read Access to Only their own items is enabled, Alerts wont work!

9. Re-register the alert template:
Try re-registering the alert template:
stsadm -o updatealerttemplates -url http://Your-SharePoint-Web-App-URL -f  "c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML\alerttemplates.xml" -LCID 1033

More info: http://technet.microsoft.com/en-us/library/dd278299.aspx

10. Check your Alternate access mapping
Is your Site URL's/AAM entries changed recently? Check the below tables in your content databases, and verify you dont have any old URL in "SiteUrl" column  in these tables, if you find, replace them.

- ImmedSubscriptions (Stores the alerts for emails that are sent immediately when changes occur)
- SchedSubscriptions (Stores daily or weekly scheduled alerts)
- EventLog (This table contains events for which only non-immediate alerts exist)
- EventCache (This table contains a list of site events for which users have requested alerts. WSS inserts events into this table as they occur)

setting up in the Alternate Access Mappings in Central Admin will correct this issue.

11. Clear the SharePoint configuration cache http://support.microsoft.com/kb/939308

12. Migrated or Changed the Site URLs?
Are you migrated from existing versions of SharePoint/ Changed your SharePoint Site URLs?
You have to update your alerts. Have you performed some database restored in your environment from a different server? Follow my article to fix the alerts: Fix Alerts in SharePoint Migration

13. Export-Import, Backup/Restore:
If you conclude alerts are not working for a entire sub-site but works well with another sub-site, then take the export of the sub-site, delete it, restore it again.

14. Is your SharePoint Up-to-Date?
Make sure your SharePoint is updated with latest service packs/patches.

15. Want to send SharePoint alert to distribution list? SharePoint alert email to distribution list not working?
Make sure your group is E-mail enabled and has at-least read-only permission on the site/list where you are creating alerts. It must be Security group and not distribution list. SharePoint can recognize one users and security groups. So, you can create a Mail for the security group.

Go to distribution group properties and un-check "Require that all senders are authenticated" or create a outgoing connector in Exchange, so that exchange server authenticate SharePoint

Same applies, When you send E-mail from SPD Workflow (or any other workflow). Make sure that the group has at least read permission to the site and the group can be viewed by "everyone".


16. Changes to the user profiles happened wont affect immediately. sync it back.

17. Make sure your timer job account has dbo access to SharePoint content databases.

18. If your Task assignment mails are not delivered, toggle the value for "Send e-mail when ownership is assigned".

19. Task Assigned notification e-mail: If the user synchronized the tasks list with Outlook 2007 the e-mail will not be sent and he will receive the notification in his task pane

20. Content database: Try Re-Attaching the content database (stsadm -o deletecontentdb and addcontentdb)


Alternates: you can simply design a SharePoint designer workflow to send E-mails. or you can have a event receiver to do the same!


Read more:

Sunday, February 5, 2017

Lets talk about SharePoint Auditing and EffectiveAuditMask

 Everyone loves auditing, it fills the content DBs with such useful information. It's like Christmas came early for the SQL storage vendors!!
Seriously, I was attempting to use PowerShell to pull Auditing settings from our farm. Who has turned it on, what trimming settings have they selected, and what items are being audited?
Pretty simple stuff:
(Get-SPSite <siteURL>) | select -expand Audit
Returns something like this for a site with no Auditing enabled
UseAuditFlagCache      AuditFlags      EffectiveAuditMask
———————–      ————-       ———————–
False                                None                 None
Great. Now if you find a site with Auditing enabled, that's where things get really wonky.
If someone has selected just "Opening or downloading documents, viewing items in lists, or viewing item", you get:
UseAuditFlagCache      AuditFlags      EffectiveAuditMask
———————–      ————-       ———————–
False                                View                   View
Oooookkkk, not really a bit-on flag, but let's see where this goes.
If someone enables "Editing item", it looks like this:
UseAuditFlagCache      AuditFlags      EffectiveAuditMask
———————–      ————-       ———————–
False                                Update              Update
And if someone enables "Checking out or checking in items", it looks like this:
UseAuditFlagCache      AuditFlags      EffectiveAuditMask
———————–      ————-       ———————–
False                                3                         3
Well, of course it does. Looks like the helpful folks at Microsoft decided that some Auditing options will return a word, and some will return a bit-on mask. Super helpful, great, thanks. Awesome.
Fear not, I'm here to help, and help I will. Below is a handy table showing you how to figure some of this mess out. If you look at the Audit Settings section under Site Settings, this will show you what you will see from PowerShell, and what the corresponding bit on equivalent is.
Documents and Items:
PowerShell      Setting in Site Settings
————-      —————————
View(4)           Opening or downloading documents, viewing items in lists, or viewing item properties
Update(16)     Editing items
3                       Checking out or checking in items
6144                Moving or copying items to another location in the site
520                  Deleting or restoring items
Lists, Libraries, and Sites
PowerShell                      Setting in Site Settings
————-                       ————————-
160                                     Editing content types and columns
Search(8192)                   Searching site content
SecurityChange(256)     Editing users and permissions
So, using some quick bit on math you can finally start to understand, from PowerShell, what auditing options your happy Site Collections Admins have selected. Now the fun part, go figure out how much space Auditing is taking up…
Open, Edit: 20
Open, Edit, check Out: 23
Open, Edit, check Out, Moving: 6167
Open, Edit, check Out, Moving, Delete: 6687
All Lists, Libraries, and Sites: 8608
All On: 15295
Hope that helps…