Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

    Advertisements
  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

Archive for May, 2015

SharePoint as Backend!

Posted by Paul on May 30, 2015

I was observing a new trend in the SharePoint Development World:

“SharePoint as Backend!”

What is SharePoint as Backend?

Here, SharePoint is used as a replacement for  SQL Database!

All the required tables will be created as SharePoint Lists.  Any, additional document storage will be managed through SharePoint libraries.

image

How the CRUD code is managed?

Good Question! Here the CRUD is managed through SharePoint REST CSOM code.

How Filtering works?

You can use OData filters for performing filtering on list items.

Okay! What are the other advantages of using SharePoint as Backend?

Following are the advantages on cost, time & effort:

  1. No need of a separate database
  2. No need to design SQL tables
  3. No need to write CRUD codes
  4. No need to manage Scalability
  5. No need to write Authorization code
  6. No need to write Search code
  7. No need to write WCF/Service code

The advantages are gained once you have an existing SharePoint implementation with Scalability taken care of.

Issues

Wait a second! Consider following factors too before going for decision:

  1. Response Delay SharePoint REST API can perform little bit slower than your WCF services.  Ensure your project NFR (Non-functional Requirements) accommodate this delay.
  2. Skill Shortage Developers with SharePoint REST API skills can be rare.  Ensure you have an expert/trained developer.

Examples

Following are few examples of SharePoint as Backend:

  • Mobile App If you are writing a mobile application, you can quickly manage the data storage by writing REST/OData code to SharePoint using JavaScript/JQuery.
  • .Net App If you are writing an ASP.NET application which requires database tables, you can use .Net code to access the CSOM of SharePoint.
  • Document Storage App If you are writing a document management application, you need not worry about SQL Server tables & BLOB storage.  You can use SharePoint REST/OData API for achieving same.

Summary

SharePoint as Backend can save you lot of time & effort.  Please do your valuations appropriately.

Advertisements

Posted in SharePoint, SharePoint 2013 | Tagged: , | Leave a Comment »

3 Types of App Authorization Policies

Posted by Paul on May 24, 2015

In this post we can explore the 3 types of App Authorization Policies.

User-Only Policy

When this policy is used, the current user permission is checked. For example, if the user does not have permission in a list & the app tried to modify list item, it can raise a Security exception.

This policy is the default in SharePoint 2010.

App-Only Policy

When this policy is used, the app policy is checked while accessing resources. For example, if the app does not have Manage permission in a site & the app tried to create a list in the site, it raises a Security exception.

User+App Policy

When this policy is used, the app & user policy are checked using AND condition. For example, if the app has permission & user does not have, it raises a Security exception.

For remote hosted apps, this policy is apt.

Setting the Policy

We can set the policy in the App Manifest file. Please follow the steps below to perform policy setting.

Create a new SharePoint App project of type SharePoint Hosted App. From the Solution Explore, Open the App.Manifest in code view as shown below.

image

Add a new tag AppPermissionRequests as shown below.

image

For AppOnlyPolicy set the following.

<AppPermissionRequests AllowAppOnlyPolicy=”true”></AppPermissionRequests>

You can also use the XML editor for the manifest file for setting Site/Web permissions.

image

References

https://msdn.microsoft.com/en-us/library/office/fp179892.aspx

Summary

In this post we have explored the 3 types of App Authorization Policies.

Posted in SharePoint, SharePoint 2013 | Leave a Comment »

SharePoint Form Digest

Posted by Paul on May 23, 2015

In this article we can explore about Form Digest in SharePoint.

Form Digest

Form Digest is used to insert a security validation for SharePoint pages. The digest value will be created by SharePoint server during page creation.

Example: A user loads a SharePoint page. He injected a script which updates the list data. When the user posts the page, the server will check Form Digest value against the page content. Thus, security attacks can be prevented.

Viewing Form Digest

You can use the view-source of a SharePoint page to see the form digest value. The value is stored under name ___REQUESTDIGEST.

image

FormDigest Class

For custom pages, you need to us the FormDigest user control for automatically inserting the form digest value. Following is the definition of FormDigest class.

image

Following is the usage of FormDigest class.

image

Once the page is rendered, the view-source will show the __REQUESTDIGEST key-value pair.

image

Client Side

While working client-side scripts OR invoking REST services, we need the form digest value creation or refresh. Refresh is required especially for SPA (Single Page Applications) where the user won’t load the page for long time & use scrolling/update feature to interact with it. (Eg: Facebook App)

References

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.formdigest.aspx

Summary

In this post we have explored Form Digest in SharePoint.

Posted in SharePoint, SharePoint 2013 | Leave a Comment »

