Thursday 22 December 2011

Error opening every Document Library in a Web Application

Credit:
My esteemed colleague Andrew Haughan and I worked on this issue together I cannot take full credit for the resolution to this issue.

We have a newly created Web Application that has been configured, trying to open any document library on the site was causing the standard and very helpful "An unexpected error has occurred" SharePoint Correlation ID error message.


A visit to the ULS logs (using ULSViewer of course) uncovered the following unexpected error for that Correlation ID:

System.NullReferenceException: Object reference not set to an instance of an object.   
 at Microsoft.Office.Server.Administration.UserProfileApplicationProxy.get_ApplicationProperties()    
 at Microsoft.Office.Server.Administration.UserProfileApplicationProxy.get_PartitionIDs()    
 at Microsoft.Office.Server.Administration.UserProfileApplicationProxy.IsAvailable(SPServiceContext serviceContext)    
 at Microsoft.Office.Server.WebControls.MyLinksRibbon.get_PortalAvailable()    
 at Microsoft.Office.Server.WebControls.MyLinksRibbon.EnsureMySiteUrls()    
 at Microsoft.Office.Server.WebControls.MyLinksRibbon.get_PortalMySiteUrlAvailable()    
 at Microsoft.Office.Server.WebControls.MyLinksRibbon.OnLoad(EventArgs e)    
 at System.Web.UI.Control.LoadRecursive()    
 at System.Web.UI.Control.LoadRecursive()    
 at System.Web.UI.Control.LoadRecursive()    
 at System.Web.UI.Control.LoadRecursive()    
 at System.Web.UI.Control.LoadRecursive()    
 at System.Web.UI.Control.LoadRecursive()    
 at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


From this error message we can determine that we have an issue consuming the User Profile Service.  A simple overview of our environment is an Enterprise Services Farm running a central User Profile Service Application.  We have several farms that consume this service, to protect the innocent this Farm will be called "Farm A" and the Web Application throwing the Correlation error will be called "Web Application B":


There are many ways to start diagnosing this issue 95% of the time I have found that this issue arises due to lack of permissions of the Web Application's Application Pool identity.  The identity that runs the web application must have permissions to read from the User Profile Service Application.  This was the case in this scenario.  To check the permissions of the user profile service application:

  1. Load Central Administration on the Farm that hosts the User Profile Service Application (Enterprise Services Farm)

  2. Select Manage Service Applications under Application Management

  3. Select just to the right of the User Profile Application (do not click the actual text or it will take you to the management page)
  4. Click Permissions in the ribbon


  5. Check to ensure the Web Application Identity is not in the list
  6. Type the Web Application Identity in the people box and click Add (not OK)
  7. Select Full Control
  8. Click OK
Hopefully this will resolve your issue.  I have seen the following issues:
  • If you are publishing with Threat Management Gateway ensure that you are pointing directly to the Enterprise Services Server and not going into the TMG NIC in the DMZ.  Update your HOST file on the Web Server in Farm A to point directly to the Enterprise Services Server

Wednesday 14 December 2011

PowerShell - Where is the IntelliSense??

Don't you wish PowerShell had IntelliSense?  If you need to find out what properties or methods an Object has you can create pass the object into the Get-Member cmdlet. and it will output the details

If you need to find out how to work with a string object load a variable with a string.
$test = "Test"
$test | Get-Member

You will get the following output


Name
MemberType
Definition
Clone
Method
System.Object Clone()
CompareTo       
Method               
int CompareTo(System.Object value), i...

Contains        
Method               
bool Contains(string value)

CopyTo          
Method               
System.Void CopyTo(int sourceIndex, c...

EndsWith        
Method               
bool EndsWith(string value), bool End...


This will of course work with SharePoint objects.

Happy Scripting!!

Tuesday 13 December 2011

First Blog Post

Hi All this is my first blog post the purpose of this blog is to document the magic of SharePoint and help the community.