Wednesday, May 14, 2014

Install and configure SharePoint 2013 Service Pack 1

Introduction

Purpose

The purpose of this document is to describe step by steps instructions that must be followed to consistently perform the installation and configuration of SharePoint Server 2013 SP1.

Assumptions

This includes the supporting servers and the servers that will have SharePoint 2013 installed. The following servers must be configured to support and host a farm:
·         Database server: The required version of SQL Server is SQL server 2012 enterprise version, including service pack 1 and cumulative updates must be installed during installation on the database server. The installation must include all features and administrative tools and packages. For additional information and guidance , see:

The data location should be set up on drive D or E as required.
·         Application servers and front-end Web servers: The farm servers that will have SharePoint 2013 installed must be prepared as follows: verify that they meet the hardware requirements, have the operating system updates. For additional information and guidance , see:
o    "Installing software prerequisites" in Hardware and software requirements for SharePoint 2013

Product Overview

SharePoint Server 2013 provides a comprehensive solution for connected information work that enables people to transform the way they work while preserving the benefits of structured processes, compliance, and existing IT investments.
SharePoint Server 2013 has been optimized for the way people work, providing people with a familiar, consistent view of information, collaboration, and process, and IT with a comprehensive, easily-managed and integrated platform to meet the needs of the business.

Product Inventory

Product Name
Version
Windows Server 2012 R2
6.3
SharePoint 2013 Service Pack 1
15.0.4569.1509
SQL Server 2012 Service Pack 1
11.0.3000.00
.Net Framework
3.5 and 4.5 (as part of windows installation)
Additional language packs may be downloaded and installed for SharePoint 2013.

User and Groups

Following service accounts are to be created in active directory with required complexity and password never expire. 

Account name
Account Description
ProfileSVC
This is Service account for User Profile synchronization
SearchSVC
This is service account for Search service applications
JobsvcsSVC
This is service account for execute all SCA jobs
FarmSVC
This is service account for Farm Configuration
ContentSVC
This is Service account for Search content access
ApppoolSVC
This is Service account for Web application pool account
svcsSVC
This is Service account for all SharePoint service applications
SOAsvcsSVC
This is service account for all interfaces
SetupSVC
This is Service account for setup and owner of site collection

Turn off UAC settings for service accounts

·           Open User Account Control Settings by clicking the Start button Picture of the Start button, and then clicking Control Panel. In the search box, type UAC, and then click Change User Account Control settings.

·           To turn off UAC, move the slider to the Never notify position, and then click OK.  Administrator permission required if you're prompted for an administrator password or confirmation, type the password or provide confirmation. You will need to restart your computer for UAC to be turned off.

UAC settings should be turned off by installation script.

Add services accounts to local administrator

Service accounts to be added, FarmSVC and SetupSVC.

Open Server Manager. Click Tool in the right corner of Server Manager and then select Computer Management.

In the Computer Management windows, expand Local Users and Groups and select Groups. Double click on Administrators group.





In the Administrators Properties, click Add...In the Select Users, Computers, Service Accounts, or Groups windows, type the account you want to add to Local Administrator group and then click OK.

Click OK.

Add service accounts to SQL users and grant permissions

·         Add FarmSVC and SetupSVC service accounts to SQL using this technet article.
·         Grant dbcreator and securityadmin.
Note :- SQL should be installed with setup account.

 Installation and Configuration of SharePoint Server 2013

Prerequisites for Installation and Configuration

Before you begin to install and configure SharePoint 2013, do the following:

Ensure that you have met all hardware and software requirements. You must have a 64-bit version of Windows Server 2012 R2 SP1. For server farms, you must also have a supported 64-bit version of SQL Server. For more information about these requirements, such as specific updates that you must install, see Hardware and software requirements for SharePoint 2013.

Ensure that you perform a clean installation of SharePoint 2013.

Ensure that you are prepared to set up the required accounts by using appropriate permissions. For detailed information, see Initial deployment administrative and service accounts in SharePoint 2013.

Install Window server 2012 R2 Roles/Features

  
This script installs all of the necessary Windows Server 2012 R2 Roles/Features to prepare for a SharePoint 2013 installation. This script supports installing the Roles/Features 'Online' with an Internet connection and 'Offline' without an Internet connection, using Windows server 2012 media.

 Windows Server 2012 R2 Environment Assumptions:

This script assumes (and does not check) that the following Windows Server 2012 R2 Features are installed (they should installed be by default in Windows Server 2012 R2):
·                     .NET Framework 4.5 Features (NET-Framework-45-Features)
·                     .NET Framework 4.5 Features > .NET Framework 4.5 (NET-Framework-45-Core)
·                     Windows PowerShell (PowerShellRoot)-Windows PowerShell > Windows PowerShell 3.0 (PowerShell)




