Showing posts with label Sharepoint2013. Show all posts
Showing posts with label Sharepoint2013. Show all posts

Wednesday, April 20, 2016

SharePoint Development Models

As mentioned in my last blog about Uses of SharePoint, that SharePoint does not only rely on the features or functions it provides out of the box, but the implementation can be customized to streamline pretty much any aspect of business collaboration.

There are many ways of development in SharePoint, majorly categorized as below:

  1. Server Side Object Model : These are those solutions which are created in Visual studio and deployed on SharePoint server only. Microsoft provides Microsoft.Sharepoint.dll for its implementation.
  2. Client Side Object Model: These are the solutions which are created in either .Net or some other language like JavaScript but are not deployed on SharePoint server. These could be used in SharePoint sites or somewhere else.
    Microsoft provides two ways for this implementation:
    .Net Managed CSOM: Microsoft provides Microsoft.Sharepoint.client.dll for this. As .Net is used in this object model people often refer to it as server side code but actually it is part of client side object model as it is not deployed on the SharePoint server.
    JavaScript Object Model: Microsoft provides SP.js javascript library. SharePoint itself uses this js library. Apart from this Jquery also provides library SPservices.js for connecting to SharePoint
  3. SharePoint Designer: SharePoint Designer is software program which connects to SharePoint site and making basic changes like updating pages, developing basic workflows etc. These pages are stored in the SharePoint database like all other SharePoint pages.
  4. SharePoint APIs:These are used majorly for your remote mobile or web applications. 
    Rest APIs: This MSDN article details how to use SharePoint REST interface. SharePoint 2013 also provides support for oData in your REST queries. This article on MSDN pretty well explains how to use oData in REST requests
  5. SharePoint App Model: This is not exactly a development model like above. It was introduced in SharePoint 2013. Now we could create a separate server on domain to deploy applications. These applications could use any of the above model apart from 1st. These apps are used on SharePoint portal. SharePoint authenticates these apps using oauth. 

Thursday, February 18, 2016

Make all SharePoint Surveys truly anonymous real quick

If you have worked withe surveys, you must be knowing survey provide an option "Show user names in survey results", to make survey anonymous, If not you could refer this. Now the problem with this is anyone with rights to edit list settings could change this setting and all users would be visible. 

There is no suggested approach to do this there are lots of options available. One very nice article is available on this msdn blog. Mostly suggested changing the name using event receiver or workflows. But none of these serve my purpose, as i needed to make all the surveys on the farm anonymous including the new ones. Also with hundreds of surveys across the farm, these workflows or event receivers could hamper performance.


So, i did a small trick to make sure no one to change the list setting and rest SharePoint could handle automatically.


I made some tweaking in the application page witch impacted all my surveys. We could also do the same for a particular site.


We will have to make changes in two application pages, available in layouts folder of 15 hive. Combined these changes will give an effect to of no in survey setting.



  1. ListGeneralSettings.aspx : This page opens when we click "ListName, Description, Navigation in site settings.
  2. New.aspx : This page opens when we create a new survey list. Page URL is same for both popup and advanced options page.
ListGeneralSettings:
Search for "Survey Settings" and make radio button with id "RADShowUserYes" hidden by adding attribute visible:false. This will hide the yes option in List settings.

New.aspx: We will make two changes in this file.
  1. To make sure user can not select yes on advanced options screen. To do this find the below ts tag and comment it.
    <td class="ms-authoringcontrols" nowrap="nowrap"><input id="onetidShowUserNamesNo" type="radio" value="on"  name="showUsernames" title="<SharePoint:EncodedLiteral runat='server' text='<%$Resources:wss,lstsetng_showusernamesyes_title%>' EncodeMethod='HtmlEncode'/>" /><label for="onetidShowUserNamesYes"><SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,lstsetng_showusernamesyes_label%>" EncodeMethod='HtmlEncode'/></label></td>
  2. By pass the Basic creation popup and navigate to advanced screen because by default SharePoint consider it yes. To do this:
    Find the below code in the file:
if (this.IsDialogMode){
    %><a class="ms-textSmall" href="javascript:;" onclick="NavigateToFullPage()"><SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,lstsetng_advancedoptions_text%>" EncodeMethod='HtmlEncode'/></a><%}

    and another if condition inside this if. Final code should look like this:

    if (this.IsDialogMode)
    {
    if (HttpContext.Current.Request.Url.AbsoluteUri.Contains("ListTemplate=102"))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "NavigateToFullPage()", true);
            }else { 
    %>
    <a class="ms-textSmall" href="javascript:;" onclick="NavigateToFullPage()"><SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,lstsetng_advancedoptions_text%>" EncodeMethod='HtmlEncode'/></a>
    <%
            }}

    If you have any existing survey lists, you could use powershell to to change their list setting.

    Saturday, April 11, 2015

    Migration from MOSS 2007 to Sharepoint Azure

    Although there is lots of documentation already available on this i want to list the steps to migrate from MOSS 2007 to SharePoint Azure in simple language.

    Now before we start, lets list some points to consider:

    • We can not directly Migrate from MOSS 2007 to SharePoint azure. We will have first migrate to SP 2010.
    • We will have to convert AD users to ADFS as explained here.
    • It is always a good practice to cleanup the SharePoint Database before we mount it on Azure Site.

    Steps to Migrate

    Step 1 : Make MOSS 2007 DB read only

    • On the MOSS 2007’s database server, click Start, point to All Programs, Microsoft SQL Server, and then click SQL Server Management Studio.
    • Traverse to Databases node by expanding the tree
    • Right-click the name of the database that you want to set to read-only, and then click Properties.
    • In the Properties dialog box, click the Options tab.
    • Under State, select the Database Read-only to True, and then click OK
    Step 2 : Take MOSS 2007 DB Backup

    • Traverse to Databases node by expanding the tree.
    • Right-click the database you want to back up, point to Tasks, and then click Backup Database
    • In the SQL Server Backup dialog box, specify a name for the backup, select Back-up type – Full, select a destination, and then Click OK to start the backup process.
    Step 3 : Restore this Backup on 2010 DB Sever.
    Step 4 : Create a Web application on SharePoint 2010.
    Step 5 : Remove the data base of new created web application and mount the restored DB.
    • This could be done using UI or power-shell. This is listed by Microsoft here.
    Step 6 : Now we will test DB for any missing features and if we need to install any custom components on the on Azure.
    Test-SPContentDatabase -Name <DatabaseName> -WebApplication <URL>
    This URL explains thoroughly the report generated by Test command .

    Step 7 : Based on the report generated in above step we will have to take appropriate actions.
    Majorly there would be following things:
    • Missing features : Use the power-shell to remove the missing features(or orphaned features)
    • Install any third party components.
    Step 8 : Once cleanup is done take DB back up of 2010 site.
    Step 9 : Restore backup on Azure DB sever.
    Step 10 :  Create a Web application on SharePoint 2013.
    Step 11 : Remove the data base of new created web application and mount the restored DB.
    Step 12 : Now that our Site is ready we will have to convert the Users.
    Follow this link to understand how to convert.
    Step 13 : Deferred Site Collection Upgrade
    This is a replacement of Visual upgrade feature available in 2010. Its pretty simple and can be done using below mentioned power-shell command.
    Get-SPSite -ContentDatabase WSS_Content -Limit All | Upgrade-SPSite –VersionUpgrade

    Saturday, April 4, 2015

    Migrating from AD to ADFS Sharepoint 2013 azure.

    One of the problem we face when migrating to SharePoint 2013 azure is user migration as SP 2013 supports only Claim based authentication. So if your source SharePoint site is running on classic authentication, migrated users will not be able to login on 2013.
    Another thing to consider would be that when we will migrate to Azure you domain will also change. On source it would be AD and on azure authentication provider would be ADFS.

    But Microsoft has provided a solution to it. All you will have to do is to run Move-SPUser Command as mentioned here. Below mentioned power-shell script will convert all users of a site collection.

    add-pssnapin microsoft.sharepoint.powershell
    $url ="<Site Collection URL>"
    #i:05.t|Domain-id-provider|username@domain.com
    # get all users in the site, this includes iwindows users
    $users = get-spuser -web $url -Limit ALL 
    foreach($useriteration in $users)
    {
         $a=@()
         $userlogin = $useriteration.UserLogin
        # get the user login name
        #Write-Host $userlogin
        if($userlogin.Contains("Domain\"))
                    {
              $user = Get-SPUser -web $url -Identity $userlogin
              #Write-Host $user.Email
                      $userLoginInfo=$user.Email
                                    if($userLoginInfo)
                                    {
            #Write-Host $userlogin " = " $userLoginInfo
           Move-SPUser -IgnoreSID -Confirm:$false -Identity $user -NewAlias "i:05.t|domain-id-provider|$userLoginInfo"
                                                    echo "User converted to claim with i:05.t|domain-id-provider|$userLoginInfo"
                            }
                                    else
                                    {
                                                    echo "No email address map with user $userlogin"
                                    }
                    }
                    else
                    {
                                    #echo "Non Domain user remains same $userlogin"
                    }

    }
    Remove-pssnapin microsoft.sharepoint.powershell

    Thursday, November 20, 2014

    Branding SharePoint : Page Layouts

    A Page Layout in SharePoint allows you to create a template for a page that users apply to their content for a consistent layout of information. Unless master page there could be different page layouts for different page types. For e.g. in a product catalog we could have single master page and a different page layout for each category. An electronics pages might need image placeholder but on some other category not.

    We basically design the structure on the content placeholder of Master Page.


    • Inserting Webparts and Webpartzones
    • Creating the layout of the pages (within the bounds of the master page)
    • Controlling page-level design elements.
    • Including page-level css files to override master page styles
    • Including custom codes for a particular type of pages (javascript, etc.). Please note we could also add JS ro master page but that will apply to all the pages. 
    • Things that occur only on this page layout, not site-wide 


    Location of Page Layout:
    Just like page master pages Page Layouts are also available in Gallery available in Site Settings

    How is Master Page and Page Layout connected:
    Each page layout has a MasterPageFile element which decides which master page will render when any page with the page layout will render.

    Please layouts are available in the publishing site template and for that we will need a publishing content types.

    Click here to learn how to create Page Layouts.

    Friday, April 4, 2014

    How to Enable Share-point Designer in Central Admin

    Below are steps for SharePoint Designer settings in Central Admin:

    1. Open Central Application Website.
    2. Open SharePoint Designer Settings under General Application Settings.
    3. Select your web application from the drop down at the top of the form.
    4. Select the appropriate options as mentioned below(per your needs) and click  ok.
    There are four check boxes as listed below:

    Enable SharePoint Designer : This Enables or disables SharePoint Designer for the Web Application and all of its site collections.

    Note: If unchecked, users still see SharePoint Designer buttons in the browser, but when they click them, they get a message stating that SharePoint Designer is not allowed on the site.

    Enable Detaching Pages from the Site Definition : This option enables or disables the ability to detach pages from the site definition. If unchecked, SharePoint Designer only allows you to edit pages in normal mode. The Edit File in Advanced Mode is disabled. Running in Advanced mode lets a user ghost pages by modifying them from the content originally in the site definition stored on the server’s hard drive. The customized version of the page is stored in the SharePoint content database. Any changes made to the site definition files aren’t reflected in detached pages. This can create maintainability problems and should be used with care.

    Note: This setting does not apply to pages that have already been detached as well as new blank ASPX or HTML pages created by the user.

    Enable Customizing Master Pages and Layout Pages : This enables or disables the ability to customize master pages and page layouts. If unchecked, SharePoint Designer does not display Master Pages or Page Layouts in the Navigation pane.

    Note: Page layouts also require publishing enabled on the server, so if you have enabled it here but the site is not a publishing site, you will still not see the Page Layouts option in the Navigation pane.

    Enable Managing of the Web Site URL Structure: This enables or disables the ability to view and edit files in the URL structure of a site. If unchecked, SharePoint Designer does not display the All Files option in the Navigation pane.


    Note: These four options are also available at site collection settings.