Checking user permissions: DoesUserHavePermissions vs. CatchAccessDeniedException

Checking user permissions DoesUserHavePermissions vs CatchAccessDeniedException

I recently had a nice discussion with a colleague about the best way to check if the current user has permissions to view a specified SharePoint list in a SP2010 site using C#.

 

 

Basically there are 2 ways to check for permissions:

1) SPSecurableObject.DoesUserHavePermissions

2) SPSecurity.CatchAccessDeniedException

This post  discusses both methods, proposes implementations and discusses the pro’s and cons.

Using the SharedQueryManager to display Relevant Search Parameters in a WebPart

Using the SharedQueryManager to display Relevant Search Parameters in a WebPart

The SharePoint Search is powerful yet very complex. There are a lot of settings and parameters that influence the search results.

For example; did you know that the Culture used in the query is used to determine wordbreaker, stemmer, and thesaures? Search with the wrong Culture and you will get unreliable and strange search results. I have seen it happen at a customer; the documents were all written in Dutch but the search was configured to use the English Culture (en-US: 1033). Finding out why some documents were included in the search result while others are left out can be a challenge as you have to check every search parameter at WebPart level, Site level, and Service Application level.

Changing the URL of an existing document library or list

Changing the URL of an existing document library or list

When you create a new list or document library in SharePoint the Name you supply for your new list is also used to in the URL. Characters like spaces are replaced by their HTML equivalents (%20). Changing the title of the list afterwards is easy, so is changing the URL of an existing list. You just have to know where to look. This post explains how to change both the title and the URL of existing lists and libraries using several techniques.

Load an external JavaScript file on demand using a Custom Action in SharePoint 2007

Load an external JavaScript file on demand using a Custom Action in SharePoint 2007

I build a lot of SharePoint Solutions that use JavaScript to enhance user experience. Most of the JavaScript I put in dedicated .js files and deploy them to the 12-hive (or 14-hive) in the layouts-folder. Deploying a JavaScript file (*.js) layouts-folder of SharePoint and loading external JavaScript files (*.js) in SharePoint 2007 can be accomplished in a couple of ways.

Enumerating SharePoint groups and group members through its webservices using PowerShell

Enumerating SharePoint groups and group members through its webservices using PowerShell

SharePoint offers a large variety of webservices and consuming such a webservice with PowerShell takes only a few lines of code:

$SPService = New-WebServiceProxy -Uri ($WebUrl + "/_vti_bin/SomeWebService.asmx?WDSL") -UseDefaultCredential
$SPService.SomeMethod()

You can use PowerShell to enumerate all SharePoint groups and save them to a CSV-file without logging in to the SharePoint server.

Fancy SharePoint navigation using jQuery and the Client Side Object Model

Fancy SharePoint navigation using jQuery and the Client Side Object Model

SharePoint offers OOTB navigation such as the Top Link Bar and the Quick Launch. Using jQuery and animations you can create a more appealing way of navigation for your SharePoint site. In this post I describe how to leverage the Links list using the Client Side Object Model in JavaScript to provide a fancy way of navigating your site.

Document ID Hyperlink with QR Code for SharePoint 2010

Document ID Hyperlink with QR-Code for SharePoint 2010

About a month ago, Jan Tielens posted a nice solution on his blog for generating short URL’s for SharePoint 2010 documents. His solutions depends on a URL shortening services like http://bit.ly/urlwiki or http://tinyurl.com/urlwiki.

As Jeroen Ritmeijer points out in his comment on the same page, this might not be a proper solution for confidential files. I wouldn’t want my ‘Plan for World Domination.docx’ leaking to the public. In this blog I try to give an alternative solution for those long hyperlinks.

Periodically upload files to SharePoint using Powershell

Periodically upload files to SharePoint using Powershell

You can use Powershell to upload files to a SharePoint document library. Let’s say some application is generating reports in C:\Reports and you want to periodically upload them to a document library Shared Documents. By sheduling a PowerShell script and uploading all files in a certain directory to SharePoint you can access of all your important reports via SharePoint.

Changing the Window Title programmatically in SP2010

Changing the Window Title programmatically in SP2010

SharePoint uses a placeholder with the name “PlaceHolderPageTitle” to influence the window title. You can set the window title by putting text in this placeholder. But if you want the window title to be based on other parameters, let’s say the current user, it is also possible to change the window title programmatically.

Displaying the filename in the SharePoint search results

Displaying the filename in the SharePoint search results

By default the SharePoint search web part ‘Core Search Results Web Part’ displays the document’s title as a hyperlink to the document (or list item). While this is fine for most cases, recently a customer explained to me:

We are crawling all our old file shares using the SharePoint Search. Our end users are used to finding documents by their filename, however the SharePoint search is displaying the document’s title which confuses our end-users