My Latest Findings

Case #243: Failing Content Deployment Job

On September 27, 2011, in Administration, SharePoint, by matdesmarais
0

We were getting errors running a content deployment job at a client site and the SharePoint logs on the source server was only showing the following details:

ContentDeploymentJob.DoServerToServer(): caught exception ‘System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

To debug this issue, I used the trusty ULS Viewer tool from Microsoft on both the source server and the destination server. The source server only returned that error on each run with no further information.

The destination server however, listed the following few errors:

A runtime exception was detected. Details follow.  Message: Access to the path ‘E:ContentDeployment7a00d1c5-38a6-4186-af54-c5ead00e867e’ is denied.  Technical Details: System.UnauthorizedAccessException: Access to the path ‘E:ContentDeployment7a00d1c5-38a6-4186-af54-c5ead00e867e’ is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity)
at Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob.<>c__DisplayClass44.<CreateDirectoryAsProcessAccount>b__43()
at Microsoft.Office.Server.Security.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.ContentDeploymentUploadPage.<>c__DisplayClass4.<WriteFile>b__1()
at Microsoft.Office.Server.Security.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.ContentDeploymentUploadPage.<>c__DisplayClass4.<WriteFile>b__0()
at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)

AND

Upload file ‘E:ContentDeployment7a00d1c5-38a6-4186-af54-c5ead00e867eExportedFiles.cab’ failed: Exception thrown was: Microsoft.SharePoint.Publishing.Administration.ContentDeploymentException: The file upload operation for ‘E:ContentDeployment7a00d1c5-38a6-4186-af54-c5ead00e867eExportedFiles.cab’ failed. Ensure that the import folder can be created and has sufficient disk space for the uploaded file. Exception : ‘Access to the path ‘E:ContentDeployment7a00d1c5-38a6-4186-af54-c5ead00e867e’ is denied.’ —> System.UnauthorizedAccessException: Access to the path ‘E:ContentDeployment7a00d1c5-38a6-4186-af54-c5ead00e867e’ is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity)
at Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob.<>c__DisplayClass44.<CreateDirectoryAsProcessAccount>b__43()
at Microsoft.Office.Server.Security.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.ContentDeploymentUploadPage.<>c__DisplayClass4.<WriteFile>b__1()
at Microsoft.Office.Server.Security.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.ContentDeploymentUploadPage.<>c__DisplayClass4.<WriteFile>b__0()
at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)     –
— End of inner exception stack trace —
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.ContentDeploymentUploadPage.<>c__DisplayClass4.<WriteFile>b__2(Exception exception)
at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)
at Microsoft.Office.Server.Diagnostics.ULS.SendWatsonOnExceptionTag(UInt32 tagID, ULSCatBase categoryID, String output, Boolean fRethrowException, TryBlock tryBlock, CatchBlock catchBlock, FinallyBlock finallyBlock)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.ContentDeploymentUploadPage.WriteFile(String filepath)
at Microsoft.SharePoint.Publishing.Internal.CodeBehind.ContentDeploymentUploadPage.OnPageLoad(Object sender, EventArgs e)

To resolve this issue, I had to change the permissions on the destination folder’s ContentDeployment folder to allow Full Control to the Farm Account. This change allowed the job to complete succesfully.

Hope this can help diagnose your own content deployment issues.

 

SharePoint 2010 Dialog Window Branding

On August 24, 2011, in Branding, CSS, Dialog Windows, by matdesmarais
0

It has been a while since my last article. We have been extremely busy here with summer vacation and projects coming to term. Now that September is just around the corner, it is time to get back in gear. So here is another SharePoint 2010 branding tip: Branding Dialog Windows!

When you start applying your own custom style to a SharePoint site one thing you will start noticing is that the dialog windows also take on the styling that is applied to the main page. To prevent some items from appearing in the dialog windows, we need to add the following class to the html elements we want to hide:

s4-notdlg

Once placed in the class of an element it won’t be displayed (you can do this with items like the header div, the top navigation div, etc.)

But what happens if you apply a css class to an element in the homepage that cannot be hidden in the dialog box, such as the main content div or the bodyContainer div?

In that case you can use the following trick:

.s4-bodyContainer { width:950px; border: 1px black solid; }
html.ms-dialog .s4-bodyContainer { width:400px; border: none; }

The “html.ms-dialog” placed before an existing style class such as s4-bodyContainer will let you override the display when the page is in a dialog window. The main tag in the render takes on the class of ms-dialog and css will cause inheritance to this overridden css class.

There is more to come soon so stay tuned!

 

Updated: Provisioning Managed Metadata Columns

