PowerShell – Delete all “deleted” site collections in a web application

When you delete a site collection, it actually stays kicking around for a while, as explained at http://blogs.msdn.com/b/chaks/archive/2011/06/30/sharepoint-2010-sp1-site-recycle-bin-ui-experience.aspx.

As I happened to have a lot of deleted site collections I wanted to permanently remove, I was not satisfied with having to manually grab the site collection ID’s and plunk them into the Remove-SPDeletedSite PowerShell command one-by-one.

So, below is the method to delete ALL the “deleted” site collections under a specified web application. In this case, the web application URL is http://sharepoint – replace with your own desired web app URL:

Get-SPDeletedSite -webapplication http://sharepoint | Remove-SPDeletedSite

You will be prompted to delete them one by one, if you want it to run through them all without further prompts just enter the letter “A”.

Read More

Check SharePoint 2010 anonymous permissions

Great PowerShell for checking the state of SharePoint anonymous permissions from Max Ruswell at Microsoft:

SharePoint PowerShell Script Series Part 6 – Is Anonymous Access Enabled?

Note:  This PowerShell script is tested only on SharePoint 2010

Instructions for running the script:

1. Copy the below script and save it in notepad
2. Save it with a anyfilename.ps1 extension
3. To run, copy the file to a SharePoint Server
4. Select Start\Microsoft SharePoint 2010 Products\SharePoint 2010 Management Shell
5. Browse to directory holding the copied script file
6. Run the script: .\anyfilename.ps1 (assuming anyfilename is the name of the file)

<# ==============================================================
//
// Microsoft provides programming examples for illustration only,
// without warranty either expressed or implied, including, but not
// limited to, the implied warranties of merchantability and/or
// fitness for a particular purpose.
//
// This sample assumes that you are familiar with the programming
// language being demonstrated and the tools used to create and debug
// procedures. Microsoft support professionals can help explain the
// functionality of a particular procedure, but they will not modify
// these examples to provide added functionality or construct
// procedures to meet your specific needs. If you have limited
// programming experience, you may want to contact a Microsoft
// Certified Partner or the Microsoft fee-based consulting line at
// (800) 936-5200.
//
// For more information about Microsoft Certified Partners, please
// visit the following Microsoft Web site:
// </span><a href="https://partner.microsoft.com/global/30000104"><span style="font-size: x-small;">https://partner.microsoft.com/global/30000104</span></a>
<span style="font-size: x-small;">//
// Author: Russ Maxwell (russmax@microsoft.com)
//
// ---------------------------------------------------------- #></span>
<h3></h3>
<span style="font-size: x-small;">[Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") </span>
<h3></h3>
<span style="font-size: x-small;">Start-SPAssignment -Global</span>
<h3></h3>
<span style="font-size: x-small;">######################################
##Creating and Returning a DataTable##
######################################
function createDT()
{
###Creating a new DataTable###
$tempTable = New-Object System.Data.DataTable

##Creating Columns for DataTable##
$col1 = New-Object System.Data.DataColumn("Anonymous Access")
$col2 = New-Object System.Data.DataColumn("Level")
$col3 = New-Object System.Data.DataColumn("URL")
$col4 = New-Object System.Data.DataColumn("Configured List\Lib")

###Adding Columns for DataTable###
$tempTable.columns.Add($col1)
$tempTable.columns.Add($col2)
$tempTable.columns.Add($col3)
$tempTable.columns.Add($col4)

return ,$tempTable
}</span>
<h3></h3>
<span style="font-size: x-small;">#####################################
##Check WebApp for Anonymous Access##
#####################################
function checkwebappAnon()
{
$webAnon = $site.IISAllowsAnonymous.tostring()
$tempanonCheck = 0;
if ($webAnon -eq "true")
{
#Add a row to DataTable
$row = $dTable.NewRow()
$row["Anonymous Access"] = "Enabled"
$row["Level"] = "WebApplication"
$row["URL"] = $site.WebApplication.Name
$dTable.rows.Add($row)
}

}</span>
<h3></h3>
<span style="font-size: x-small;">######################################
##Check the Site for Anonymous Access#
######################################
function checksiteAnon()
{
$tempanonCheck = 0
$checkWeb = $web.AllowAnonymousAccess.tostring()
$checkWebState = $web.AnonymousState.tostring()
$webMask = $web.AnonymousPermMask64.tostring()
Write-Host
Write-Host "Checking how Anonymous is set up on site: " $web.Url -ForegroundColor Magenta

if(($checkWeb -eq "True") -and ($checkWebState -eq "On"))
{
#Add a row to DataTable#
$row = $dTable.NewRow()
$row["Anonymous Access"] = "Enabled"
$row["Level"] = "Site Level: Entire WebSite"
$row["URL"] = $web.Url.tostring()
$dTable.rows.Add($row)
$tempResult = 1
}

elseif(($checkWeb -eq "False") -and ($checkWebState -eq "Enabled") -and ($webMask -eq "Open"))
{
#Add a row to DataTable#
$row = $dTable.NewRow()
$row["Anonymous Access"] = "Enabled"
$row["Level"] = "Site Level: Lists and Libraries"
$row["URL"] = $web.Url.tostring()
$dTable.rows.Add($row)
$tempResult = 2
}

else
{
$tempResult = 3
}

return $tempResult
}</span>
<h3></h3>
<span style="font-size: x-small;">############################################
##Check List\Libraries for Anonymous Access#
############################################
function checklistAnon()
{
###Checking each list and library for anonymous access###
$lists = $web.lists
$count1 = $lists.count
$hasAnon = 0

Write-Host "Checking " $lists.count " lists\libaries for Anonymous Access" -ForegroundColor Magenta

###Setting String Vars###
$defMask1 = "OpenWeb"
$defMask2 = "EmptyMask"
$defTax = "TaxonomyHiddenList"

foreach($list in $lists)
{
$listUrl = $web.url + "/" + $list.Title
$listMask = $list.AnonymousPermMask.tostring()
$tax = $list.Title.ToString()

##Checking List eventhough Anonymous Access was disabled at SPWeb Level##
if(($webResult -eq '3') -and ($defTax.CompareTo($tax) -ne '0'))
{
if($listMask.CompareTo($defMask2) -ne '0')
{
if($listMask.CompareTo($defMask1) -eq '0')
{
#Anonymous Access is Enabled but not Configured on list\library#
$row = $dTable.NewRow()
$row["Anonymous Access"] = "Enabled"
$row["Level"] = "List\Library"
$row["URL"] = $listUrl
$row["Configured List\Lib"] = "No"
$dTable.rows.Add($row)
$hasAnon++
}
else
{
#Anonymous Access Enabled and Configured on list\library#
$row = $dTable.NewRow()
$row["Anonymous Access"] = "Enabled"
$row["Level"] = "List\Library"
$row["URL"] = $listUrl
$row["Configured List\Lib"] = "Yes"
$dTable.rows.Add($row)
$hasAnon++
}
}
}

elseif(($webResult -eq '2') -and ($defTax.CompareTo($tax) -ne '0'))
{
if(($listMask.CompareTo($defMask2) -ne '0') -and ($listMask.CompareTo($defMask1) -ne '0'))
{
#Anonymous Access Enabled and Configured on list\library#
$row = $dTable.NewRow()
$row["Anonymous Access"] = "Enabled"
$row["Level"] = "List\Library"
$row["URL"] = $listURL
$row["Configured List\Lib"] = "Yes"
$dTable.rows.Add($row)
$hasAnon++
}
}
$count1--
if($count1 % '10' -eq '0')
{
Write-Host "Total # of lists\libraries left to check: " $count1 -ForegroundColor DarkYellow
}
}
Write-Host
Write-Host "Total # of lists\libraries with Anonymous Access Enabled: " $hasAnon -ForegroundColor Cyan
}
</span>
<h3></h3>
<span style="font-size: x-small;">########################
###Script Starts Here###
########################
$output = Read-Host "Enter a location for the output file (For Example: c:\logs\)"
$filename = Read-Host "Enter a filename"
$url = Read-Host "Please enter the URL of desired site collection and press enter"</span>
<h3></h3>
<span style="font-size: x-small;">###Getting a new DataTable###
[System.Data.DataTable]$dTable = createDT</span>
<h3></h3>
<span style="font-size: x-small;">###Getting Site Collection###
$site = Get-SPSite $url</span>
<h3></h3>
<span style="font-size: x-small;">###Checking if WebApp has Anonymous set###
checkwebappAnon</span>
<h3></h3>
<span style="font-size: x-small;">###Gathering web collection###
$webs = $site.Allwebs
$count = $webs.Count
Write-Host "Checking for Anonymous Access on " $count " Sites" -ForegroundColor Magenta</span>
<h3></h3>
<span style="font-size: x-small;">foreach($web in $webs)
{
$webResult = 0
###calling function to check anonymons on spweb###
$webResult = checksiteAnon

if(($webResult -eq '2') -or ($webResult -eq '3'))
{
Write-Host "Checking for Anonymous Access on List and Libraries" -ForegroundColor Magenta
###calling function to check anonymons on lists and libs###
checklistAnon
}

$count--

if($count -ne '0')
{
Write-Host
Write-Host "Total # of sites left to check: " $count -ForegroundColor DarkYellow
}

else{Write-Host "Operation Completed" -ForegroundColor DarkYellow}
}</span>
<h3></h3>
<span style="font-size: x-small;">if($dTable -ne $null)
{
$name = $output + "\" + $filename + ".csv"
$dTable | Export-Csv $name -NoTypeInformation
Write-Host "Anonymous Access was detected" -ForegroundColor Green
Write-Host "Log File Created: " $name
}
else
{
Write-Host "Anonymous Access is Disabled for the entire Site Collection" -ForegroundColor Green
Write-Host "No Log File Created" -ForegroundColor Green
}

Stop-SPAssignment -Global
Read More

CKS Dev New Release 2.4 – Content Type With Event Receiver and Web Template SPI

This project extends the Visual Studio 2010 SharePoint project system with advanced templates and tools. Using these extensions you will be able to find relevant information from your SharePoint environments without leaving Visual Studio. You will have greater productivity while developing SharePoint components and you will have greater deployment capabilities on your local SharePoint installation.

What’s new in this release  CKS Dev New Release 2.4   Content Type With Event Receiver and Web Template SPI SharePoint 2010 event handlers development content type

The current 2.4 release includes the following features:

  • Content Type With Event Receiver SPI – New Content Type with Event Receiver project item template.
  • Web Template SPI – New Web Template project item template.

Download CKSDev

This CodePlex site serves as the place to get project news and source code. The extensions themselves are distributed through the Visual Studio Gallery. You have direct access to the Visual Studio Gallery from within the Extension Manager. For installation instructions see the Installation Guide. Never miss an update again, with direct update notification from the Visual Studio Gallery when we publish a new version.

Which version should I download?

If you are using SharePoint Foundation 2010 then download and install the SharePoint Foundation 2010 version

If you are using SharePoint Server 2010 then download and install the SharePoint Server 2010 version

Features

This project provides extensions to four core areas; Environment, Exploration, Content and Deployment. Enhancements to the Visual Studio environment include the new SharePoint References tab available on the Add Reference dialog, allowing you to easily reference any SharePoint assembly without searching the file system or GAC for it. Exploration extends the new SharePoint Explorer with advanced information about SharePoint sites such as the installed Web Parts and Master Pages or the Feature dependencies and elements. Also included in the Explorer are a variety of import functions to bring existing SharePoint items into your active solution. The Content area includes advanced templates such as Linq to SharePoint, Custom Action or Delegate Control. Project templates include the SharePoint Full Trust Proxy and the SharePoint Console Application. Our enhanced Deployment functions give you the ability to utilise quick deployment and almost a dozen other productivity enhancing deployment steps, including automated deployment (per file on change deployment) Find the complete overview of all the CKS Development Tools Edition features on the Documentation tab.

With the release of Microsoft’s excellent Visual Studio 2010 SharePoint Power Tools the CKSDev team have retired the Sandboxed Visual web part item template. for more information read Wouter’s blog

Read More

Object in the sharepoint administrative framework, SPsolutionLanguagePack Name=0, depends on other objects which do not exist

I encountered the following error today when trying to use the Sharepoint 2010 Management Shell Add-SPSolution to install a .WSP

“an object in the sharepoint administrative framework, “SPsolutionLanguagePack Name=0″, depends on other objects which do not exist”

I noted that there were a lot of recent MSI install (Windows Updates) that morning in the style of “Windows Installer reconfigured the product. Product Name: Microsoft SharePoint Foundation 2010 1033 Lang Pack. Product Version: 14.0.6029.1000. Product Language: 1033. Manufacturer: Microsoft Corporation. Reconfiguration success or error status: 0.”

Putting 2 and 2 together I figured they were more than happenstance to be occuring in parallel all of a sudden. So I did what anyone intimate with IIS would do: splash it in the face with a cold bucket of IISRESET.EXE.

Add-SPSolution subsequently worked. Will update if I ever learn more details.

 

*** UPDATE – it seem’s this may possibly be caused by installing a WSP before it’s previously been removed. Especially in a multi-server far where solutions have to be deployed or retracted in parallel across several machines, there may be a bit of lag. Give it a few minutes then try again, before resorting to IISReset or swearing.

Read More

Nintex Custom Actions permissions – Understanding RunWithElevatedPrivileges

When trying to do a simple System.IO.File.Copy inside the context of a Custom Nintex Action I wrote, I found that I couldn’t get the file to copy to a particular Windows Server File Share. Even though I had assigned the user name that was running the Nintex Workflow Read/Write permissions on the share, it would fail with an error indicating lack of access to that folder.

It worked ok if I set “Everyone” with Read/Write permissions. Reviewed the great article on Windows Server 2008 File Share setup at http://www.techotopia.com/index.php/Configuring_Windows_Server_2008_File_Sharing , still it was clear the File Share was just net configured right.

The source of the issue is that in running the File Copy code inside a RunWithElevatedPrivileges block, it is actually using a different account than the one running the workflow. Here is the Nintex Execute Activity function in question:

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
		{
			NWWorkflowContext ctx = NWWorkflowContext.GetContext(
			   this.__Context,
			   new Guid(this.__ListId),
			   this.__ListItem.Id,
			   this.WorkflowInstanceId,
			   this);

			base.LogProgressStart(ctx);
				SPSecurity.RunWithElevatedPrivileges(() =>
				{
					if (!Directory.Exists(ctx.AddContextDataToString(OutputPath)))
						Directory.CreateDirectory(ctx.AddContextDataToString(OutputPath));
					File.Copy(ctx.AddContextDataToString(SourcePath) + ctx.AddContextDataToString(strFileName),ctx.AddContextDataToString(OutputPath) + ctx.AddContextDataToString(strFileName),true);
				});
			}
			catch (Exception ex2)
			{
			    EventLog.WriteEntry("CopyFile Create Exception - Source File [" + SourcePath + strFileName + "] Output File [ " + OutputPath + strFileName + "]", ex2.Message + ", StackTrace: " + ex2.StackTrace, EventLogEntryType.Error, 9999);
			}
			base.LogProgressEnd(ctx, executionContext);
			return ActivityExecutionStatus.Closed;
		}

Two good comments from the MSDN reference at http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx:

The other thing to remember regarding this method call is that the account NAME that is being used is “SHAREPOINT/SYSTEM” and this does not resolve to an actual domain account. Now the only time this becomes and issue is when one is referring to Windows resources outside of SharePoint. Again this is only intended to be used for resources within SharePoint. If your function code is say calling even a SharePoint web service and one sets the web service “Credential” to “System.Network.CredentialCache.DefaultNetworkCredential” that the service call will in fact fail because IIS will not be able to resolve the domain account “SHAREPOINT/SYSTEM”. If the case is one needs to access external data then consider using a Secure Store credential.

And:

I’ve always found that the nuances of RunWithElevatedPrivileges cause much confusion as well as some weird and wonderful behavior if not properly understood. While the documentation here does a good job of explaining how and when to use it, it’s missing a key piece of information and that’s how the mechanism actually works.

Behind the scenes, RunWithElevatedPrivileges impersonates the identity of the current thread. In effect, this means that the delegate will run under the context of the application pool account, in the case of the code being called in the W3P process, or in the context of the SPTimerv4 service, in the case of the code being called in a workflow, timer job or anything else that’s kicked off using the timer. If the code is running in a console application or some other user-initiated app, the delegate will be kicked off using the context of the user who started the application. (Which would be the default behavior anyway).

When using workflows, bear in mind that the workflow may start running under W3P but continue executing under owstimer (SPTimerV4) depending on what it’s actually doing. In this case a delegate executed using RunWithElevatedPrivileges would not neccesarily yeild the same result.

PS nifty trick if you’ve forgotten about it: just add a $ to the end of the share name (rendering it accessible but invisible when people browse the shares).

Read More

Open modal dialog and refresh the parent page from custom form SharePoint 2010

What

You need to open a SharePoint 2010 popup (SPModalDialog) and refresh the parent page on close.

So What

End Users get griefed when they add an amazing new bit of content to SharePoint, but after submitting it’s not immediately visible on the page they just “came from” (even though geeks know the score).

Now What

Add the following code (assuming you are up to snuff on the basics of the SP Modal Dialog methods – here’s a good primer):

<script type="text/javascript">
    function openMyDialog(itemid,title) {
        var options = SP.UI.$create_DialogOptions();
        var layoutsUrlView = SP.Utilities.Utility.getLayoutsPageUrl('WebParts/MyWebPart/ViewDialog.aspx')
        options.url = layoutsUrlView + "?itemid=" + itemid + "&title=" + title;
        options.autosize = true;
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
        SP.UI.ModalDialog.showModalDialog(options);
    }
    function CloseCallback(result, target) {
        location.reload(true);
    }
</script>

Now when you close the popup, the parent page is refreshed.

Read More

Nintex – Specified value is not supported for the urlOfFile parameter

Recently after a Ninxtex migration/version update we encountered the following error when trying to publish any workflow:

nintex error Nintex   Specified value is not supported for the urlOfFile parameter SharePoint 2010 nintex lists

Windows Event Log Error:
System.ArgumentException: urlOfFile Parameter name: Specified value is not supported for the urlOfFile parameter.
at Microsoft.SharePoint.SPFileCollection.get_Item(String urlOfFile)
at Nintex.Workflow.WorkflowRepository.NameInUse(String workflowName, Guid listId, WorkflowType& workflowType)
at Nintex.Workflow.ApplicationPages.SetName.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.OnLoad(EventArgs e)
at Microsoft.SharePoint.WebControls.LayoutsPageBase.OnLoad(EventArgs e)
at Nintex.Workflow.ServerControls.NintexLayoutsBase.OnLoad(EventArgs e)
at Nintex.Workflow.ApplicationPages.SetName.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

To resolve this, go to the hidden NintexWorkflows library and check the contents of each subfolder. If your site is http://farm/sites/test the URL would be http://farm/sites/test/NintexWorkflows. If any subfolder is empty (contains no files), delete the subfolder – you should be able to publish after that.

Read More

SharePoint 2010 101 Code Samples

The SharePoint 2010 101 Code Samples set of examples is an excellent starting point for Developing with SharePoint.

Each code sample is part of the SharePoint 2010 101 code samples project. These samples are provided so that you can incorporate them directly in your code.

Each code sample consists of a standalone project created in Microsoft Visual Studio 2010 and demonstrates a distinct feature or feature set. Each sample includes comments describing the sample and the expected results. Each sample also contains comments that explain how to set up your environment so that the sample code runs, where necessary.

Microsoft SharePoint 2010 gives you the tools needed to create powerful applications. These managed code (C#, VB.NET, JavaScript, XML) samples can assist you in creating your own applications that perform specific functions or as a starting point to create more complex solutions.

To open a solution:
1. Start Microsoft Visual Studio 2010.
2. On the File menu, click Open, and then click Project/Solution.
3. Navigate to the folder containing the .sln file, select it, and then click Open.

To run a solution:
1. In the solution files, read and follow the comments that describe how to set up your environment if necessary.
2. On the Build menu, click Build Solution.
3. When you have a successful build, right-click the project in the Solution Explorer window, and then click Deploy.

List of all Examples in the pack:

SharePoint 2010 Developing Styled Master Pages
This sample creates and deploys branded master pages to customize SharePoint sites, including custom stylesheets and images.

SharePoint 2010 Developing JQuery-Enabled Web Parts
This sample develops a Web Part that uses the JQuery library to display items from a SharePoint list.

SharePoint 2010 Hosting Silverlight Applications that Call Azure Services
This sample calls WCF web services that are hosted in Windows Azure from Silverlight applications that are stored in SharePoint.

SharePoint 2010 Developing AJAX-Enabled Web Parts
This sample creates a SharePoint Web Part that uses Ajax UpdatePanel and UpdateProgress controls to call server-side methods.

SharePoint 2010 Leveraging HTML5 Objects in SharePoint
This sample uses custom SharePoint master pages to enable IE9 and other compliant browsers to render HTML5 tags such as <audio>.

SharePoint 2010 Creating List Items from Silverlight
This sample creates SharePoint list items by calling the SharePoint Client Object Model from Silverlight applications.

SharePoint 2010 Developing Web Templates
This sample creates web templates, which are similar to SharePoint site definitions, but can be used in sandboxed solutions.

SharePoint 2010 Creating Document Sets Programmatically
This sample creates new SharePoint document sets and configures their properties.

SharePoint 2010 Developing List Definitions
This sample uses declarative programming to create a SharePoint list definition and an instance of that list.

SharePoint 2010 Developing Custom Navigation Providers
This sample creates and deploys two links to the top link bar on a SharePoint site.

SharePoint Online Accessing Web Services
This sample connects to SharePoint Online, authenticates by using claims authentication, and then displays the contents of a SharePoint Online list.

SharePoint 2010 Querying SQL Azure Data from Web Parts
This sample queries a SQL Azure database from code in a SharePoint Web Part.

SharePoint 2010 Developing Sequential Workflows
This sample develops SharePoint sequential workflows based on items in task lists.

SharePoint 2010 Creating Custom Field Types
This sample creates a new field type that adds options for users who create new columns in SharePoint lists, libraries, or content types.

SharePoint 2010 Creating Items in Lists from External WCF Services
This sample creates SharePoint list items by calling a method in a WCF service that uses the SharePoint List Data Retrieval Web Service.

SharePoint 2010 Developing Workflow Activities
This sample creates and deploys custom workflow activities that can be used in SharePoint Designer to extend workflows.

SharePoint 2010 Performing Cross-List Queries
This sample uses the SPSiteDataQuery class to find items from all the lists in a SharePoint site.

SharePoint 2010 Creating Custom Timer Jobs
This sample creates and schedules a SharePoint timer job that runs code at regular intervals.

SharePoint 2010 Developing Starter Master Pages
This sample sets master pages for SharePoint sites by using feature receivers, and deploys master pages without styles or images as starters for branded master pages.

SharePoint 2010 Updating SQL Azure Records from Web Parts
This sample saves changes to a SQL Azure record by using code in a SharePoint Web Part.

SharePoint 2010 Uploading SharePoint Library Content to Azure Storage
This sample uploads files from a SharePoint document library to Windows Azure storage.

SharePoint 2010 Displaying Video Files Stored in Azure
This sample displays videos stored in Windows Azure in Silverlight applications.

SharePoint 2010 Creating SQL Azure Records from Web Parts
This sample inserts records into SQL Azure tables by using code in SharePoint Web Parts.

SharePoint 2010 Developing Feature Receivers
This sample develops a Feature receiver that performs an action when Features activate and cleans up when Features deactivate.

SharePoint 2010 Calling Azure Services from Event Receivers
This sample calls WCF web services hosted in Windows Azure from SharePoint event receivers.

SharePoint 2010 Using JavaScript and CAML to Query Lists
This sample uses the SharePoint Client Object Model to display the details of all the items in a SharePoint list.

SharePoint 2010 Creating Custom SharePoint Service Applications
This sample returns the current weekday by using a custom service application for SharePoint.

SharePoint 2010 Creating Content Types Programmatically
This sample creates SharePoint content types nondeclaratively in code.

SharePoint 2010 Developing Connected Web Parts
This sample creates two SharePoint Web Parts that you can connect to exchange information.

SharePoint Online Authenticating Using the Client-Side Object Model
This sample connects to, and authenticates in, SharePoint Online.

SharePoint 2010 Using REST to Discover the Contents of Excel Worksheets
This sample displays the names of tables that are in a spreadsheet by calling RESTful Excel Web Services.

SharePoint 2010 Displaying User Profile Pictures Programmatically
This sample evaluates and displays the pictures of all users who have set profile pictures in a Web Part.

SharePoint 2010 Using LINQ in REST Requests
This sample uses LINQ queries to return filtered lists of items from SharePoint lists.

SharePoint 2010 Accessing SharePoint Lists from External WCF Services
This sample writes a WCF service that returns all the items in SharePoint lists, and includes a sample client console application to test the service.

SharePoint 2010 Calling Azure Services from Web Parts
This sample calls WCF web services hosted in Windows Azure from SharePoint Web Parts.

SharePoint 2010 Performing Searches from Silverlight
This sample calls the SharePoint Search web service from a Silverlight application.

SharePoint 2010 Performing Searches from Web Parts
This sample calls a SharePoint Search or FAST Search service application from a Web Part.

SharePoint 2010 Creating Content Organizer Rules Programmatically
This sample creates and configures content organizer rules for content types in SharePoint document libraries.

SharePoint 2010 Creating Taxonomies Programmatically
This sample adds SharePoint groups, term sets, and terms to a term store programmatically.

SharePoint 2010 Developing Custom Field Controls
This sample creates custom field controls that display and edit fields on SharePoint publishing sites.

SharePoint 2010 Developing Application Pages
This sample creates and deploys a simple application page that displays information about the current SharePoint site, and modifies its description.

SharePoint 2010 Programmatically Reading User Profile Properties
This sample obtains properties from all SharePoint user profiles in your organization.

SharePoint 2010 Developing Event Receivers
This sample develops and registers an event receiver that intercepts SharePoint list item events such as ItemAdded and ItemUpdating.

SharePoint 2010 Managing Document Sets Programmatically
This sample reads properties from all the document sets in a given SharePoint document library.

SharePoint 2010 Deleting SQL Azure Records from Web Parts
This sample deletes records in SQL Azure by using code in SharePoint Web Parts.

SharePoint 2010 Calling Azure Services from Custom Workflow Activities
This sample calls WCF web services hosted in Windows Azure from code in SharePoint workflows.

SharePoint 2010 Accessing List Items from Silverlight
This sample returns items in SharePoint lists (in Silverlight applications) by using the SharePoint Client Object Model.

SharePoint Online Creating Documents Using Word, PowerPoint, or OneNote Web App
This sample creates custom ribbon actions that use JavaScript and Office Web Apps to create new Word, PowerPoint, and OneNote documents.

SharePoint Online Creating and Deploying Sandboxed Workflow Activities
This sample creates a workflow activity that functions in a sandboxed solution on SharePoint Online.

SharePoint 2010 Importing Content by Using the Content Deployment API
This sample imports content from CMP files into SharePoint lists by calling the Content Migration API.

SharePoint 2010 Developing Connected Silverlight Web Parts
This sample creates interconnected custom SharePoint Web Parts that can host Silverlight applications that exchange information.

SharePoint 2010 Programmatically Finding Tagged Items
This sample locates terms that match input strings and then locates all items tagged with those terms in SharePoint lists.

SharePoint 2010 Logging Site Events Programmatically
This sample develops and registers event receivers to intercept web events such as SiteDeleted and WebMoved, and logs those events to a list for auditors.

SharePoint 2010 Using REST to Obtain Excel Charts
This sample obtains image files of charts from Excel spreadsheets via REST.

SharePoint 2010 Calling WCF Services from Web Parts
This sample calls a WCF service that retrieves data after users click a button in a SharePoint Web Part.

SharePoint 2010 Deleting Items in Lists from External WCF Services
This sample creates a WCF service that finds a SharePoint item and deletes it.

SharePoint 2010 Using JavaScript to Edit and Save Values in Items
This sample uses the SharePoint Client Object Model to change items in SharePoint lists.

SharePoint 2010 Developing Page Layouts
This sample creates and deploys custom page layouts for content types in SharePoint publishing sites.

SharePoint 2010 Declaring Records Programmatically
This sample can determine whether a document is a record and declare it as a record.

SharePoint 2010 Calling Azure Services from Timer Jobs
This sample calls WCF web services hosted in Windows Azure from SharePoint timer jobs.

SharePoint 2010 Developing Solution Validators
This sample develops SharePoint solution validators that check activating user solutions and help verify sandboxed solutions.

SharePoint 2010 Developing Custom Expiration Actions
This sample specifies custom actions to take and code to run after a document expires against a SharePoint information management policy.

SharePoint 2010 Retrieving List Contents and Parsing Atom Responses
This sample gets all the items in a SharePoint list by using the RESTful List Data web service.

SharePoint Online Creating and Deploying Sandboxed Event Receivers
This sample responds to item events (such as ItemAdded) in sandboxed event receivers.

SharePoint 2010 Using REST to Query Data Ranges in Excel Worksheets
This sample gets and displays data from a date range in an Excel spreadsheet by querying RESTful Excel Web Services.

SharePoint 2010 Developing Ribbon Actions
This sample adds a button control (to the SharePoint ribbon) that runs JavaScript when clicked.

SharePoint 2010 Developing Delegate Controls
This sample creates an ASP.NET user control to replace the standard SharePoint Global Navigation.

SharePoint 2010 Working with Disposable Objects
This sample disposes SPWeb and SPSite objects properly so that they do not unnecessarily consume memory.

SharePoint 2010 Logging Data to the Developer Dashboard
This sample uses monitored scopes to log information to developer dashboards, and includes scripts to enable and disable those dashboards.

SharePoint Online Creating Excel Worksheets by Using Excel Web App
This sample creates custom ribbon actions that use JavaScript and Excel Web Apps to create new spreadsheets.

SharePoint 2010 Using JQuery to Retrieve List Contents in JSON
This sample uses the JQuery library to obtain and display items in SharePoint lists.

SharePoint 2010 Retrieving Single List Items in REST Requests
This sample gets a single item from a SharePoint list by using the RESTful List Data web service.

SharePoint 2010 Calling WCF Services from Custom Workflow Activities
This sample calls a WCF service from a SharePoint workflow that starts after a new item is created, and then modifies the item body field of that workflow.

SharePoint 2010 Retrieving List Contents in JSON Format and Parsing Responses
This sample gets items from SharePoint lists in JSON format, parses the responses, and then displays the item properties.

SharePoint 2010 Using JavaScript to Show Dialog Boxes
This sample uses the SharePoint Client Object Model to display an application page as a dialog box.

SharePoint 2010 Calling WCF Services from Event Receivers
This sample calls a WCF service from an event receiver; after a new item is added to a SharePoint list, the service returns data that is appended to the body of that new item.

SharePoint 2010 Performing Cached Cross-Site Queries
This sample uses the SharePoint PortalSiteMapProvider class to perform high-performance cross-site queries.

SharePoint 2010 Using REST to Create a SharePoint and Bing Maps Mashup
This sample uses JavaScript to integrate data from Excel spreadsheets in SharePoint with Bing Maps.

SharePoint 2010 Using JavaScript to Enable Notifications
This sample uses SharePoint status and notifications to feed back information to users.

SharePoint 2010 Using JavaScript to Create Lists
This sample uses the SharePoint Client Object Model to create SharePoint lists with JavaScript.

SharePoint 2010 Using JavaScript to Retrieve and Interrogate Items in Lists
This sample uses the SharePoint Client Object Model with a CAML query to return matching items from lists.

SharePoint 2010 Developing Branded Media Controls
This sample brands a Media Field Control on a SharePoint site.

SharePoint 2010 Using JavaScript to Delete Items from Lists
This sample uses the SharePoint Client Object Model to delete items from a SharePoint list with JavaScript.

SharePoint 2010 Using JavaScript to Update Site Properties
This sample uses the SharePoint Client Object Model to set titles and descriptions for SharePoint sites.

SharePoint 2010 Using JavaScript to Get Details About Sites
This sample uses the SharePoint Client Object Model to display information about the current SharePoint site.

SharePoint 2010 Developing Editor Web Parts
This sample modifies a Web Part properties sheet to include an Editor Web Part that enables users to choose from all the lists in the SharePoint site.

SharePoint 2010 Calling RESTful SharePoint Services From Desktop Applications
This sample uses a service reference to connect to the List Data Retrieval Web Service and display lists of SharePoint items in a Data Grid.

SharePoint Online Accessing Current User Information in Sandboxed Solutions
This sample creates a Web Part that functions in a sandboxed solution on SharePoint Online and gets information about the current user.

SharePoint 2010 Canceling Synchronous Events
This sample checks the properties of synchronous events and cancels them to prevent users from deleting SharePoint items.

SharePoint 2010 Calling WCF Services Hosted in SharePoint
This sample calls a WCF service that is hosted by Sharepoint, and whose code uses the SharePoint Foundation Server-Side Object Model.

SharePoint 2010 Developing Ribbon Drop Down Controls
This sample uses a drop-down control on the SharePoint ribbon to forward users to the selected list.

SharePoint 2010 Developing State Machine Workflows
This sample develops state machine workflows based on documents in SharePoint document libraries and items in tasks lists.

SharePoint Online Deploying Sandboxed Content Types and List Definitions
This sample creates a Web Part that functions in a sandboxed solution on SharePoint Online and uses code to create content types and list definitions.

SharePoint 2010 Developing Sandboxed Web Parts
This sample creates a Web Part in a sandboxed solution, and includes Panels to hide controls, radio buttons, and the Render method.

SharePoint 2010 Using JavaScript to Get Details About Site Collections
This sample uses the SharePoint Client Object Model to display information about the current site collection.

SharePoint 2010 Calling WCF Services from Timer Jobs
This sample calls a WCF service from a custom timer job that creates a new announcement when it runs.

SharePoint 2010 Developing Site Definitions
This sample creates a custom SharePoint site definition that specifies Content Editor and Image Viewer Web Parts on a Web Part page.

SharePoint 2010 Developing Custom Expiration Formulae
This sample calculates an expiration date for a SharePoint information management policy by using a custom expiration formula.

SharePoint Online Creating and Deploying Sandboxed Web Parts
This sample creates a Web Part that checks whether it is in a sandboxed solution and displays the title of the SharePoint site.

SharePoint 2010 Exporting Content by Using the Content Deployment API
This sample exports content from SharePoint lists by calling the Content Migration API.

SharePoint Online Creating and Deploying Sandboxed Feature Receivers
This sample creates a feature receiver that works in a SharePoint Online sandboxed solution.

Read More

Shrink wrap your DLLs with Retail Mode

It happens: someone’s trying to debug a problem in a rush, a dev environment gets migrated – sometime’s it happens that your web.config Debug Mode switch gets inadvertently left in “true” mode. This is all kinds of bad- ScottGu highlights:

1) The compilation of ASP.NET pages takes longer (since some batch optimizations are disabled)
2) Code can execute slower (since some additional debug paths are enabled)
3) Much more memory is used within the application at runtime
4) Scripts and images downloaded from the WebResources.axd handler are not cached

http://weblogs.asp.net/scottgu/archive/2006/04/11/442448.aspx

On production, unless you have a multi-tenant server where some users may expect to be able to flip debug mode on (not a likely scenario in the SharePoint world!), it’s a wise best practice to alter the Machine.config to use Retail Mode.  Full reference here – link is SP 2007 but same principles apply.

<system.web>
<deployment retail=”true” />
</system.web

Just remember that editing the Machine.config is no trivial task- root instructions are here: http://support.microsoft.com/kb/815178, but it doesn’t explain that you must ensure nothing else on the machine is trying to update that machine.config while you have it open in Notepad. If this machine.config get’s out of synch with other settings, you will hose your server. You can ensure this doesn’t happen by:

  1. Turning of all IIS Sites and App pools
  2. Backing up the machine.config
  3. Open the machine.config in Notepad
  4. Change the Deployment to retail=true
  5. Save and close machine.config
  6. Start IIS Sites and App Pools
Read More

CKS Development Tools Edition for Visual Studio: New Version Out

Overview

The Community Kit for SharePoint: Development Tools Edition extends the Visual Studio 2010 SharePoint project system with advanced templates and tools. Using these extensions you will be able to find relevant information from your SharePoint environments without leaving Visual Studio. You will have greater productivity while developing SharePoint components and you will have greater deployment capabilities on your local SharePoint installation.

This version is targeted for users running SharePoint Foundation 2010, for the server version go here.

Features

This project provides extensions to four core areas; Environment, Exploration, Content and Deployment.

Enhancements to the Visual Studio environment include the new SharePoint References tab available on the Add Reference dialog, allowing you to easily reference any SharePoint assembly without searching the file system or GAC for it.

Exploration extends the new SharePoint Explorer with advanced information about SharePoint sites such as the installed Web Parts and Master Pages or the Feature dependencies and elements. Also included in the Explorer are a variety of import functions to bring existing SharePoint items into your active solution.

The Content area includes advanced templates such as Linq to SharePoint, Custom Action or Delegate Control. Become extra productive while developing sandboxed solutions using the SharePoint Full Trust Proxy. Utilise the SharePoint Console Application project template to quickly build SharePoint code.

Our enhanced Deployment functions give you the ability to utilise quick deployment and almost a dozen other productivity enhancing deployment steps, including automated deployment (per file on change deployment).

Find the complete overview of all the CKS Development Tools Edition features on the documentation tab of the project site. The CKS Development Tools Edition works with Microsoft’s Visual Studio 2010 SharePoint Power Tools.

What’s new in this release

The current 2.3 release includes the following features:

– Activate Quick Deploy from global shortcuts – Activating the shortcut keys now from any VS item not just the SP Project.
– New ASHX SPI – New ASHX handler project item template.
– Cancel Adding SPIs – Cancel adding SPIs feature which stops VS automatically adding a SPI to features.
– Updates for Quick Deployment steps – Correct processing of the assembly name.
– Quick Deploy GUID replacable params – Quick deploy now supports GUID based replaceable params and will represent the latest dll version of them.
– Quick Deploy fixes – Improvements to Quick Deploy. Read only files not locked during Quick Deploy.
– WCF SPI Template update – Changes to the SPI to deploy to the root of the ISAPI folder to remove the need for a custom web.config. This should make deployment simple for default WCF SPI’s while still allowing custom implementation with a sub folder and web.config to be done.

Contribute

If you have a great idea for a deployment tool, template or any other thing that you believe increases developer productivity, contribute! Contact the Project team or add your idea to the discussion forum. Use the #CKSDev tag to follow and connect with the team on Twitter.

About the Community Kit for SharePoint

The Community Kit for SharePoint is a set of editions, components, tools and recommended documentation for SharePoint development. You are currently viewing the edition project site for the Development Tools Edition. To learn about the other editions and components you can go to http://www.communitykitforsharepoint.org/default.aspx.

Read More
Page 1 of 512345