Monday, November 29, 2010

SharePoint 2010–App Pool Account User Rights

This is a quick one: Had a new web application in a new farm – so it was the first time the app pool identity was put to use. The app pool would not start with SQL-sounding errors like ‘Unknown SQL Exception 1346 occurred...Either a required impersonation level was not provided, or the provided impersonation level is invalid’.

So after verifying all of the usual suspects, it was determined that adding the user to the local administrators group resolved the issue. Of course that is not a good solution, so I wanted to find out what the smallest set of user rights should be for that account. In the end (and working well so far), the user is a plain-Jane domain user with these rights:

  • Log on as a batch job
  • Generate security audits
  • Impersonate a client after authentication
Tuesday, August 24, 2010

Cannot activate Document Sets feature in SharePoint 2010

A coworker attempted to activate the Document Sets feature within a SharePoint 2010 site collection. This action resulted in a blank page with the feature still inactive. Hmm… Permissions? But she is a site collection admin!

Having both site collection admin permissions and beyond, I tried it myself and got the same results. Diving into the log files (anyone else find that more informative in SP2010, or is that just me?) I found these lines:

  • Feature Activation: Activating Feature 'DocumentSet'
  • Calling 'FeatureActivated' method of SPFeatureReceiver for Feature 'DocumentSet'
  • DocumentSet FeatureActivating: start
  • DocumentSetTemplate ProvisionLists for 0x999990 on https://site : throws exception: Only a site collection administrator can add a work item.. Stacktrace:    at Microsoft.SharePoint.SPSite.AddWorkItem(Guid gWorkItemId, DateTime schdDateTime, Guid gWorkItemType, Guid gWebId, Guid gParentId, Int32 nItemId, Boolean fSetWebId, Guid gItemGuid, Guid gBatchId, Int32 nUserId, Byte[] rgbBinaryPayload, String strTextPayload, Guid gProcessingId, Boolean useExponentialRetryBackOff)     at Microsoft.SharePoint.SPSite.AddWorkItem(Guid gWorkItemId, DateTime schdDateTime, Guid gWorkItemType, Guid gWebId, Guid gParentId, Int32 nItemId, Boolean fSetWebId, Guid gItemGuid, Guid gBatchId, Int32 nUserId, Byte[] rgbBinaryPayload, String strTextPayload, Guid gProcessingId)     at Microsoft.O...   

Score one for the error handling – an error that was actually caught. But there was nothing really interesting about the information above, aside from the fact that it thought I was not a site collection admin – which I verified. Never know – someone else might have booted me from the group!

It was the next line of the log file, which continued the call stack output, that I found the answer:

  • ...ffice.DocumentManagement.DocumentSets.DocumentSetTemplate.<ProvisionLists>b__0()     at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()     at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)     at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)     at Microsoft.Office.DocumentManagement.DocumentSets.DocumentSetTemplate.ProvisionLists().


So the code that was failing was running in the context of the app pool user… interesting.


Resolution

Ensured the app pool identity account was a site collection admin. Document Sets feature then activated without a problem.

So my remaining questions are:

  1. Is it necessary to have the app pool identity be a site collection admin? Is that a best practice? Had this been a production system, I probably would have elevated to site collection admin, activated the feature, then removed the account from the site collection admin group.
  2. Why the heck is RunElevated needed in the activation code of a Site Collection feature?? Isn’t that a security risk – or at least a good extra validation that the current user has permissions to do what they are attempting to do?
Monday, June 7, 2010

SharePoint 2010 Quick Tip: Expose the Enterprise Wiki Template

Was looking to create a shiny new SP 2010 wiki site as a subsite. I could see the Enterprise Wiki template when creating a new site collection, but not when attempting to create a child site of an existing site collection. In MOSS 2007, I do not recall a situation where the “Wiki Site” template was not available, so I was surprised when I found that I was missing the option to create a new SP 2010 wiki site – aka Enterprise Wiki.

The answer is pretty easy – though may not be 100% obvious: Activate the SharePoint Server Publishing Infrastructure feature on the site collection:

image

