Thursday 4 April 2013

[SP2010] - Open InfoPath 2010 form template in Modal dialog window

When publishing a custom InfoPath 2010 form template (using either the form template or blank form template), it is set to open in the browser by default.

The instructions below will take you through the steps of and opening a custom form template in a modal dialog window using HTML and JavaScript.

Step 1:  Create JavaScript file to open form in Modal dialog
  • Using SharePoint Designer 2010, create a new folder in your Style Library called "js"
  • Open the js folder and create a new JavaScript file from the Ribbon menu called "OpenModalDialog.js"
  • Add the code below to your JS file
 function openMyListDialog()   
 {  
  var options = {  
    url: '/blog/Lists/MyList/item/newifs.aspx',  
    title: "MyList - New Item",  
    dialogReturnValueCallback: function (dialogResult)   
    {  
       SP.UI.ModalDialog.RefreshPage(dialogResult);  
       if(dialogResult==1){     
       }  
    },  
    allowMaximize:false  
  };  
  SP.UI.ModalDialog.showModalDialog(options);  
  HideRibbon();  
 }   
 function HideRibbon()  
 {  
      $('.ms-dlgFrame').load(function () { $('.s4-pr.s4-ribbonrowhidetitle', frames[1].document).hide();});  
 }  


  • Replace the url value to point to your InfoPath form
  • If you reference a Form Template then the HideRibbon function can be used to hide the ribbon in the Modal Dialog
Step 2: Add hyperlink to open form to page
  • Add a content editor web part to your page
  • Add the code below to the content editor web part
 <script src="/Style%20Library/js/OpenModalDialog.js" type="text/javascript"></script>  
 <a onclick="javascript:openMyListDialog();return false;" href="#" target="_self">Open My List in Modal Dialog</a>  

The snippet above reference the JavaScript file on your page and also add a hyperlink to the page.  The hyperlink calls the openMyListDialog() function that will open in a modal dialog.

The end result:





Thursday 28 February 2013

[SP2010] - Limiting the Reporting Extensions in SSRS 2012 SharePoint Integrated Mode

By default, the Report Viewer web part in SharePoint allows you to export published reports in various rendering formats. See screenshot below: 




If you would like to limit these rendering extensions on your SharePoint farm you can use the PowerShell command listed below.  The script finds an SSRS application called "SSRS Service App"  (remember to replace this with then name of your SSRS service app) and hides the XML export options from the Actions menu.

 $apps = Get-SPRSServiceApplication | where {$_.name -like "SQL Server SSRS"}  
 Set-SPRSExtension -identity $apps -ExtensionType "Render" -name "XML" -ExtensionAttributes "<Visible>False</Visible>"   
 Set-SPRSExtension -identity $apps -ExtensionType "Render" -name "CSV" -ExtensionAttributes "<Visible>False</Visible>"   
 Set-SPRSExtension -identity $apps -ExtensionType "Render" -name "MHTML" -ExtensionAttributes "<Visible>False</Visible>"   
 Set-SPRSExtension -identity $apps -ExtensionType "Render" -name "WORDOPENXML" -ExtensionAttributes "<Visible>False</Visible>"   
 Set-SPRSExtension -identity $apps -ExtensionType "Render" -name "IMAGE" -ExtensionAttributes "<Visible>False</Visible>"   
 
In my example the end result will only show the PDF and Excel extensions as below.




Thursday 8 November 2012

[SP2010] - Configuring Kerberos Authentication for BI

In this post I will take you through the steps of configuring Kerberos authentication for SharePoint 2010 Business Intelligence.  Now I know that alot of people out there get stomach cramps when you here the word "Kerberos", but I can assure you that it is really not that bad.  Follow the steps in this article and you should have your environment ready in no time.

My post will cover Kerberos setup for a Small SharePoint 2010 farm using SQL Server Reporting Services 2012 (SSRS 2012) as an example.


High level requirements:
Step 1:  Enable Kerberos Authentication on your SharePoint Web Application
Step 2:  Create SPNs for your Web Application Application Pool Account
Step 3:  Create SPN for  Reporting Services Service Application Application Pool Account
Step 4:  Create SPNs for SQL Server Database Engine service account
Step 5:  Configure delegation on Web Application Application Pool Account
Step 6:  Configure delegation on Reporting Services Service Application Pool Account
Step 7:  Configure Claims To Windows Token Service delegation
Step 8:  Configure Claims To Windows Token Service delegation
--------------------------------------------------------------------------------------------------------------------------

