Thursday, September 27, 2012

SSL Site with Host Headers in IIS 7

We cannot use the IIS7 User Interface to add a host header to an SSL site binding. The Host name field will get disabled once we select the Type as https.

One way to add a host header to an SSL site binding is by using command-line tools. Another way is edit the applicationhost.config file directly.

1.  Add SSL bindings to your web sites with empty host headers
2. Find applicationhost.config file located in “C:\Windows\System32\inetsrv\config”. You need administrator permission to edit this file (Use Notepad in ‘Run as administrator’ mode )
3.  Search for the value ‘443’ in Find applicationhost.config file
4.  You can find “bindings” section inside the site node

5.  Add the required host header in bindingInformation property

6.  Save the applicationhost.config file
7.  Refresh IIS Manager and you can notice host header in https binding

Thursday, September 13, 2012

PowerShell Error in SharePoint Server - Cannot Access the Local Farm

I was using a PowerShell script to deploy my SharePoint solution in the development environment for some time now. But when I try to use the same script in a newly configured SharePoint environment I got the following error.

“Get-SPSolution : Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permissions to access the database before trying again.”



In my deployment script I have used “Get-SPSolution” command and it seemed like this command was failing due a configuration error in the local farm. So I tried to re-run the SharePoint 2010 Products Configuration Wizard and got the following error.

“Failed to detect if this server is joined to a server farm. Possible reasons for this failure could be that you no longer have the appropriate permissions to the server farm, the database server hosting the server farm is unresponsive, the configuration database in inaccessible or this server has been removed from the server farm.”
























When I click “OK” on the popupbox, Database server and Database name were marked as Unknown and “Do not disconnect from this server farm” option was disabled.


Issue in my case:
Executing sp_helpserver in SQL Server management studio of the server gave me a wrong name as the server name and same wrong name as the network name of the server. (You will come across this scenario when the computer hosting SQL Server is renamed).

In addition to the above issue, the domain account I used to do the deployment didn’t have permissions to access the databases, even though it was added as a local administrator account of the server. 


Solution:
In order to correct the server name in the SQL server, first I used sp_dropserver command. This command removes a server from the list of known remote and linked servers on the local instance of SQL Server.
sp_dropserver 'WrongServer'

Then I used sp_addserver command to define the name of the local instance of SQL Server.  This command actually informs the new computer name to the instance of the SQL Server Database Engine.
sp_addserver 'CorrectServer'

Finally granting DB permission to the domain account solved my issue.