Once that is active, when you attempt to create a new site in a site collection where the publishing infrastructure is activated, the Enterprise Wiki template will be an option.

I went back to check: Activating the publishing Infrastructure feature in MOSS 2007 is not a requirement for the Wiki Site template. With all the new bling that comes with the 2010 wiki, it is reasonable that it would have more dependencies on other SharePoint components.

Sunday, January 17, 2010

SharePoint Saturday Virginia Beach

Had a few requests for the materials from my session at SharePoint SaturdayVB: jQuery – The 16th Piece of Flair for SharePoint.

There was actually way more interest than expected – thanks to you all for the compliments. My apologies to those of you who were expecting a less technical session – somehow I got billed as a designer session. There were some benefit to designers, but when it comes down to talking about jQuery, HttpModules, and functional programming in JavaScript, I know we left some of you designers in the dust. Sorry!

I had a great time attending and presenting at the event. Always more fun than I expect it to be. Also had the chance to catch up with some old comrades, as well as meet some new people. If you end up using this stuff and/or improving it, drop me a line! You never know, I you may catch me with some motivation(aka ‘time’)  to work with you on it.

Anyways, here is the good stuff:

The presentation slides:

The code:

Tuesday, October 13, 2009

SysFader Hater

I recently encountered the SysFader error within Internet Explorer 8 on Windows 2k3 R2.

This initially worried me because it was within a page I had built that contained some jQuery animation. It turned out it was not just my page though – at least MSN, Amazon, and MajorGeeks caused the same error to appear. That seemed like a decent enough variety to assume it was not just my page.

There are some good posts about the SysFader error out there:

This error seems to have been around for a while – third link above is a thread that spans nearly 2 years.

I tried some of the proposed ‘fixes’ out there – with no success. I admittedly did not try that hard on the ones that had me turning off animation effects and 3rd party browser extensions within IE – since 1) I like me some animations & extensions and 2) The animation effects have been working fine for years, why would I suddenly need to turn them off? (No, I don’t fear change at all…)

There is even a post that points the blame at poor innocent MOSS: http://biztalkdev.com/blogs/paulwu/archive/2007/03/09/IE7-Crash-when-accessing-MOSS-2007.aspx This was interesting because the page that initially threw the error at me was MOSS-based. I also DID NOT attempt to disable the OWSSUPP.DLL ActiveX control since it had been working well for a while and as I mentioned earlier, I was seeing the error from other sites that were definitely not MOSS-based.

Even tried reboot – no dice. Scary because that was the second time in the past month that reboot has failed me!

So how I fixed it: Actually, it was pretty easy. I reinstalled Adobe Flash 10. Not sure what the minor version that I had was, but I had updated Flash recently on the affected machine and it was version 10 – so I may have reinstalled the current version – or at most it was a minor version update. Either way, the net effect of reinstalling flash and restarting IE was that the Sysfader error was a nothing but (a) bad memory.

Later SysFader!

Friday, October 9, 2009

Web Parts Down: A SharePoint Tragedy

Prologue:

There are times when I am a click or two away from registering some derivative of IHateSharePoint.com or SharePointIsKillingMe.com or WasSaneBeforeSharePoint.com. I was VERY close after encountering the following problem…

 

Act I Scene I

I had been through the Code – Build – Debug cycle with this particular feature numerous times (especially the Debug step). Suddenly one of the builds resulted in the informative web part error:

Web Part Error: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.

…which I have seen before – but usually only when the web part is first deployed. 99% of the time this error is caused by the entry for your web part in the SafeControls section of the web.config file. It usually boils down to something like a spelling error, the namespace, assembly version, etc.

ACT I Scene II

Remove the code I just added. No dice – same issue.

ACT I Scene III

IISRESET. Strike two – same issue.

ACT I Scene IV

Remove code I added several builds previous. Same issue.

ACT I Scene V

Re-add the feature and web part to the page. Adding web part fails. Interesting. Upon navigation to home page, notice that ALL web parts are showing errors – even the out of the box ones. Also interesting in a ‘just what I needed’ sort of way.

 wp_error2

Intermission

Magic reboot. Same issue. Strange, because magic reboots rarely fail to resolve issues.

 

ACT II SCENE I

Hit up the internet to see what he knows. Typical stuff: make sure there is a SafeControls entry, make sure it is right, etc. etc. Found some good posts about what to check. Here are a few of them:

Check on all of it for me though – double checked in fact. Re-add assemblies to GAC just in case. Same issue.

ACT II SCENE II

Restore a web.config from previous day. SAME ISSUE.

Act II Scene III

Crank up ULS logging level to the deepest depths of verbosity – you know, the ‘disk filler and killer’ levels. But they gave me no additional information – showed me the same as what is rendered within page…

Act II Scene IV

Restore web.config from previous month. All web parts back up except the one I had been working on, which did not exist a month earlier.

Epilogue

So it was web.config related, and also probably an issue with my custom web part. After some experimentation, it turned out to be the entry in the SafeControls section. But not because it was invalid – remember I checked that in act 2 scene 1 – it was because the assembly could not be loaded because one of its dependencies could not be found. Why could it not be found? It was not in app’s bin folder or in GAC. Easy enough to fix once I finally found the real problem. My questions are:

> Why did this not show up as an error somewhere? I could have solved it within minutes rather than burning an entire afternoon.

> Why did this kill ALL SafeControls in the SafeControls section of the web.config, and not just the ones within the problematic entry? If there is a problem with a SafeControl node, the typical behavior is that it only affects anything in that namespace, not every SafeControl node.

 

Pray for no sequel!

Tuesday, September 1, 2009

Web Part wrapper for the Google Dynamic Feed Control

If this is out there, 2 minutes of searching couldn’t find it. Interesting little exercise even if it is out there.

The out of the box SharePoint 2007 RSS Viewer web part is pretty lame. It is pretty much the Xml Web part with 300+ lines of ready made XSL. This might just be my opinion, but XSL is only really interesting the first time you do something with it. After that, you can have it back – especially when it comes to debugging it.

So I was looking around for a pinch hitter for the out of the box RSS web part and came across the Google Dynamic Feed Control. This is what it looks like in vertical mode with the default CSS applied:

dynamicfeed

Works well. Looks good enough. Free. What more could one ask for? How about the following advantages over the RSS Viewer web part:

  • Can consume both RSS and Atom feeds.
  • SSL Friendly – can consume an HTTP feed from an HTTPS site without the annoying security warning dialog. This is actually a pretty important advantage if you are within an SSL site.
  • Aggregation – it can handle more than one feed.
  • Built in AJAX updates. Side bonus: It won’t cause script errors – specifically the infamous ASP.NET pendingCallbacks bug – if there is more than one instance on a page.
  • Superior UI and use of screen real estate.
  • Does not require XSL manipulation to change.
  • No half-baked loading bar graphic. Where did that thing come from anyways? If it played the Knight Rider theme while it loaded or a KITT sound effect, it would possibly have some value.

CRPERSPC

This javascript control is built on the Google Feeds API, and as with all of Google’s ‘free’ stuff, the integration point for this is within the client tier via javascript. This will make it easier for Google to steal your customers in the future. I like to joke around – but unfortunately that was not a joke. Having their API’s all javascript – and therefore in almost all cases from the client tier – is a brilliant move. But only for them – and maybe the rest of us who take advantage of their price points in the short term.

OK – digression phase complete. I set out to create a web part wrapper to make the incorporation of this control into a SharePoint site easer. The web part essentially generates the javascript required to initialize and render the control using the Google API.

Web Part Construction

Within the web part, there are essentially three main pieces:

  1. Create personalizable properties that allow the web part to be customized.
  2. Get the Google Ajax API and the Dynamic Feed Control scripts into the page.
  3. Render the client script that loads the control based on the configured properties and the containing HTML element (just a DIV).

Step 1: This is pretty standard web part stuff. Some of the customizable properties I created:

  • FeedURL – Allows the specification of an RSS/Atom feed. This can be a semicolon delimited list to show multiple feeds. I know - a crude way to do it – but we can save the custom editor for a rainy day.
  • PageSize – How many records to show.
  • DisplayTime – How many seconds to show the details of an item before moving on to the next one. The Dynamic Feed Control continuously cycles through the items in the list and displays the details of one item at a time.
  • CssUrl – the url of the stylesheet containing the classes used in the markup. The schema for the CSS is outlined here.

Step 2: The core Google javascript does not do well if it is not loaded into the page before content – or more importantly other scripts – are rendered. In other words, it needs to be in the HEAD section. This means that the normal means of doing this – using the regular Page.ClientScript.RegisterClientScriptBlock method – will not be good enough, since that loads scripts into the BODY section. One way to get script into the HEAD section is to add to the Page.Head.Controls collection. So here is the code to register the Google JSAPI core – and the Dynamic Feed Control:



Code Snippet



  1. protected virtual void RegisterScripts()
  2. {
  3. if (CanRender)
  4. {
  5. //add scripts to header - the registered block is used just as indication that we already
  6. // added the script to the page
  7. //google jsapi script does not do well if it is not already loaded into head section
  8. if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), GoogleAjaxKey))
  9. {
  10. Page.ClientScript.RegisterClientScriptBlock(
  11. this.GetType(),
  12. GoogleAjaxKey,
  13. string.Empty);
  14. Page.Header.Controls.Add(new LiteralControl(string.Format(ScriptLinkTemplate,
  15. string.Format(GoogleAjaxUrl,
  16. HttpContext.Current.Request.Url.Scheme,
  17. string.IsNullOrEmpty(ApiKey)
  18. ? string.Empty
  19. : string.Format("?key={0}", ApiKey)))));
  20. }
  21. if (!Page.ClientScript.IsClientScriptBlockRegistered(this.GetType(), GoogleDynamicFeedKey))
  22. {
  23. Page.ClientScript.RegisterClientScriptBlock(
  24. this.GetType(),
  25. GoogleDynamicFeedKey,
  26. string.Empty);
  27. Page.Header.Controls.Add(new LiteralControl(string.Format(ScriptLinkTemplate,
  28. string.Format(GoogleDynamicFeedUrl,
  29. HttpContext.Current.Request.Url.Scheme))));
  30. }
  31. }
  32. \




Step 3: Rendering the script is just string manipulation. It is possible to get really fancy when building javascript dynamically within C#, but sometimes you can’t beat a good old fashioned StringBuilder. The most important thing to get right is the order – you do not want something to reference script that has not loaded yet or an object that has not yet been defined. So the general order here will be:

Body Load > Google Feeds Load > Dynamic Feed Control Load

which translates to (all javascript):

_spBodyOnLoadFunctionNames this allows us to add a function to be called when the SharePoint-rendered DOM is loaded

google.load('feeds'…) this loads the Google feeds api – used by the dynamic feed control

new GFdynamicFeedControl() creates the javascript object – it will do the rest

The rest of it is the dynamic generation of the options objects based on the configured property values (remember step 1?) Here is what I mean – actually pretty simple:



Code Snippet



  1. protected virtual string BuildFeedOptionsScript()
  2. {
  3. StringBuilder script = new StringBuilder();
  4. script.Append("var options = {");
  5. script.Append("stacked : true, ");
  6. script.Append("horizontal : false, ");
  7. script.AppendFormat("numResults : {0}, ",
  8. PageSize);
  9. script.AppendFormat("displaytime: {0}, ",
  10. DisplayTime * 1000);
  11. script.Append("fadeOutTime : 1000, ");
  12. script.Append("scrollOnFadeOut : true, ");
  13. script.AppendFormat("title : \"{0}\"",
  14. Page.Server.HtmlEncode(this.Title));
  15. script.Append("};");
  16. return script.ToString();
  17. \




That is pretty much the bulk of it. In the end you have yourself an RSS (and Atom) consuming web part that is superior to what you get out of the box.

The Visual Studio 2008 solution uses takes advantage of feature based web part deployment and uses STSDev2008 (you will need to install it if you want to build).

VS2008 Solution:

Just the WSP
 
© I caught you a delicious bass.
Back to top