Time to Move from SPServices to REST

Posted by Paul on May 22, 2015

In one of the SharePoint sessions, I found that the presenter is using SPServices.  Although, I have used SPServices before, I do not recommend using it for new projects, especially while SharePoint 2013 supports REST enabled services.

What is SPServices?

For those who are not aware of SPServices:

  • SPServices is a JQuery library which eases working with SharePoint ASMX web services
  • SPServices started supporting from MOSS 2007 to SharePoint 2010 to SharePoint 2013
  • SPServices is available from https://spservices.codeplex.com/

Following is an example of how SPServices looks like. (Courtesy)

image

What is REST?

A brief about REST enabled services in SharePoint 2013:

  • REST uses GET/POST/PUT/DELETE http-verbs for carrying the get/insert/update/delete operations on site, list, libraries
  • REST decreases the foot-print of application
  • REST supports JSON on top of XML enabling a broader client application integration with SharePoint
  • REST along with OData support provides advantages like filtering, combining etc.

Following is an example of how a REST service look like.

image

Please see References section for more examples.

Why to move to REST?

Following are the reasons Why we should move to REST from SPServices:

  1. More and more CSOM code are being exposed through REST
  2. SPServices was created before an era of CSOM and supports only XML
  3. In future ASMX web services can be deprecated creating a threat to existing SPServices solutions

Summary

Considering the above factors, I would not recommend new projects to be built using SPServices.  The new SharePoint Solution world is of REST and OData!

References

https://msdn.microsoft.com/en-us/magazine/dn198245.aspx

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

Indexed Columns to Improve List Performance

Posted by Paul on May 20, 2015

In this article we can explore Indexed Columns which is a less-used feature in SharePoint.

Indexed Columns

Indexed Columns allows Indexing of List or Library columns. This enable the following advantages:

1. Increase speed of data retrieval

2. Improve Performance of large list or library

Indexing at list or library level will be applied to the database tables too. This helps in increasing retrieval speed especially used for the WHERE condition fields.

Improving Performance is required when the list view threshold has reached, for example a list with more than 5000 items.

Create Indexed Columns

To create indexed columns for a list or library do the following steps.

Open the List Settings Page.

image

Scroll down and click on the Indexed Columns link.

image

You will get the following page.

image

Click on the Create a new index link. You will get the following page.

image

image

Please note that SharePoint does not allow all column-types to be indexed. See references section for more information.

You can choose the column for indexing. For the time being, I have chosen Content Type.

image

The changes will be saved automatically.

image

You can add up to 20 indexed columns.

Database Index

If you have examined SharePoint Content Database Table structure, you will be knowing that SharePoint stores a record in multiple rows in the AllItems table. This table also contains record (items) from different lists. So you might have the concern:

Adding an Index can impact other List items too!

Explanation: This case won’t happen as once a column is indexed, the data will be stored in a new table. So whenever we are adding indexed-columns, a new database-column creation happens in the background. The new database-column will be indexed and thus provides better performance.

References

http://bit.ly/1Fy3G0j

Summary

In this article we have explored Indexed Columns.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

App Side Loading

Posted by Paul on May 17, 2015

App Side Loading allows installation of an App directly into a SharePoint site.

Pre-Requisites

Following are the pre-requisites of the site to enable App Side Loading:

  1. Site Template should be Developer Site Template
  2. Or, Side Loading feature should be enabled

Developer Site Template

You can create a developer site using the developer site template as shown below.

image

Side Loading Feature

To activate this feature, you have to use PowerShell.  This feature is a hidden one & cannot be activated using SharePoint > Site Collection Features > User Interface.

Following is the PowerShell script to activate the feature.

Add-PSSnapin Microsoft.SharePoint.PowerShell
Enable-SPFeature e374875e-06b6-11e0-b0fa-57f5dfd72085 –url http://site-url

Note

Specify your site URL in the above script.

Error

If we are not using any of the two options above, you may receive the following error during app deployment.

Side loading of apps is not enabled on this site

In this case, you can run the above PowerShell script & try re-deploying the App.

Note

This feature should not be used in Production machines.

Summary

In this post we explored the App Side Loading feature.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

SharePoint 2016 New Features

Posted by Paul on May 13, 2015

In this article I would like to highlight the features of SharePoint 2016. This information was collected from the Ignite session conducted by Microsoft.

Link: http://channel9.msdn.com/Events/Ignite/2015/FND2203

Release by 2016-Q2

SharePoint 2016 is expected to release by 2016-Quarter-2.

image

Look N Feel

I cannot find any huge difference in SharePoint 2016 Look N Feel. The Tiled UI will be continuing.

image

On-Premise is here to Stay