Step 1:   Enable Kerberos Authentication on your SharePoint Web Application

  • Open Central Admin, select "Manage Web Application" under the "Manage Web Applications" section.
  • Select your web application and click the Authentication Providers button in the Ribbon

  • Select the default zone
  • Change the IIS Authentication settings as per the screen shot below and save
  • Start the Claims to Windows Token Service in Central Administration if it is not running!

Step 2:  Create SPNs for you Web Application Application Pool Account

In this step we are going to create SPNs on the Application Pool account (identity)  for the Web Application's host name.
  • On your domain controller, open command prompt and use the commands below:
          SetSPN -S http/gsp2010webf1 gdom\svc_sp_ap
          SetSPN -S http/gsp2010webf1.gdom.local gdom\svc_sp_ap
     
Note!  All SharePoint Server web application, regardless of the port number, use the following SPN format:
  • HTTP/<DNS HOST name>
  • HTTP/<DNS FQDN>
Step 3: Create SPN for Reporting Services Service Application Application Pool Account

In this step we create a dummy SPN for the SSRS Service Application's Applicatoin Pool account.  This is required so that SharePoint can delegate authentication from the Web Application to the SSRS Service Application.

  • On your domain controller, open command prompt and use the commands below:
          SetSPN -S sp/rs gdom\svc_sql_ssrs

Note!  In this example I use sp/rs, but this can be anything as this is a dummy SPN.

Step 4: Create SPNs for SQL Server Database Engine service account
          
In this step we create SPNs on the SQL Database Engine service account (identity).  This is required to setup contrained delegation for the SSRS Service Application to SQL Server.

  • On your domain controller, open command prompt and use the commands below:
          SetSPN -S MSSQLSvc/gsqlf1:1433 gdom\svc_sql_dbe
          SetSPN -S MSSQLSvc/gsqlf1.gdom.local:1433 gdom\svc_sql_dbe

 Step 5:  Configure delegation on Web Application Application Pool Account

In this step we configure delegation on the Web Application Application Pool account.  This account needs to be able to delegate to the SPN that we have created for the SSRS application pool in step 3.

  • On your domain controller, open Active Directory Users and Computers
  • Open your SharePoint App Pool account's properties
  • Select "Trust this user for delgation to specified services only" (Constrained Delegation)
  • Select "User any authentication protocol"
  • Click add and search for the SSRS service account
  • Select the SPN that was created for the account and add it.


 Step 6:  Configure delegation on Reporting Services Service Application Pool Account

In this step we configure delegation on the SharePoint SSRS Application Pool account.  This account needs to be able to delegate to the SPN that we have created for the SQL Server database engine (DBE) service account in step 4.

  • On your domain controller, open Active Directory Users and Computers
  • Open your SSRS Application Pool account's properties
  • Select the Delegation Tab
  • Select "Trust this user for delgation to specified services only" (Constrained Delegation)
  • Select "User any authentication protocol"
  • Click add and search for the SQL DBE service account
  • Select the SPN that was created for the account and add it.



Step 7:  Configure Claims To Windows Token Service delegation

SharePoint internally uses claims authentication when "talking" to it's respective databases.  The Claims to Windows Token Service (C2WTS) is reponsible for converting Claims to a Windows token so that we can talk to SQL.

By default, this account run as a Local System account.  To setup delegation for your C2WTS you can either change this account to a domain service account and delegate to SQL from that account, or you can setup your delegation on the machine name that the C2TWS service is running on. In my example I've configured delegation on the machine name to reduce the admin overhead of managing another service account for SharePoint.
 
  • On your domain controller, open Active Directory Users and Computers
  • Under Computers, open your SharePoint server running the C2WTS
  • Select the Delegation Tab
  • Select "Trust this user for delgation to specified services only" (Constrained Delegation)
  • Select "User any authentication protocol"
  • Click add and search for the SQL DBE service account
  • Select the SPN that was created for the account and add it.


Step 8:  Grant SSRS Application Pool account access to Content Database

A required step in configuring SharePoint Server 2010 Office Web Applications is allowing the web application’s service account access to the content databases for a given web application.

Run the PowerShell commands below to give your SSRS account access to the Content DB:


$w = Get-SPWebApplication -Identity http://gsp2010webf1
$w.GrantAccessToProcessIdentity("gdom\svc_sql_ssrs")

 Note!  Change the above URL and service account as configured on your environment.

Thursday 4 October 2012

[SP 2010] - Change Navigation Editing and Sorting limit

