Wednesday, April 22, 2009

SharePoint Designer says I have a file checked out, but I don't

Occasionally, SharePoint designer may tell you you have a file checked out, but you don't. It won't let you undo checkout, because it's not checked out, and it won't let you check it in, because it's not checked out.

To resolve this, you need to go manually (ugh) into the cache on your machine and delete the offending files.

On Windows Server 2003, I had to go here:
cd %userprofile%\local settings\application data\microsoft\websitecache

On Vista, I had to go here:
cd %localappdata%\microsoft\websitecache

Once you get there, go into the folder of the website you're having trouble with, and delete everything in it. The next time you open SharePoint Designer, your file will not be marked as checked out.

Also, you might want to be sure you have other files checked in before you do this. You don't want to screw up the status of other files to fix just the one file, so be careful.

Thursday, April 16, 2009

SharePoint custom security trimming

Ok, so this turned out not to be so custom, but it was annoying enough to figure it out that I wanted to share.

My problem: I've created some custom widgets in my master page, but I only want Full Control people and Contributors to see them, not Readers, etc. So, I tried to use the SPRole to figure out what roles the current user was in. It didn't work as expected, plus it's depricated. So I moved on to the SPRoleDefinition and SPRoleAssignment classes. These also didn't give me what I wanted. Finally I did a search on tapping into SharePoint's security trimming, and found this gem.

Wrap the following tag around the thing that you want security trimmed, and SharePoint will take care of it for you.

<SharePoint:SPSecurityTrimmedControl id="something" runat="server" PermissionsString="AddAndCustomizePages"> your stuff goes here </SharePoint:SPSecurityTrimmedControl>

The important bit is what goes inside the PermissionsString attribute.

Here's a list of possible values:

List Permissions
ManageLists
CancelCheckout
AddListItems
EditListItems
DeleteListItems
ViewListItems
ApproveItems
OpenItems
ViewVersions
DeleteVersions
CreateAlerts
ViewFormPages

Site Permissions
ManagePermissions
ViewUsageData
ManageSubwebs
ManageWeb
AddAndCustomizePages
ApplyThemeAndBorder
ApplyStyleSheets
CreateGroups
BrowseDirectories
CreateSSCSite
ViewPages
EnumeratePermissions
BrowseUserInfo
ManageAlerts
UseRemoteAPIs
UseClientIntegration
Open
EditMyUserInfo

Personal Permissions
ManagePersonalViews
AddDelPrivateWebParts
UpdatePersonalWebParts