Are you installing the Roles/Features 'Online' or 'Offline'?

·           If your server is 'Online' and you use the PrerequisiteInstaller.exe (i.e. out of the box), it will execute a PowerShell script to install the necessary Roles/Features to configure Windows Server 2012 R2 for SharePoint 2013. Part of the (PowerShell) Add-WindowsFeature installation installs the NET-Framework-Core feature which is .NET 3.5. This installation requires binaries and other files that are not included by default in Windows Server 2012 R2. This requires Windows Update to download/install these files and an Internet connection.
·           You need to have SharePoint 2013 SP1 media to run preinstaller.exe to configure web and app roles for windows server 2012 R2.
Procedure:
·         Download .zip file containing my scripts and extract the .ps1 files to c:\powershellscripts (or another directory of your choosing)
·         Run PowerShell as Administrator (you can do this from the Start Screen - right click PowerShell and select "Run as Administrator"
·         Ensure you have set your PowerShell execution policy to Remote-Signed (you can change it later if you need to)
·         Run this script: 
PowerShell
c:\powershellscripts\Install-SP2013RolesFeatures.ps1 
o   When you run the script, it will prompt you to decide if you are installing the Roles/Features 'Online' or 'Offline'. If you select 'Online' your server must have an Internet Connection. In this case, Windows Update will be used to download then install binaries and other files related to the installation of .NET 3.5. If you select 'Offline', the script will prompt you for the location of your Windows Server 2012 R2 installation media. The binaries and other files required are included in this media. Enter the path (without a trailing slash) to the 'sources\sxs' folder (for example D:\sources\sxs) of your Windows Server 2012 R2 installation media. This can be a mounted ISO, a local drive or a UNC path. Using the 'Offline' method will install the Roles/Features faster than the 'Online' method. 
o   The script will prompt you to Reboot your server after the Roles/Features have installed. You can opt in or out, but I recommend that you opt in and reboot your server as you need to in order for the Windows Features to be configured correctly.


Download SharePoint 2013 prerequisites


This script downloads the ENGLISH versions of the required Prerequisite files for SharePoint 2013 on Windows Server 2012 R2. It stores them in a directory of your choosing.

Procedure:
·      Create a local directory where the script can save the SharePoint 2013 Pre-requisite downloads. For example, c:\sp2013downloads.
·      Run PowerShell as Administrator (you can do this from the Start Screen - right click PowerShell and select "Run as Administrator"
·      Run this script: 
PowerShell
c:\powershellscripts\Download-SP2013PreReqFiles.ps1
·      You will be required to define a path where the script can save the downloaded files. (e.g. c:\sp2013downloads)

Install SharePoint 2013 prerequisites




This script utilizes the PrerequisiteInstaller.exe included in the SharePoint 2013 installation media to install the necessary prerequisites for SharePoint 2013 on Windows Server 2012 R2.
Assumptions:
You have downloaded the SharePoint 2013 installation media from MSDN, TechNet or Volume Licensing/Software Assurance etc.

Procedure:
·         You have already executed Install-SP2013RolesFeatures.ps1 and rebooted your server
·         You have already executed Download-SP2013PreReqFiles.ps1
·         Copy the SharePoint 2013 installation media files into a local directory on you Windows Server 2012 R2 server. For example, c:\sp2013.
·         Copy the Prerequisite files into the c:\sp2013\prerequisiteinstallerfiles directory.
·         Run PowerShell as Administrator (you can do this from the Start Screen - right click PowerShell and select "Run as Administrator"
·         Run this script:
PowerShell
c:\powershellscripts\Install-SP2013PreReqFiles.ps1
·         You will be required to define a path where to your SharePoint 2013 installation media. (e.g. c:\sp2013). Watch the Prerequisite installer tool install all of the prerequisites.
·         When the installer is complete, reboot your server prior to installing SharePoint 2013. You should now be able to run the SharePoint 2013 installer, bypassing the Pre-requisite step.


Installation and Configuration Procedure

Steps to configure and run AutoSPInstaller, a set of scripts that can be used to automatically install SharePoint.

By not having the original file present, we ensure that our environment specific file is loaded and forms a way of documenting the installation. You could also provide separate config.xml files with separate PIDs. To do this, rename the config.xml files and specify the new names in the AutoSPInstallerInput.xml file under the ConfigFile element.

Open the file and enter the SharePoint 2013 product key under the PIDKEY parameter. Once done, open the files in Internet Explorer to ensure they open without errors, i.e. that they contain well formed XML. Alternatively, use an XML editor.


Create following folders


Enter passphrase for SharePoint farm

Ensure that the passphrase meets the following criteria:
  • Contains at least eight characters
  • Contains at least three of the following four character groups:
    • English uppercase characters (from A through Z)
    • English lowercase characters (from a through z)
    • Numerals (from 0 through 9)
    • Non-alphabetic characters (such as !, $, #, %)

Add service accounts under required parameters in the AutoSPInstallerInput.xml file.



Add SQL Database Name

You can also create default site collection with required host header


Update app domain URL

Save AutoSPInstallerInput.xml

Run AutoSPInstallerLaunch.

Post Installation Activities

Configure environment for apps for SharePoint

Verify following DNS entries


Environment
DNS Name
Dev
MySiteCollection
Dev
*.myApps.MyDomain.com

Add certificates to IIS

Add following certificate to IIS using this article.

Environment
Certificate Name
Dev
MySiteCollection
Dev
*.myApps.MyDomain.com

Configure central certificate store for IIS

The CCS is based on a truly simple concept. Store all the certificates in a Windows File Server share, then have the Web site bindings use those instead of locally installed certificates. Not only does this reduce the chaos of installing certificates on multiple servers, it greatly reduces the management time and effort locating certificates that are about to expire.
Refer MSDN Article to configure CCS.
Export all certificate listed above to this CCS.

 Add a Website to host SharePoint Apps on App server

This step tells you how to add a website to IIS by using the IIS Manager UI, or by running Appcmd.exe commands in a command-line window.

Open IIS Manager.

For Windows Server 2012 R2, on the Start page click the Server Manager tile, and then click OK. In the Server Manager, click the Tools menu, and then click Internet Information Services (IIS) Manager.

In the Connections pane, right-click the Sites node in the tree, and then click Add Website.

In the Add Website dialog box, enter name SCA SharePoint Apps for your website in the Site name box.

If you want to select a different application pool than the one listed in the Application Pool box, click Select. In the Select Application Pool dialog box, select an application pool from the Application Pool list and then click OK.

In the Physical path box, enter the physical path of the website's folder, or click the browse button (...) to navigate the file system to find the folder.

Select the protocol for the website from the Type list, Select HTTPS.

Enter a port number 443 in the Port text box.

Enter a host header name MySiteCollection for the website in the Host Header box.

If you do not have to make any changes to the site, and you want the website to be immediately available, select the Start Web site immediately check box.

Click OK.



Friday, September 27, 2013

SharePoint Asynchronous Webpart Load

Issue Description

While working on SharePoint application development, we usually go with the development of custom web parts. These web parts are then placed on the respective pages as per the application requirements.
This is all good and easy from the development side. But looking at this from a performance perspective, the page load time depends on the total load time of the web parts. This load time can be effectively reduced by loading the web parts’ content asynchronously, as below.

Solution

1.       Using XMLHttpRequest in JavaScript

We can use AJAX to load the web part content, a sort of lazy loading, hence making the page load independent of their load times. A combination of client-side and server-side script is used to implement this.
The client-side XMLHttpRequest object is used to exchange data with a server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
When a request to a server is sent, we want to perform some actions based on the response. The onreadystatechange event is triggered every time the readyState changes. The readyState property holds the status of the XMLHttpRequest, while the status property indicates whether the response was retrieved successfully or not.
In the onreadystatechange event, we specify the processing to be done for the ready server response. When readyState is 4 and status is 200, the response is ready.
Three important properties of the XMLHttpRequest object:
Property
Description
onreadystatechange
Stores a function (or the name of a function) to be called automatically each time the readyState property changes
readyState
Holds the status of the XMLHttpRequest. Changes from 0 to 4:
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready
Status
200: "OK"
404: Page not found

2.       Using jQuery Ajax

The ajax() method is used to perform an AJAX (asynchronous HTTP) request. The parameters specify one or more name/value pairs for the AJAX request.
Some possible names/values in the table below:
Name
Value/Description
async
A Boolean value indicating whether the request should be handled asynchronous or not. Default is true
beforeSend(xhr)
A function to run before the request is sent
cache
A Boolean value indicating whether the browser should cache the requested pages. Default is true
complete(xhr,status)
A function to run when the request is finished (after success and error functions).
data
Specifies data to be sent to the server
dataType
The data type expected of the server response.
error(xhr,status,error)
A function to run if the request fails.
success(result,status,xhr)
A function to be run when the request succeeds
timeout
The local timeout (in milliseconds) for the request
type
Specifies the type of request. (GET or POST)
url
Specifies the URL to send the request to. Default is the current page
xhr
A function used for creating the XMLHttpRequest object

3.       jQuery $.get() Method

The $.get() method requests data from the server with an HTTP GET request.
This is a shorthand Ajax function, which is equivalent to:
$.ajax({
  url: url,
  data: data,
  success: success,
  dataType: dataType
});
The success callback function is passed the returned data, which will be an XML root element, text string, JavaScript file, or JSON object, depending on the MIME type of the response. It is also passed the text status of the response.

Syntax:
$.get(URL,callback);
The required URL parameter specifies the URL you wish to request. The optional callback parameter is the name of a function to be executed if the request succeeds. The following example uses the $.get() method to retrieve data from a file on the server:

Example for this implementation:
1)       Create a visual webpart NewsFeedWebpart that will display news articles and will also change news dynamically based on the category selected by the user from a drop down menu.
2)       When user selects a category from the dropdown, the getSelectedNewsFeeds() javascript function will be called, specified on client click for dropdown.  This function will create a new XMLHttpRequest object.
3)       Create a request to the AJAXServiceRequest.aspx application page, along with the required query string parameters, as required (action name and category Id, in this case).
4)       Once the response is received, the existing HTML of the news div is replaced with the new HTML fragment.
Add following code in NewsFeedWebpartUserControl.aspx.
a)       Script for XMLHttpRequest in JavaScript

<script language="javascript" type="text/javascript">

    function getSelectedNewsFeeds() {
        var ajaxRequest;
        var dropdown = document.getElementById('<%=ListSelectedNewsCat.ClientID %>');
        var filterVal = dropdown.options[dropdown.selectedIndex].value;

var ajaxDisplay = document.getElementById('<%=divNews.ClientID %>');

//This is to indicate to user about the processing
ajaxDisplay.innerHTML = 'Loading...';

if (window.XMLHttpRequest)
{ // code for IE7+, Firefox, Chrome, Opera, Safari
  ajaxRequest =new XMLHttpRequest();
}
else
{ // code for IE6, IE5
  ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
}       

        ajaxRequest.onreadystatechange = function () {
            if (ajaxRequest.readyState == 4 && xmlhttp.status == 200) {
                var response = ajaxRequest.responseText;
                ajaxDisplay.innerHTML = response;
            }
        }

        var queryString = "?queryaction=ProcessForNewsFeed&category=" + filterVal;
        ajaxRequest.open("GET", "/_layouts/AJAXServiceRequest.aspx" + queryString, true);
        ajaxRequest.send(null);
    }
 
</script>

b)       Script for  $.ajax() in jQuery

<script language="javascript" type="text/javascript">

    function getSelectedNewsFeeds() {
     
    var filterVal = $("[id$='ListSelectedNewsCat'] option:selected").val();
    var ajaxDisplay = $("[id$='divNews']");

    //This is to indicate to user about the processing
    ajaxDisplay.html('Loading...');

    var queryString = "?queryaction=ProcessForNewsFeed&category=" + filterVal;
    var requestString = "/_layouts/AJAXServiceRequest.aspx" + queryString;

    $.ajax({
       url: requestString,
       success: function (result) {
           ajaxDisplay.html(result);
       }
    });
    }
 
</script>

c)       Script for $.get() in jQuery

<script language="javascript" type="text/javascript">

   function getSelectedNewsFeeds() {

        var filterVal = $("[id$='ListSelectedNewsCat'] option:selected").val();
        var ajaxDisplay = $("[id$='divNews']");

        //This is to indicate to user about the processing
        ajaxDisplay.html('Loading...');

        var queryString = "?queryaction=ProcessForNewsFeed&category=" + filterVal;
        var requestString = "/_layouts/AJAXServiceRequest.aspx" + queryString;

        $.get(requestString, function (data, status) {
            if(status == "success")
            {
                ajaxDisplay.html(data);
            }
        });
   }
 
</script>


HTML snippet to add dropdown and div on the page

<div>
    <asp:DropDownList ID="ListSelectedNewsCat" runat="server" onclientclick=" getSelectedNewsFeeds();” DataTextField="Title" DataValueField="ID">
    </asp:DropDownList>
</div>
<div class="divNews" runat="server" id="divNews">
</div>


5)       Get query string parameters in the server side script and call appropriate method to generate news feed HTML for selected category.
For this, create an application page AJAXServiceRequest.aspx in layouts folder. This page will be called by all AJAX requests. Add following code in AJAXServiceRequest.aspx.cs to format the HTML and return it as response for the request.
Return final html using AntiXss.GetSafeHtmlFragment.
AntiXss.GetSafeHtmlFragment: Returns well-formed HTML fragments (does not try and add <html> or <body> tags).

protected void Page_Load (object sender, EventArgs e)
{

//// Process For News Feed
if (Request.QueryString[“queryaction”] != null &&   Request.QueryString[“queryaction”].ToString().Equals(“ProcessForNewsFeed”))
     {
                string formattedText = string.Empty;
                string category = Request.QueryString[“category”];
                formattedText = NewsFeedHelper.ProcessMainNews(category);
                Response.Write(formattedText);
                Response.End();
     }
}
public static string ProcessMainNews (string id)
{
//// code to generate news feed html
                return AntiXss.GetSafeHtmlFragment(html);
}