By default when you navigate to Site Settings -> Navigation Settings you would find that SharePoint only show the first 50 items (pages) in the Navigation Editing and Sorting.  When you have more than 50 pages in the Pages library these pages will not show up under the Navigation Editing and Sorting section, hence you wouln't be able to add them to the Quick Launch navigation.


In order to show all items in your Pages library in the "Navigation Editing and Sorting" navigation pane, you would need to make a slight change to your web.config file on each Web Front-End server in your farm.

Step 1:  Open your web.config file and search for "CurrentNavSiteMapProvider"

Step 2: Add the DynamicChildLimit=”0” property to this tag as in the code snippet below

 <add name="CurrentNavSiteMapProvider" description="CMS provider for Current navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" EncodeOutput="true" DynamicChildLimit="0" />  

Once you have saved your web.config file you should see all your pages in the "Navigation Editing and Sorting" navigation pane.

Tuesday 2 October 2012

[SP2010] - Term store management link missing

When you create a new Site Collection using the "Blank Template" you would find that the "Term store management" link is missing under the Site Administration settings:



Run this STSADM command below to activate this hidden Site Collection feature to display the missing "Term store management link" on your site settings page.

 stsadm -o activatefeature -id "73EF14B1-13A9-416b-A9B5-ECECA2B0604C" -url http://yoursiteurl/yoursitecollection -force  

Once you have activated this feature you should see the link under Site Administration as below.

Thursday 27 September 2012

[SP2010] - Add the Profile Status Notes Control to Master Page

The My Profile Status Notes control that is found on the My Profile page (person.aspx) can easily be added to your custom Master Page using SharePoint Designer 2010.


In my example below I have added the Status Control to the header section on my custom Master Page, but this can also be added to any Page Layout that you use on your site. 


The Status Control is a Server Control that needs to be registered on your Master Page before you can use the control.  Once registered you can add the control tag to your Master Page and use the CSS to style the default look and feel of the Status Control if you wish.  Follow the instructions below to implement this functionaly:

1. Open your site in SharePoint Designer 2010 and edit your Master Page in Advanced Mode.


2. Add the sample code below to the top of your Master Page to register the Server Control.


 <%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>  


3.  Add the Status Notes Control tag to your Master Page.

 <SPSWC:StatusNotesControl runat="server"/>  


4. Save the  CSS styles below in a .css file and store it in your Style Library. Once done, reference the CSS file used by your site by navigating to Site Settings - > Master page.


Note that a reference can also be added to your Master Page in SharePoint Designer to reference the CSS file.

Tuesday 25 September 2012

[SP2010] - Image Rotator Web Part that links to a SharePoint Picture Library

If you have used the OOTB SharePoint Image Rotator (Picture Library Slideshow ) web part then I'm sure you will agree that there is room for improvement.  I've taken some time to build an alternative easy to use jQuery slideshow web part that can be used on any page in your SharePoint site.  This solution reads images from a SharePoint Picture Library and transition through them using the jQuery slider plugin.


This code is easy to use, but if you're looking for a more scalable and robust solution then I suggest you look at building and packaging a solution using Visual Studio.

NB!  Ensure that your SharePoint Server Publishing Infrastructure Site Collection feature is enabled on your site.  By activating this, SharePoint will create the Style Library that we will use to store our JavaScript files.

Step 1:  Copy jQuery and CSS files to Site Collection Style Library
Step 2:  Add JavaScript reference and CSS reference to Site MasterPage
Step 3:  Create Picture Library
Step 4:  Add Content Editor web part to SharePoint page

-------------------------------------------------------------------------------------------------------------------

Step 1:  Copy jQuery and CSS files to Site Collection Style Library
  • Click here to download the jQuery slider plugin file (slides.min.jquery.js)
  • Click here to download the CSS Stylesheet (jslider.css)
  • Open your site in SharePoint Designer 2010 and navigate to your Style Library
  • Copy the CSS file to the root Style Library folder
  • Create a new folder called js in the root Style Library folder
 

  • Copy the download jquery plugin and paste it into the created js folder


Step 2: Add JavaScript reference and CSS reference to Site MasterPage

  • In SharePoint Designer 2010, Check Out your Master Page and edit the file in Advanced Mode

  • Add the code below just above the closing </head> tag

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
  
 <script src="../../Style Library/js/slides.min.jquery.js" type="text/javascript"></script>
  
 <link rel="stylesheet" type="text/css" href="../../Style%20Library/jslider.css"/>
  

  • Ensure that your can access all the files referenced in the code and save all changes.
