Click here to Skip to main content
11,717,570 members (77,748 online)
Click here to Skip to main content

Tagged as

How to create default groups in SharePoint 2013 Host-Name Site Collection?

, 27 Jun 2014 CPOL 4K 3
Rate this:
Please Sign up or sign in to vote.
How to create default groups in SharePoint 2013 Host-Name Site Collection?

What is Host-Named Site Collection?

Host-named site collections enable you to assign a unique DNS name to site collections. For example, you can address them as http://TeamA.contoso.com and http://TeamB.contoso.com. This enables you to deploy many sites with unique DNS names in the same web application. It also enables hosters to scale an environment to many customers. If you do not use host-named site collections, your SharePoint web application will contain many path-based site collections that share the same host name (DNS name). For example, Team A has a site collection at http://contoso.com/sites/teamA, and Team B has a site collection at http://contoso.com/sites/teamB.

You can read more about the Host-named site collection architecture and deployment in SharePoint 2013 here. This article has listed a very good comparison of host-name site collections to the path based site collections. However, one of the key advantage which host-named site collection offers is the transparent experience to the end users which was difficult to achieve in earlier versions of SharePoint. Till SharePoint 2010, the only way to have a dedicated URL mapping was on a Web Application level through alternate access mapping.

It should be noted that there is no user interface to create a host-named site collection from SharePoint 2013 Central administration and is possible only via PowerShell command, which is not very complex either. Below example shows how to create a host-name site collection which can be accessed via the DNS entry http://manasbhardwaj.net

Add-PSSnapin Microsoft.SharePoint.PowerShell 

$currentUser = "$env:USERDOMAIN\$env:USERNAME" 
$siteCollectionUrl = "http://manasbhardwaj.net"
$siteCollectionName = "Manas Dev Site"
$webApplicationUrl = "http://manas"

New-SPSite -Url $siteCollectionUrl -OwnerAlias $currentUser -Name $siteCollectionName -Language 1033 -HostHeaderWebApplication $webApplicationUrl -Template sts#0

Create Default Groups in a Host-Named Site Collection

However, when you use the above script to create a host-named site collection it does not create the default groups (such as Owners, Members and Visitors) which are available if the site collection is created using the Central Administration user interface.

Host Named Site Collection

Look at the image above and you can see the groups are missing. But the good news is that it is still possible to create the default groups using a couple of lines of script.

Add-PSSnapin Microsoft.SharePoint.PowerShell 

$currentUser = "$env:USERDOMAIN\$env:USERNAME" 
$siteCollectionUrl = "http://manasbhardwaj.net"
$siteCollectionName = "Manas Dev Site"
$webApplicationUrl = "http://manas"

New-SPSite -Url $siteCollectionUrl -OwnerAlias $currentUser -Name $siteCollectionName -Language 1033 -HostHeaderWebApplication $webApplicationUrl -Template sts#0

$web = Get-SPWeb $siteCollectionUrl
$web.EnsureUser($currentUser)
$web.CreateDefaultAssociatedGroups($currentUser, "", "")

What you need to do is call the CreateDefaultAssociatedGroups once your site collection has been created. And this will ensure that the default groups are created for the specified site collection.

Host Named Site Collection_With Groups

Update hosts file (on local Development Environment)

If you want to create a host-named site collection on your development environment, you might need to update your local host file to create an entry for the specified Url. In a real test or production environment, you would have a actual DNS VIP entry which you can use to redirect to your site collection. So, for e.g.

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

127.0.0.1 manasbhardwaj.net

This post How to create default groups in SharePoint 2013 Host-Name Site Collection? written by Manas Bhardwaj appeared first on Manas Bhardwaj's Stream.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Manas Bhardwaj
Architect
Netherlands Netherlands
Read my personal blog at www.manasbhardwaj.net.

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150901.1 | Last Updated 27 Jun 2014
Article Copyright 2014 by Manas Bhardwaj
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid