Archive for August, 2009

I only get a chance to setup email enabled libraries once every 4 months or so. My last setup was a couple of weeks back. This was for one of our customer who wanted to use incoming email functionality to support some reports coming from external sources; this particular customer was running Microsoft Exchange 2007.

Before I get into the actual steps, here are some basics: For email enabled libraries to work in SharePoint, you need at least one server in your SharePoint Farm to host the SMTP service (on Windows 2008 and above this service is still administrated through IIS 6.0 Manager) this service stores routed email in a drop folder from where SharePoint timer job picks it up periodically and puts it in the document library linked to an email alias (the LibName part in The timer jobs run on all severs connected to the Farm but only the server where the mail is forwarded to will actually process it. When Distributed Lists management is turned on SharePoint will create Contacts for all incoming email library under the selected organisational unit.

Here are some quick sanitised steps that I documented for the customer:

  1. Create an Organisational Unit under you domain called SPMail, for example the one I created has an LDAP Path: OU= SPMail,OU=Melbourne,DC=COMPANYNAME,DC=COM
    1. On Windows Server 2008 and above ADSI Edit is preinstalled and one of best tool to find the LDAP Paths
  2. On the newly created OU setup Delegate rights with Full Control for the Central Administration\Timer Service Account: DOMAIN\ServiceAccountName
    1. Full Control is not Necessary, you can get by Read, Write
  3. On your DNS Server add a new MX record, to a new subdomain like SPMAIL such that your entry looks like SPMAIL.COMPANYNAME.COM with Mail Server Priority set to 20 and DNS pointing to the SharePoint box (for example SPAPP.COMPANYNAME.COM) in your farm with the SMTP service running locally.
  4. Open up Exchange 2007 Management console and under Hub Transport create a new Send Connector called SharePoint Mail
    1. Use the following for the Address Space value: SPMAIL.COMPANYNAME.COM
    2. Under Smart Host Routing setting select: Use DNS for MX Records
  5. Install and setup the SMTP service on SPAPP.COMPANYNAME.COM for domain: SPMAIL.COMPANYNAME.COM with the drop folder set to its default value
  6. Finally setup the Incoming Email settings under operations in Central Administration (<CA SITE>/_admin/IncomingEmail.aspx)

For testing simply enable email on Shared Document library under the Central Admin Site. This can be done by going to list settings and the clicking on the Incoming Email Settings link.

Library: <CA SITE>/Shared%20Documents/Forms/AllItems.aspx

Email Alias: SharedDocuments@SPMAIL.COMPANYNAME.COM

Verify that a new Contact is created in AD and Exchange and then send an email using you email client to verify if emails are being routed to the library.


A client of mine did not want parts of their Intranet based on MOSS 2007 to be searched; now that’s quite easy to do with Crawl rules. As they wanted strict control over the content that can be crawled I trained them on how to control ‘the crawl’ behaviour for content within SharePoint.

There are three places within SharePoint where end users can change search visibility setting or exclude content for search.

  1. Change Visibility for a Web site: In the Site Settings page, site owners can click the Search Visibility link to go to the Search Visibility page SharePoint. In the Indexing Site Content group, selecting the No option to will exclude all content within the site. The crawler will in turn simply skip the site and not include any of its content in the index.
  2. Exclude Site Columns: In the Site Settings page, site owners can click the Searchable Columns link to go to the Search Settings for Fields page in SharePoint. This page will enumerate all the site columns defined at the current site level. Selecting the NoCrawl check box for the site columns will exclude them from future crawls.
  3. Exclude Lists: The last option for excluding content exists at the level of the SharePoint list settings. It enables list owners to exclude the list and all the content within it from crawls. In the settings page of the list, click the Advanced Settings link. Selecting the No option under Search Available for crawl tells the crawler to exclude the specific list from a crawl.

Also if there are certain pages or entire site content that site designers don’t want to be crawled, simply putting the no index directive in the head section of the master page or layout page’s mark-up will stop the SharePoint crawler from crawling the pages:


I recently blogged about how to security trim contents of a page using the Security Trim Control, it works great for content on the page but what about contents within a web part I was asked, for example that of a DataView web part. Well that’s easy too, all you need is a little less known built in XSLT function called ddwrt:IfHasRights(<Permission Mask>)) and some Conditional Formatting logic.

  1. Simply select the text or mark-up inside the data view web part and then
  2. Click on Conditional Formatting option in the Task Panes menu
  3. In the Condition Criteria dialog box select Advanced and in the Advanced Condition dialog box change Select a function category to All
  4. Find and insert the IfHasRights() function by double clicking on the Select a function list
  5. Use a single Permission Mask for example 4 IfHasRights(4) to only make the mark-up or text visible when the user has edit rights on the page\item