On August 11, 2011, in C#, SharePoint, Taxonomy, by matdesmarais
1
SharePoint 2010 now includes functionality for Managed Metadata. These new features add a lot of new features for end users but also add a level of extra complexity for us as developers. These issues are already discussed at length here: http://www.sharepointconfig.com/2011/03/the-complete-guide-to-provisioning-sharepoint-2010-managed-metadata-fields/ so I won’t get into the details of the issues but only provide a quick guide for provisioning these columns.

 

Here are the steps to take to provision Managed Metadata columns.
  • Start with an empty SharePoint Project in Visual Studio 2010.
  • Add a new Item to the project and select the Empty Element template.
  • In this new Element file, add the following xml definition for a Managed Metadata column and it’s associated hidden Note field:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <Field ID="{F2B1920F-2025-41EB-84DC-F59E29D17D33}" Type="TaxonomyFieldType" DisplayName="Contributor" ShowField="Term1033" EnforceUniqueValues="FALSE" Group="Custom Metadata" StaticName="Contributor" Name="Contributor" Overwrite="TRUE">
   <Customization>
     <ArrayOfProperty>
       <Property>
         <Name>TextField</Name>
         <Value xmlns:q6="http://www.w3.org/2001/XMLSchema" p4:type="q6:string" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">{35732AE5-9782-42F6-A44B-AF07ED2809CE}</Value>
       </Property>
     </ArrayOfProperty>
   </Customization>
 </Field>
 <Field ID="{35732AE5-9782-42F6-A44B-AF07ED2809CE}" Type="Note" DisplayName="Contributor_0" StaticName="ContributorTaxHTField0" Name="ContributorTaxHTField0" ShowInViewForms="FALSE" Required="FALSE" Hidden="TRUE" CanToggleHidden="TRUE" RowOrdinal="0" />
</Elements>

Updated: Aug 11, 2011 updated to add the Customization ArrayOfProperty that is required to make your content type be re-deployable. Without this, you will get a message that the hidden note field already exists.

  • Then we will add a new Content type to consume this new column. To do this add a new Item to the project and select Content Type in the templates. Provide a name and pick the content type that will be the base for this new content type.
  • In the Elements.xml file of the new content type add the following FieldRefs:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Article Page (0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D) -->
  <ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D00426fe9e90dd14ec8a88a4599ec58c3fd"
               Name="Article Page"
               Group="Article Page Layout Content Types"
               Description="Base for all article pages"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
     <FieldRef ID="{35732AE5-9782-42F6-A44B-AF07ED2809CE}" Name="ContributorTaxHTField0"/>
     <FieldRef ID="{F2B1920F-2025-41EB-84DC-F59E29D17D33}" Name="Contributor"/>
    </FieldRefs>
  </ContentType>
</Elements>
  • Make sure the Hidden field is added first so there won’t be an automatic Note field created by the Managed Metadata column and cause conflicts.
  • Now we need to add a feature event receiver on Feature1 of the project. (right clicking the Feature1 will give you the option of creating this)
  • In the feature event receiver, we need to uncomment the FeatureActivated block and add the following code to it:
using Microsoft.SharePoint.Taxonomy;

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    SPWeb web = properties.Feature.Parent as SPWeb;
    SPSite sitecoll = web.Site;

    //Attach Metadata Fields to Store
    AttachManagedMetadataFieldToStore("{F2B1920F-2025-41EB-84DC-F59E29D17D33}", "TaxonomyTermSetName", "TaxonomyTermGroupName", web, sitecoll, "{35732AE5-9782-42F6-A44B-AF07ED2809CE}");
}
  • You will also need the following helper functions to complete the feature:
public Group GetByName(GroupCollection groupCollection, string name)
{
	if (String.IsNullOrEmpty(name)) throw new ArgumentException("Not a valid group name", "name");
	foreach (var group in groupCollection)
	{
		if (group.Name == name)
		{
			return group;
		}
	}
	throw new ArgumentOutOfRangeException("name", name, "Could not find the group");
}

public void AttachManagedMetadataFieldToStore(string guid, string TS, string TG, SPWeb web, SPSite site, string NoteGuid)
{
	Guid fieldId = new Guid(guid);
	if (web.Fields.Contains(fieldId))
	{
		TaxonomySession s = new TaxonomySession(site);

		if (s.DefaultKeywordsTermStore != null)
		{
			var termStore = s.DefaultKeywordsTermStore;
			var groupCol = termStore.Groups;
			var group = GetByName(groupCol, TG);
			var termSet = group.TermSets[TS];

			TaxonomyField fld = site.RootWeb.Fields[fieldId] as TaxonomyField;

			// Attach Properties to field
			fld.SspId = termSet.TermStore.Id;
			fld.TermSetId = termSet.Id;
			fld.AnchorId = Guid.Empty;
			fld.TargetTemplate = string.Empty;
			fld.TextField = new Guid(NoteGuid);
			fld.Update();
		}
	}

}
This SharePoint solution can be packaged up and will provision the columns for you on activation.

Please note: Managed Metadata Columns do have limitations like not having any support in Infopath, not being supported in datasheet views, not being supported by Office 2007, etc… The complete list can be found on this post here: https://www.nothingbutsharepoint.com/sites/eusp/Pages/Managed-Metadata-Column-Limitations.aspx 

I will add a second part to this article soon on how to create the taxonomy term store using an xml import file instead of the OOTB csv import file so the GUIDs remain unchanged from deployment to deployment (handy for dev/qa/uat/prod multi-level environments.)
 

There was an update to the SharePoint 2010 language pack downloader to handle selecting and deselecting all the language packs at once.

This was a feature update requested by Ryan Dennis (@SharePointRyan). Ryan originally created a powershell script to download ALL the language packs, I took his idea and made this tool where you could pick and choose the ones you wanted. It is only fitting to have this checkbox to again download ALL of the language packs.

Thanks Ryan.

http://sp2010dl.codeplex.com/

If anyone wants to request other features to be added to this utility, let me know via Twitter (@matdesmarais).

 

 

The MSDN Health Blog has just posted an article that puts the spotlight on Orangutech as the partner of the year award winner for Health.

Check out their article here.

 

I just found an article that details how to give your FBA users the control to manage their password through SharePoint. I believe this could come in handy for many projects.

When you want to use form based authentication for SharePoint authentication, one of the requirements could be that users can change their passwords from within SharePoint. Because this functionality is not OOTB available, you will need to create a custom web part or application page for it. Check what best matches your project requirements. The code behind it will be the same, and this is what will be covered in this blog post.

Read the rest of this article written by Elio Struyf here.

 

An article was just submitted online Breaking news: FAST folks laid off from Microsoft that makes FAST Search’s future very uncertain.

Does Microsoft have a plan to bundle the FAST functionality directly in the SharePoint platform or was it not selling as good as they expected?

Hopefully we will find out soon as my next project coming up includes FAST. We’ll just have to wait and see.

 

We had to create a web service that needed to impersonate a user to upload some documents from a specific directory. The web service needed to upload as a specific defined user and this article was found online. The method was originally written to interact with Windows SharePoint Service 2.0 and SharePoint Portal Server 2003 but it still works perfectly against SharePoint 2010.

The page details the use of an Impersonator Class:

The Impersonator Class

There are several steps involved with performing explicit impersonation, which I have wrapped up into a class called Impersonator (download here) It appears this link is now dead. Here is an alternate link to this class: download here. The steps for impersonation are as follows:

  1. Authenticate a valid account which possesses the proper permissions to perform the necessary operations
  2. Create a new System.Security.Principal.WindowsIdentity instance that represents the account
  3. Begin impersonating the new Windows identity
  4. Perform actions that require higher permission level
  5. Stop impersonating and revert back to the client’s identity

The goal of wrapping these steps into one class is to write the following simple code to begin impersonation, execute code under the context of a different domain user account, and revert back to the original security context of the client:

Impersonator i = new Impersonator("SharePointRead", "MARINER",
"password123").Impersonate();

// Code requiring higher permissions...

i.Undo();

[see linked page for the rest of the details]

Way to revive an old thread (2006) :). I think this could come in handy for someone out there.

 Updated: Apr 2012 – link to code was dead.

 

Here is a nice article on MSDN that details end-to-end the process of branding a publishing site. Real World Branding with SharePoint 2010 Publishing Sites written by Andrew Connell and Randy Drisgill, both SharePoint MVPs.

It starts off with the starter master pages which I highly recommend: Starter Master Pages for SharePoint 2010 by Randy Drisgill

The article is a good base to start learning SharePoint 2010 branding. One thing that needs to be added to this is the removal of the ribbon from anonymous view which you can see in my article here.

Have fun branding!

 

I have just made an update to my Language Pack downloader tool on codeplex http://sp2010dl.codeplex.com to now handle SharePoint Foundation 2010 Language Packs and it’s associated Service Pack 1 update. This marks version 1.4 of the application.

Download it now on codeplex!

I will try and make another update soon to start handling the Cumulative updates in the multiple languages available. Keep an eye out for this in the near future.

Thanks!