Microsoft promised SharePoint 2016 will be having On-Premise version. There was a rumor about discontinuing On-Premise version from 2016 onwards. But, customers have reasons for all data cannot be on SharePoint Online.

Search with Delve

SharePoint 2016 will be having Search with Delve app. Delve is a new way of searching & presenting contents based on user’s interest. Delve’s roots goes to Office 365.

Delve can present information from Exchange, OneDrive for Business, SharePoint Online and Yammer based on user’s interactions. Please find references section to learn more about Delve.

Farm Solutions will be supported

Farm Solutions will be supported. This should enable lot of 2010 & 2013 code to be migrated to 2016 with least amount of upgrade to CSOM. But, as said earlier App Model / CSOM will be the preferred development model.

OneDrive

SharePoint 2016 will have improvised support for OneDrive. This is part of Microsoft’s Hybridization movement for On-Premise.

Hybridization is bringing cloud-features to On-Premises, rather taking On-Premise customers to Online versions.

Yammer

Yammer will be integrated with SharePoint 2016. This is also part of Microsoft’s Hybridization movement for On-Premise. Additionally, External User interaction will be added to Yammer to enable external-users like customer/vendor communications.

Office Graph

Office Graph is the core component which will enable Delve Search & Hybridization feature. But, Office Graph will be residing in SharePoint Online and a Hybrid Connectivity from SharePoint 2016 will be provided.

Responsive UI

There are improvements to the default responsive user interface. This enabled SharePoint 2016 better view ability in mobile devices.

Hardware Requirements

It is cooler to see that the hardware requirements will be similar to SharePoint 2013. This will save lot of $ for developers & administrators who recently invested in hardware for SharePoint 2013.

Online Patching

Administrators should really like this feature. SharePoint 2016 allows applying patches while being Online. No need to take the servers off & users can continue working while patches are applied. Zero Downtime!

Expanding Boundary Limits

SharePoint 2016 expanded boundary limits on content database size, list view items count etc. This should save lot of shredding-jobs from Administrators and Developers.

User Profile Service Application will be removed

User Profile Service Application will be removed. I am not clear about the details on Active Directory synchronizing and so. Will have to play with the preview version to understand this.

References

Delve https://support.office.com/en-us/article/What-is-Office-Delve-1315665a-c6af-4409-a28d-49f8916878ca

Roadmap for Delve http://www.zdnet.com/article/microsoft-starts-rolling-out-delve-its-flipboard-for-office-365/

SharePoint Evolution http://blogs.office.com/2015/02/02/evolution-sharepoint/

Summary

In this article we have explored SharePoint 2016 features overview.

Posted in SharePoint, SharePoint 2016 | Tagged: , , | Leave a Comment »

PowerShell Memory Leak & Prevention

Posted by Paul on May 13, 2015

In this article we can explore how to prevent memory leaks while writing SharePoint scripts.

Memory Leak

While writing PowerShell scripts, there are immense chances to form memory leaks if the script-writer did not free the objects correctly. While dealing with SPFarm, SPSiteAdministration SPSite, SPWeb objects with huge internal data, the problem can become more vulnerable crunching system resources.

Preventions

We can prevent memory leaks quickly using the following Cmdlets:

1. Start-SPAssignment

2. Stop-SPAssignment

Start- SPAssignment & Stop-SPAssignment

Start-SPAssignment will start collecting memory objects. Later we can invoke the Stop-SPAssignment to release the memory.

$c = Start-SPAssignment;

$w = Get-SPWeb –Site http://serfver –AssignmentCollection $c

Stop-SPAssignment $c;

Explanation In the above code, we are first declaring the variable $c pointing to collect the assignment objects. In the next line Get-SPWeb will create a web object in $w and simultaneously it I added to the assignment collection. The Stop-SPAssignment will release all the memory-objects within $c.

image

Here additional coding is required to add the web objects to assignment collection. In production scenarios where pre-existing PowerShell script has to be modified will required much effort.

Using –Global Switch

We can do memory leak prevention quickly using the –Global switch. Example is given below:

Start-SPAssignment -Global

$w = Get-SPWeb –Site http://serfver –AssignmentCollection $c

Stop-SPAssignment -Global

Types of Assignment

There are 3 types of Assignments:

1. No Assignment

2. Simple Assignment

3. Advanced Assignment

Simple Assignment is the one we have seen using the –Global parameter. This is used more often.

Advanced Assignment is the one with assignment variable. This is used in advanced scripts.

No Assignment is where no parameters or variables are used. Here objects are disposed each iteration.

References

https://technet.microsoft.com/en-us/library/ff607664.aspx

Summary

