Archive

You are currently browsing the archives for the Tip category.

Feb

2

Setting up Anonymous Access

By Cory

I always seem to leave out a step when configuring anonymous access for a SharePoint site so I’ve finally put together a full guide so I don’t leave out any steps in the future.

Deactivate Hidden Features

If you are getting “Access Denied” for lists and libraries then you probably for got this step. There is a hidden feature that secures the lists and libraries by default for all sites that have anonymous access enabled. If you have already enabled anonymous access prior to deactivating this feature then you will need to turn all anonymous access off and back on to refresh this functionality.

  1. For each site collection that requires anonymous access execute the following stsadm command.
    stsadm -o deactivatefeature -url http://sitecollection -name ViewFormPagesLockDown

Read more »

Feb

2

Saving Your Command Line History

By Cory

Many times I find myself in a command window hacking away deploying solution packages or activating features to only later think to myself that I would love to save those commands to a batch file. Previously I would have copy and pasted the contents of the window into notepad and started removing all of the directory information but now I use this method below:

doskey /history > commands.bat

This will export the entire command window history into a file called commands.bat. You’ll just need to go into commands.bat and remove any of the unwanted commands. Enjoy!

Dec

11

SharePoint Search Crawled Properties Variant Types

By Cory

If you ever need to create SharePoint managed properties through code then you’re going to be asked for a Variant Type. Since I couldn’t find an enum in the code or any documentation to identify them I started digging through the SharePoint UI and was able to hunt down the following. Hopefully it will save the next person some time.

Read more about programmatically creating managed properties via MSDN.

Variant Type Data Type
31 Text
20 Integer
11 Yes/No
12 Binary Data
64 Date/Time

Sep

29

Undocumented List Definition Properties

By Cory

While the MSDN article gives most of the properties that you can use when configuring your list definition it does miss a few. I’ve documented the missing properties that I’ve found below:

Attribute

Description

ForceCheckout Optional Boolean. TRUE to require documents to be checked out before they can be edited.
EmailAssignTo Optional Boolean. TRUE to automatically send emails to the user when an item is assigned to them.
MajorVersionLimit Optional Integer. Specifies the number of major versions to retain when versioning is enabled.
MajorWithMinorVersionLimit Optional Integer. Specifies the number of draft versions to retain for each major version when versioning is enabled.

Sep

24

Querying a SharePoint List with LINQ

By Cory

I am continuously seeing the value in LINQ and I think with the upcoming changes in SharePoint 2010 I plan on making LINQ an even bigger part of my normal development practice.

First establish an SPList object of the list you would like to query data from.

SPList list = web.GetList("/Lists/ListUrl");

Next query the list; taking advantage of the filtering and sorting capabilities built into LINQ

var listItems = from SPListItem item in list.Items
                            orderby item.Title
                            ascending
                            select item;

And with a where query utilizing a custom field!

var listItems = from SPListItem item in list.Items
                            orderby item.Title
                            ascending
                            where ((DateTime)item["CustomExpirationField"]).DayOfYear >= DateTime.Now.DayOfYear
                            select item;

Now feel free to loop through your data and take care of business!

foreach (SPListItem item in listItems)
{
     // item.Title
     //etc
}

Aug

26

Shared Services Between Farms

By Cory

So let’s say that you have multiple SharePoint farms but want to search across them… enter “Shared Services Between Farms”. In this scenario you set one farm to be the provider and a second farm to be the consumer. The provider farm shares it’s Shared Service Provider with the consumer farm allowing you to associate one of your consumer farm’s web applications with one of the provider farms Shared Service Proviers.

Let’s get started… Read more »