Friday, May 9, 2014

Host named site collections in SharePoint 2013

What are HNSC

Traditional site collections that we create in SharePoint are Path based site collections

image

Host named site collections have their own url. 

Example

Microsoft recommends using host named site collection.  It is used in SharePoint online and Office 365.

Benefits of HNSCs

A SharePoint farm can have 20 web applications at max.  If we use path based site collections in order to have unique urls we need to create different web applications with different host names.

For example if we need to create following site collections

1. www.companyA.contoso.com/

2. www.companyB.contoso.com

3. www.portals.com

By using path based site collections we need to create 3 web application with appropriate host names. 

But by using host named site collections we can create one web application and 3 site collections with different urls.

Path based site collection are not scalable as we can create at max 20 web applications, while a sharePoint farm can have at max 250000 site collections using shared content database.

When to use Path Based site collections

1. You want separate application pools.

2. You have requirement of self service site creation feature. - You need to use a custom solution for self-service site creation with host-named site collections.

How to create HNSC

HNSC can be created only through powershell script

  1. Create web application
  2. Create root site collection (required for crawling)
  3. Create host named site collections
  4. Set alternate URLs for host named site collection

Let us have a closer look.

  • Create a web application (either through central admin or through powershell). 

I created through central admin

port – 100

Web app name – SharePoint – 100

  • Now create a root site collection.  When root site collection is crawled, all HNSC s also get crawled although they do not appear in content sources

New-SPSite 'http://<servername>:100' -Name 'Root Portal' -Description 'Root site collection' -OwnerAlias 'contoso\administrator' -language 1033 -Template 'STS#0'

  • Now create HNSC.  Use following powershell to create HNSC

New-SPSite 'http://CompanyA.contoso.com:100' -HostHeaderWebApplication 'http://<servername>:100’ -Name ‘CompanyA portal’ -Description 'Portal for CompanyA' -OwnerAlias 'contoso\administrator' -language 1033 -Template 'BLANKINTERNET#0'

New-SPSite 'http://CompanyB.contoso.com:100' -HostHeaderWebApplication 'http://<servername>:100’ -Name ‘CompanyB portal’ -Description 'Portal for CompanyB' -OwnerAlias 'contoso\administrator' -language 1033 -Template 'BLANKINTERNET#0'

Managed paths with host-named site collections

Managed paths can be used with host-named site collections.  Managed paths for HNSC are different from path based site collections.  Managed paths for HNSC are available to all HNSCs in the farm regardless of the web application.  They are limited to 20 per farm.  While managed paths for path based site collection do not apply to path based site collectioins in other web applications. 

To create managed path for HNSC we need to use powershell

New-SPManagedPath ‘dept’ –HostHeader

Now we can create HNSC with managed path

New-SPSite ‘http://CompanyA.contoso.com:100/dept/Technology’ –HostHeaderWbApplication ‘http://<servername>:100’ –Name ‘Technology’ –Description ‘Technology department’ –OwnerAlias ‘contoso\administrator’ –language 1033 –Template ‘BLANKINTERNET#0’

Managed path for path based site collection can be defined at central admin or using powershell

New-SPManagedPath [-RelativeURL] "</RelativeURL>" -WebApplication <WebApplication> creates managed path for a particular web application that can be used by path based site collections of that particular web application

Having done this you can check by browsing the site

Note : – In case you see a 404 error and if you are browsing the site on same local SharePoint server, you would need to change the host file to include then entry

for example to browse http://companyA.contoso.com:100 the entry in host file would be

127.0.0.1       companyA.contoso.com

Further you need to disable LoopBack in registry.  To do this manually open registry using regedit and nav to HKEY_LM\System\CCS\Control\LSA

Create dword key with name ‘DisableLoopbackCheck’.  Change the value to 1 for this.

It can also be done using powershell

New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -Value "1" -PropertyType dword

Wednesday, December 4, 2013

Get crawled property name for your column

 

I was desperately trying to find what is the crawled property name of my column scheduling end date. 

I stumbled across this helpful powershell

