Wednesday, May 30, 2012

I was recently setting up a new virtual test box for SharePoint to work on developing a new project and was trying to mimic my production network with sever and site collection names, however I was getting a prompt to enter my username and password but even entering my credentials I was still not able to access my site. My dev server name was SP2010-SP which is where my central admin site was as well as my first site collection, even this site was giving me issues with login, to make it more interesting I created 2 additional sites at dashboard.company.com and portal.company.com using host headers so I could use port 80. The solution that worked was to do the following:

Specify host names (Preferred method if NTLM authentication is desired)
To specify the host names that are mapped to the loopback address and can connect to Web sites on your computer, follow these steps:
  1. Set the DisableStrictNameCheckingregistry entry to 1. For more information about how to do this, click the following article number to view the article in the Microsoft Knowledge Base:
    281308  (http://support.microsoft.com/kb/281308/ ) Connecting to SMB share on a Windows 2000-based computer or a Windows Server 2003-based computer may not work with an alias name
  2. Click Start, click Run, type regedit, and then click OK.
  3. In Registry Editor, locate and then click the following registry key:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
  4. Right-click MSV1_0, point to New, and then click Multi-String Value.
  5. Type BackConnectionHostNames, and then press ENTER.
  6. Right-click BackConnectionHostNames, and then click Modify.
  7. In the Value data box, type the host name or the host names for the sites that are on the local computer, and then click OK.
  8. Quit Registry Editor, and then restart the IISAdmin service.

Thursday, May 24, 2012

The holy grail for SharePoint developers just getting started

While recently looking for some code samples for creating a custom web part I came across this little gem from Microsoft, the SharePoint 2010 Code Samples 101 download located here: http://code.msdn.microsoft.com/SharePoint-2010-101-Code-da251182

This is a great collection of Visual Studio Solutions written in C# to get you started on your next custom project for SharePoint 2010.

Tuesday, May 22, 2012

Create a SharePoint sub site from a site export

Our issue was some 3rd party web parts were not allowing us to save a site as a template through the normal way of going into the Site Actions > Site Settings > Save Site as a template.

Our solution involved using Powershell to do an export of the site we wanted to use as a template. The main challenge with this is that you need to first create a SharePoint site, then do an Import-SPWeb to restore the site that was exported, then set the title and description. (This works with both http and https sites.)

# Define root site where the shell of the sub site will be created under
$site = "https://portal/"
   
Write-Host "Please enter the Title of the site to create"       
$webTitle = Read-Host "Please enter the title of the site you wish to create"    
$newSiteUrl = "https://portal/$webTitle"     
# Create empty subsite
$web = New-SPWeb $newSiteUrl -name $webTitle -UseParentTopNav
# Use the base SharePoint template of STS#1
$web.ApplyWebTemplate("STS#1")
# Give the site a name
$web.Name = $webTitle
# Apply changes
$web.Update()
# Since we are using a custom template for the sites we will want to set some variables
$templateName = "https://portal/$webTitle"
$templateLocation = "C:\Temp\Template\site.bak"
# Restore the site from the back up
Import-SPWeb $templateName -Path $templateLocation -IncludeUserSecurity
# We need to update some properties of the restored site, so we set the site as a variable
$web = (Get-SPWeb -Identity "https://portal/$webTitle")
# Once the site is restored this will overwrite the title and description which we set here
$web.title =$webTitle
$web.description = "Template Site"
# Update the site
$web.update()
# Clean it up
$web.dispose()
  
Write-Host "The Installation is complete please visit the site at" $web.URL