All posts in SharePoint 2013

SharePoint Best Practices – Site Columns

So today I am starting a new series on SharePoint Best Practices.  This may seem like a fairly simple topic but, I have come to learn that it is an important one.  I am not talking about best practices in setting up and configuring SharePoint or how to best develop a solution in SharePoint.  I am instead wanting to discuss best practices in your day to day usage of SharePoint.  Too many times I have worked with experienced clients that have a decent knowledge of how to do things in SharePoint, but don’t think of the little things that make these best practices.  This is where this series is coming from.  Today I am going to cover site columns.

Read more

Manipulating REST API Calls in SharePoint Designer 2013 Workflows

In my previous post on the different ways to determine the return message from a REST API call in a SPD workflow I covered using a test list and Fiddler to build your web call in a SharePoint Designer workflow.  In this post I want to discuss manipulating REST API calls in SharePoint Designer 2013 workflows.  Basically I want to show how you can determine what your read string is going to look like based on the values coming back from SharePoint.

Read more

Handling REST Responses in SharePoint Designer Workflows – Reading The Response

Years ago when Microsoft released it’s latest version of SharePoint Designer, it came with a few enhancements that really made building workflows with Designer more robust and efficient.  One efficiency enhancement was the ability to copy actions, steps and even entire stages within the same workflow or even between workflows.  Microsoft also allowed for the ability to move back and forth between stages instead of continuing down a parallel path (called a state machine workflow).  While the addition of state machine workflows to Designer (previously only available in Visual Studio workflows) is great; in my opinion the best (by a very small margin) addition to Designer is the ability to call web services.  As your queries get more and more complex however, knowing what is coming back into the workflow can be filled with frustration as you try to determine how to get the data from the response content.  While I it isn’t a new concept, I wanted to discuss handling REST responses in SharePoint Designer workflows.  Or at least how I do it.  The method I use is pretty straight forward and very easy to implement.

Read more

Waiting in a SharePoint Designer 2013 Workflow

All too often when building workflows in SharePoint Designer there is a need to pause the workflow for a duration of time, or while waiting for values to change within SharePoint list\library.  Microsoft has provided methods or actions within a workflow to accommodate this for quite some time.  The method to accomplish while similar between versions has changed with the latest iteration of SharePoint Designer.  For this reason I wanted to discuss waiting in a SharePoint Designer 2013 workflow today.  I know that most are now moving to SharePoint 2016 or SharePoint online, but while Microsoft has released newer versions of SharePoint, it hasn’t released a new version of Designer since 2013.  So whether you are on SharePoint 2013 or a later version, this post is relevant for the foreseeable future.

Read more

SharePoint Custom Solution Crashes IIS Worker Process (w3wp.exe) – Part 2

In Part 1 of this series, I discussed an issue we were having in one of our SharePoint 2013 farms and how I determined the issue was occurring because of a set of event receivers acting on the library.  In this post, I will discuss the code being used and what the final result was determined to be.  Stick around, it’s not what you think.

To be terribly honest nothing jumped out at me while looking over the code.  The initial review of the code indicated the issue could be around where the event receiver was trying to determine if the user adding the file was a member of the site owner group.  The original code was:

This seems pretty straight forward, but when “CheckIfUserInSPGroup” is called things aren’t quite as kosher.

Again, normally not a huge issue, except that best practices state that you shouldn’t instantiate SPSite, SPWeb or SPList objects within an Event Receiver.  The reason for this is it causes extra database calls (more information here: https://msdn.microsoft.com/en-us/library/office/ee724407(v=office.14).aspx).  I thought this could be the culprit, but wasn’t convinced.  If this was the issue, why does it work fine for years and then suddenly stop working?  The reason the code is instantiating the SPSite and SPWeb object is it is used elsewhere in the solution and could be called by users who do not have the required access.  The same goes for the event receiver.  If I do not have access to control security groups in the site, I get an UnauthorizedAccessException.

So I thought, why not just use that.  We can safely assume that if the UnauthorizedAccessException error is thrown, the user is not in the Owners group.  So I updated the code with a try\catch (why one wasn’t already being used I don’t know) and added some logic into the catch.  Not generally the best method, but when used for targeted exceptions I believe acceptable IMHO.

I also created a new method for the event receiver to call.  I couldn’t modify the existing one, as it contained valid logic to handle users without access and was being used elsewhere.

So I moved the code into Pre-Prod and tried it out.  No change.  Still hanging, throwing errors and crashing the app pool.

Next step was to install Visual Studio into Pre-Prod and attach to the IIS Worker process.  I followed the code until it got into the newly created CheckIfUserInSPGroupEvntRcvr method.  There it stayed.  It kept looping through the AD users and groups within the SharePoint group.  As it was looping I watched the worker process memory usage grow and grow until it finally crashed again.  This didn’t make any sense as there are NOT that many users in these groups.

The Cause of it All

I took a look at the ownership group for the site I was testing with.  Like most (not all) of our project sites, it contained an AD group that contains our project team.  Let’s call that group All-Project.  All-Project had about a dozen users within it, however, there was an anomaly.  It also contained the Owners group from another project site.  This was an oddity.  I took a look at the Owner group and it also contained the same All-Project group. There was the culprit.

As you can see in the code above, it is designed for nested groups, so if the code hits a group it digs down to see if the nested group contains the user.  Because this Owner group was added (in error I found out while trying to figure out why it was there) to the All-Projects group, the code would dig into All-Projects then to the Owners group, from there back into the All-Projects group and then back into the Owners group… see where I am going with this?  By adding that single group to the All-Projects group in error an infinite recursion loop was created in the code.

The Final Fix

So the final fix was not an environmental change or a code modification.  It was simply to remove the Owners group from the All-Projects group.  Once that was done, the original code functioned as designed.  If this becomes a regular occurrence I will have to update the code to handle such an event, but in this case, I didn’t.  The farm is in containment (no further development short of break\fix) and the issue has not occurred for two years before this.  I hope the steps I documented in this blog series helps others out.

 

Thanks for reading!