Function Get-CrawledPropertyNames([string]$DocURL){ 
$DocURL = $DocURL.Replace("%20"," ")
$webfound = $false
$weburl = $DocURL
while ($webfound -eq $false) {
    if ($weburl.Contains("/")){
    $weburl = $weburl.Substring(0,$weburl.LastIndexOf("/"))
    $web = get-spweb -identity $weburl -ea 0
    if ($web -ne $null){
        $webfound = $true
    }
    }else{
    Write-Host -ForegroundColor Red "The Web could not be found"
    return -1
    }
}
$web.GetFile($DocURL).item.xml.Replace("' ", "' `n").Replace("`" ", "`" `n")
} 

#To use enter the url of a file within a doucment library  Get-CrawledPropertyNames http://sites/doc/file.pdf

Got it from this link.

http://gallery.technet.microsoft.com/scriptcenter/Get-Crawled-Property-names-9e8fc5e0

Wednesday, October 2, 2013

Creating your own VHD for SP2013

 

Go to Hyper-V.

Click New VHD.

After installing basic OS we need to install AD.

Using following link install AD.

http://www.rackspace.com/knowledge_center/article/installing-active-directory-on-windows-server-2008-r2-enterprise-64-bit

  • Open Server Manager. To open Server Manager, click Start, point to Administrative Tools, and then click Server Manager.


  • In Computer Information, click Configure Remote Desktop.


  • In the System Properties dialog box, under Remote Desktop, click one of the following options:

    • Allow connections from computers running any version of Remote Desktop (less secure). Use this option if you do not know the version of Remote Desktop Connection that will be used to connect to this server.
    • Allow connections only from computers running Remote Desktop with Network Level Authentication (more secure). Use this option if you know that the users who will connect to this server are running Windows Vista or Windows Server 2008.

  • Review the information in the Remote Desktop dialog box, and then click OK twice.

    Make sure to give 2 processors

    http://absolute-sharepoint.com/2013/01/microsoft-sharepoint-server-2013-encountered-an-error-during-setup.html


  • Wednesday, July 24, 2013

    AD and SharePoint users sync

    Lot of times we encountered the problem where for testing we add users in AD and they do not get access to site the same time and even after doing User Profile Synchronization job run, we could not solve the problem.

    Turns out the below blog helped.

    http://blog.randomdust.com/index.php/2013/06/sharepoint-2013-claim-expiration-and-ad-sync/

    Wednesday, June 19, 2013

    Page cannot be displayed error while creating Web application

    While creating a new web application, a 404 'Page not found' error is displayed and the web application is only provisioned on the local server

    After a number of web applications have been created in the SharePoint 2010 farm, further attempts to create a new web application through Central Administration result in the following:

    The creation process results in a 'Page cannot be displayed' message.

    The web application is only provisioned on the Central Administration server.

    But if you try to create a site collection on this newly created web app, it fails. Reason is it is not completely done.

    After struggling this for a while I found you can resolve by increasing the Shutdown time limit in IIS to a greater value.

    Steps

    1. Go to application pool of Central Administration.
    2. Right click on it and go to Advanced Settings
    3. In the Process Model section, increase the shutdown time limit to 200 for example.
    4. It is a good idea to restart IIS now.
    5. After searching on net for a while I found that the reason is during the web application creation process IIS is reset and by default. It allows the "Shutdown time limit" which by default is 90 seconds. Sometimes this might not be enough. And hence it forcibly shuts down in 90 seconds.

    Saturday, June 1, 2013

    Server Error in ‘/’ Application. Runtime Error in SharePoint

    Open web.config file


    1. C:\inetpub\wwwroot\wss\virtualdirectories\” modify the web.config file

    a. In customErrors tag set mode="Off" to "On
    b. In SafeMode tag set CallStack="true" to false
    c. In Compilation tag Debug="false" to true

    2.If still you are facing default error page then follow below change
    In the layouts directory underneath the SharePoint root directory or 14 hive – C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS

    a. In customErrors tag set mode="Off" to "On
    b. In SafeMode tag set CallStack="true" to false
    c. In Compilation tag Debug="false" to true

    Wednesday, July 18, 2012

    Turning off custom errors in for debugging in SharePoint 2010



    As a developer, one of the first things I do after I have setup a web application & site collection is:
    Open the web.config (“C:\inetpub\wwwroot\wss\VirtualDirectories\(port)”) and set:

    1.change batch and debug to true - (compilation batch="true" debug="true" )
    2.change CallStack=”true” in safe Mode tag - (SafeMode CallStack="true")
    3.Change CustomErrors=”Off”
    However when I ran into exception, instead of getting the detailed message I was expecting, I ended up getting the infamous message telling me to change the customerrors setting in the web.config so that I can see the details:

    Server Error in '/' Application.

    After embarassingly long time I figured out there is another web.config in _layouts directory - C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14

    Custom errors need to be turned off here too.