Following is a list of Permission Masks for the build in permissions

  • ViewListItems – 1
  • AddListItems – 2
  • EditListItems – 4
  • DeleteListItems – 8
  • ApproveItems – 16
  • OpenItems – 32
  • ViewVersions – 64
  • DeleteVersions – 128
  • CancelCheckout – 256
  • PersonalViews – 512
  • ManageLists – 2048
  • ViewFormPages – 4096
  • Open – 65536
  • ViewPages – 131072
  • AddAndCustomizePages – 262144
  • ApplyThemeAndBorder – 524288
  • ApplyStyleSheets – 1048576
  • ViewUsageData – 2097152
  • CreateSSCSite – 4194314
  • ManageSubwebs – 8388608
  • CreateGroups – 16777216
  • ManagePermissions – 33554432
  • BrowseDirectories – 67108864
  • BrowseUserInfo – 134217728
  • AddDelPrivateWebParts – 268435456
  • UpdatePersonalWebParts – 536870912
  • ManageWeb – 1073741824
  • UseRemoteAPIs – 137438953472
  • ManageAlerts – 274877906944
  • CreateAlerts – 549755813888
  • EditMyUserInfo – 1099511627776
  • EnumeratePermissions – 4611686018427387904
  • FullMask – 9223372036854775807

Security Trim Contents of a Page

I get this question a lot of times, and yesterday I had this question come up again. One of my team mates asked me about a way to security trim content on the page rather then the entire page it self. Well it’s quite easy, all you need is the SPSecurityTrimmedControl.

<SharePoint:SPSecurityTrimmedControl ID=”SPSecurityTrimmedControlName″ PermissionsString=”BrowseDirectories” runat=”server”>

The markup that needs to be security trimmed goes here.


Here are the permissions you can use, you can add multiple using commas:

  AddDelPrivateWebParts Add or remove personal Web Parts on a Web Part Page. 
  AddListItems Add items to lists, add documents to document libraries, and add Web discussion comments. 
  ApplyStyleSheets Apply a style sheet (.css file) to the Web site. 
  ApplyThemeAndBorder Apply a theme or borders to the entire Web site. 
  ApproveItems Approve a minor version of a list item or document. 
  BrowseDirectories Enumerate files and folders in a Web site using Microsoft Office SharePoint Designer 2007 and WebDAV interfaces. 
  BrowseUserInfo View information about users of the Web site. 
  CancelCheckout Discard or check in a document which is checked out to another user. 
  CreateAlerts Create e-mail alerts. 
  CreateGroups Create a group of users that can be used anywhere within the site collection. 
  CreateSSCSite Create a Web site using Self-Service Site Creation. 
  DeleteListItems Delete items from a list, documents from a document library, and Web discussion comments in documents. 
  DeleteVersions Delete past versions of a list item or document. 
  EditListItems Edit items in lists, edit documents in document libraries, edit Web discussion comments in documents, and customize Web Part Pages in document libraries. 
  EditMyUserInfo Allows a user to change his or her user information, such as adding a picture. 
  EmptyMask Has no permissions on the Web site. Not available through the user interface. 
  EnumeratePermissions Enumerate permissions on the Web site, list, folder, document, or list item. 
  FullMask Has all permissions on the Web site. Not available through the user interface. 
  ManageAlerts Manage alerts for all users of the Web site. 
  ManageLists Create and delete lists, add or remove columns in a list, and add or remove public views of a list. 
  ManagePermissions Create and change permission levels on the Web site and assign permissions to users and groups. 
  ManagePersonalViews Create, change, and delete personal views of lists. 
  ManageSubwebs Create subsites such as team sites, Meeting Workspace sites, and Document Workspace sites.  
  ManageWeb Grant the ability to perform all administration tasks for the Web site as well as manage content. Activate, deactivate, or edit properties of Web site scoped Features through the object model or through the user interface (UI). When granted on the root Web site of a site collection, activate, deactivate, or edit properties of site collection scoped Features through the object model. To browse to the Site Collection Features page and activate or deactivate site collection scoped Features through the UI, you must be a site collection administrator. 
  Open Allow users to open a Web site, list, or folder to access items inside that container. 
  OpenItems View the source of documents with server-side file handlers. 
  UpdatePersonalWebParts Update Web Parts to display personalized information. 
  UseClientIntegration Use features that launch client applications; otherwise, users must work on documents locally and upload changes.  
  UseRemoteAPIs Use SOAP, WebDAV, or Microsoft Office SharePoint Designer 2007 interfaces to access the Web site. 
  ViewFormPages View forms, views, and application pages, and enumerate lists. 
  ViewListItems View items in lists, documents in document libraries, and view Web discussion comments. 
  ViewPages View pages in a Web site. 
  ViewUsageData View reports on Web site usage. 

Had this question pop up at work today, to show all items without folders in SharePoint you will need to add the Recursive attribute to the SPQuery object.

 Here is an example, This can be done in Code:

 SPQuery.ViewAttributes += ” Scope=\”Recursive\””;

 Or as part of the CAML Query Markup

    <FieldRef Name=’ID’ /> 



   <ViewAttributes Scope=’Recursive’ /> 



Other query options are:

   <Folder>Name Of the Folder Here/</Folder>