In this article we have explored how to prevent memory leaks while writing SharePoint scripts.

Posted in SharePoint, SharePoint 2013 | Tagged: , , , , | Leave a Comment »

Sign the Certificate

Posted by Paul on May 8, 2015

In this article we can see how to sign a certificate. This step is essential for doing a Provider Hosted Application in SharePoint 2013.

Pre-Requisites

You have to create an IIS Certificate. I hope you have gone through this step already.

http://www.jeanpaulva.com/index.php/2014/12/01/create-export-certificate/

Steps

Following are the steps involved:

1. Copy the Certificate

2. Sign the Certificate

Copy the Certificate

Now we have to copy the certificate and sign it.

Open the IIS > Certificates.

image

Double click on our certificate.

image

From the Details tab click on the Copy to File.. Option.

image

Select the default options and click the Next button.

image

Please note that the extension is cer.

image

Click the Finish button to complete the copy operation.

Sign the Certificate

Now we need to sign the certificate. We can do this using PowerShell ISE editor.

Open ISE Editor in Administrator mode.

image

Run the following code. (You need to change the certificate path & GUID)

Add-PSSnapin Microsoft.SharePoint.PowerShell

$certPath = “C:tempSP2013Certificate.cer”
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certPath)
New-SPTrustedRootAuthority -Name “PHASelfSignedCertificate” -Certificate $cert

$realm = Get-SPAuthenticationRealm

$issuerId = “586bb34f-83b9-4dbe-b293-8981441bd7a8”
$issuerIdentifier = $issuerId + ‘@’ + $realm

New-SPTrustedSecurityTokenIssuer -Name “Provider hosted Self Signed Certificate” -Certificate $cert -RegisteredIssuerName $issuerIdentifier
iisreset

$config = Get-SPSecurityTokenServiceConfig
$config.AllowOAuthOverHttp = $true
$config.Update()

image

Signing process is required so that the SharePoint server can trust the second IIS Server which will host the PHA application. In real-world scenarios the certificate exporting & signing should be done with third-party vendors.

References

http://bit.ly/10uiVpB

Summary

In this article we have explored how to sign a certificate for using in PHA application.

Posted in SharePoint, SharePoint 2013 | Tagged: , , | Leave a Comment »

Cache File Extension – .appcache OR .cachemanifest

Posted by Paul on May 3, 2015

I have been observing some arguments about offline application cache file extension:

  1. Is .appcache the right extension?
  2. Is .cachemanifest the right extension?

Who is the Authority?

The authority to decide extension & MIME types goes to W3C (World-Wide-Web-Consortium). This also means that no company nor browser nor developer can set the standard.

All Extensions are Right!

Going through W3C, I cannot find any restriction to use .appcache or .cachemanifest extensions.   You can use whatever extensions you prefer!

WC3 only restricts to use the right MIME type of text/cache-manifest.  So all the extensions are right if they render the right MIME type.

link

See below link:

http://www.w3.org/TR/2011/WD-html5-20110525/offline.html

W3C is the authority to decide on extensions or MIME types. All browsers are written to align with these standards.

How MIME type works?

In SharePoint terms, MIME type acts as the Content Type.  When the browser fetches one file for eg: abc.jpg it doesn’t know what to do with it.  Then it will request the MIME type and understand it as image/jpg which makes the decision to render it as image.

Browser Support

Browsers are bound to support any MIME type regardless the file extension.  Basically, it has to look into the MIME type rather than file extensions.

Example: IE, Chrome, Firefox, WorxWeb

Going with O365

Going with O365 one may get disappointed seeing the .appcache is no longer mapped to text/cache-manifest.  It will return another mime type as application-octetstream.  Clearly, this won’t serve our purpose & O365 does not allow changing MIME types as the IIS is managed by Microsoft.

But, there is a solution.  O365 provides another extension .cachemanifest with the MIME type text/cache-manifest.  We need to use this extension for offline application cache files.

Why O365 .appcache has wrong MIME type?

First of all we cannot call it as wrong as W3C never said “.appcache is the correct extension”.  O365 inherits IIS older versions where .appcache served a different purpose. (era before offline application cache).  If Microsoft is going to change the .appcache to text/cache-manifest, then the existing applications using application-octetstream will break.

Note

Please open IIS Manager > MIME types to ensure the right MIME type is being associated with the extension.

References

http://www.w3.org/TR/2011/WD-html5-20110525/offline.html

http://www.jeanpaulva.com/index.php/2015/03/25/right-mime-type-for-application-cache/

Summary

The conclusion is “all extensions are right”.  The browsers are bound to support it as long as the right MIME type is served.

 

Posted in Uncategorized | Leave a Comment »