Step 3: Create Picture Library

  • Create a Picture Library called SlideShow on the root site of your Site Collection
  • Upload sample images and give each image a Title value
Step 4:  Add Content Editor web part to SharePoint page

  • Add a Content Editor web part to your SharePoint Page
  • Click on the "Click here to add new content" text to show the web part options in the Ribbon
  • On the Ribbon, select the HTML button in the Markup section as shown below


  • Paste the code below in the HTML Source Modal dialogue window and click OK. (download file here)

 <div id='container'>  
 <div id='example'>  
 <div id='slides'>  
 <div class='slides_container'>  
 </div>  
 <a href='#' class='prev'><img src='/Style Library/Images/jslides/arrow-prev.png' width='24' height='43' alt='Arrow Prev'/></a>  
 <a href='#' class='next'><img src='/Style Library/Images/jslides/arrow-next.png' width='24' height='43' alt='Arrow Next'/></a>  
 </div>  
 <img src='/Style Library/Images/jslides/example-frame.png' width='739' height='341' alt='Example Frame' id='frame'/>  
 </div>  
 </div>  
 <script type="text/javascript">  
 $(function(){  
 function GetAllImages()   
 {  
      var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'><soapenv:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>";  
   //The name of the image library is called 'SlideShow'. Replace the name below with the name of your image library  
  soapEnv += "<listName>SlideShow</listName>";  
   soapEnv += "<query><Query><OrderBy Override='TRUE'><FieldRef Name='Created' Ascending='FALSE' /></OrderBy></Query></query>";  
   soapEnv += "<viewFields><ViewFields><FieldRef Name='Title'/><FieldRef Name='ows_FileLeafRef'/><FieldRef Name='Description'/></ViewFields></viewFields><rowLimit></rowLimit>";  
   soapEnv += "</GetListItems></soapenv:Body></soapenv:Envelope>";  
 var port = window.location.port;  
 if (port.length <= 0)  
  port = "";   
 else  
  port = ":"+port;  
 var webservice = window.location.protocol+"//"+window.location.hostname+port+L_Menu_BaseUrl+"/_vti_bin/lists.asmx";  
   $.ajax({  
     url: webservice,  
     type: "POST",  
     dataType: "xml",  
     data: soapEnv,  
     complete: processQueryResults,  
     contentType: "text/xml; charset=utf-8",  
      error: function(xhr) {  
     alert('Error! Status = ' + xhr.status);}  
   });  
 }  
 function processQueryResults(xData, status)  
 {  
 var port = window.location.port;  
 if (port.length <= 0)  
  port = "";  
 else  
  port = ":"+port;  
 //Change the below to point to your image library  
 var imageURL = window.location.protocol+"//"+window.location.hostname+port+L_Menu_BaseUrl+"/SlideShow/";  
 var itemURL = window.location.protocol+"//"+window.location.hostname+port+L_Menu_BaseUrl+"/SlideShow/Forms/DispForm.aspx?ID=";  
 $(".slides_container").html("")  
 $(xData.responseXML).find("z\\:row").each(function() {  
  var title = $(this).attr("ows_Title");  
  var desc = $(this).attr("ows_Description");  
  var imageLink = imageURL+$(this).attr("ows_FileLeafRef").substring($(this).attr("ows_FileLeafRef").indexOf('#')+1);   
  var itemLink = itemURL+$(this).attr("ows_ID");  
  var liHtml = "<div class='slide'><img width='570' border='0' height='270' src='" + imageLink +"'/><div class='caption' style:'botton:0'><p>" + title + "</p></div></div>";  
      $(".slides_container").append(liHtml);  
   });  
 $('#slides').slides({  
           preload: true,  
           preloadImage: 'http://demo/Style Library/Images/jslides/loading.gif',  
           play: 5000,  
           pause: 2500,  
           hoverPause: true,  
           animationStart: function(current){  
                $('.caption').animate({  
                bottom:-35  
                },100);  
                if (window.console && console.log) {  
                     // example return of current slide number  
                     console.log('animationStart on slide: ', current);  
                };  
           },  
           animationComplete: function(current){  
                $('.caption').animate({  
                     bottom:0  
                },200);  
                if (window.console && console.log) {  
                     // example return of current slide number  
                     console.log('animationComplete on slide: ', current);  
                };  
           },  
           slidesLoaded: function() {  
                $('.caption').animate({  
                     bottom:0  
                },200);  
           }  
      });     
 }  
 GetAllImages();  
 });  
 </script>