Pages

Aug 28, 2012

Add Users and Site Permissions Error – Object reference not set to an instance of an object


While performing some testing as part of my current SharePoint 2007 migration project, I encountered the following error when accessing the Add Users link from People and Groups:
Object reference not set to an instance of an object.   at Microsoft.SharePoint.SPRoleDefinitionCollection.Init()
   at Microsoft.SharePoint.SPRoleDefinitionCollection.Undirty()
   at Microsoft.SharePoint.SPBaseCollection.System.Collections.IEnumerable.GetEnumerator()
   at Microsoft.SharePoint.ApplicationPages.AclInv.InitPage()
   at Microsoft.SharePoint.ApplicationPages.CBaseAclPage.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I also received the same error message when going to the Site Permissions page of the same site. Going to either screen in other sites in the same site collection did not have this issue so at least it wasn’t a wide spread problem.
A quick search returned this forum post of someone encountering the same issue along with some responses indicating this was a mismatch between the Roles and Groups tables in the database. I didn’t want to edit the database directly as this would take the installation into an unsupported state and was about to continue searching when I saw in the last forum response that re-inheriting the site permissions also fixed this issue.
Along with the information about there being missing information in the database led me to the conclusion that something on those two pages was missing (a user or permission group perhaps) but this hadn’t be registered in the database properly. But how can I get to the re-inherit permissions screen if I can’t get to the Site Permissions page in the first place?
I contemplated digging through the source to figure out where that menu link takes you but instead figured this might be something I could achieve with the object model and hence Powershell! Another quick search revealed that SPWeb.ResetRoleInheritance() was what I needed so I fired up Powershell to see if I could resolve the issue.
First off I need a reference to my site (or Web in proper terminology):
$site = New-Object Microsoft.SharePoint.SPSite("http://my.intranet.local/sites/subsite/")
$web = $site.OpenWeb()
Now I could just immediately call $web.ResetRoleInheritance() but I first wanted to see if I could see what permissions are currently assigned to the site so I can try and put them back to their original state once the permissions are re-inherited.
$web.Permissions | ft Member,PermissionMask
I’m using format-table (or the abbreviated ft rather) to show just the Member and PermissionMask columns in a nicely formatted table which gives me the following:
Member                       PermissionMask
------                       --------------
Intranet Owners              FullMask
Intranet Visitors            138612833
Site Owners                  FullMask
Site Members                 1011045712
Subsite Owners               FullMask
Subsite Members              1011045712
Subsite Visitors             138612833
So what permission levels do the PermissionMask values correspond to? I can presume that FullMask = Full Control and can take a guess that 138612833 corresponds to Read and 1011045712 corresponds to Contribute but it would be nice to confirm this.
I decided to get a list of the permission levels assigned to the site by doing the following:
$web.Roles | ft Name,PermissionMask
Which gave me the following:
Name                       PermissionMask
----                       --------------
Full Control               FullMask
Design                     1012866047
Manage Hierarchy           2129075183
Approve                    1011028991
Contribute                 1013125871
Read                       138612833
Restricted Read            196641
Limited Access             OpenWeb, BrowseUserInfo
View Only                  138612801
From this I can see that FullMask does indeed equate to Full Control and that 138612833 corresponds to Read as suspected, but interestingly 1011045712 does not exist at all. This confirmed my suspicion that a missing entry had caused the original fault – in this case it looks like a custom Permission Level may have been removed from the site. I would have thought SharePoint would handle this gracefully but perhaps not though I haven’t gotten around to confirming this yet.
At any rate, all that was left for me to do was re-inherit the permissions using the following:
$web.ResetRoleInheritance()
$web.Update()
Once this was done I could access both the Add User and Site Permissions screens successfully and was able to manually break the permission inheritance and reconfigure as required!

Apr 18, 2012

Sharepoint search results: document icon is not displayed

When it comes to documents icons we always have to check the ...\12\TEMPLATE\XML\DocIcon.xml. The problem was that the file had two instances of the pdf mapping key and the gif file name which is in the mapping value had a blank space in it. I deleted one instance, corrected the gif file name and performed an IISRESET. After that, the icons displayed fine.

Apr 9, 2012

Best Practices - BLOB Cache (Configuration & Type of files to Include)


In SharePoint you also have something called the BLOB Cache, which is a disk-based caching mechanism that caches resources on the disk. Normally these resources are files served by a web page and are named Binary Large OBjects (BLOB).
Normally the BLOB cache will cache files served by the web request like images and video clips.
In web.config you’ve got something similar to the following line which lets you know what file types are cached. You can of course add or remove file types here:
<BlobCache  
    location="D:BLOB" 
path=".(gif|jpg|jpeg|jpe|jfif|bmp|dib|tif|tiff|ico|png|wdp|hdp|css|js|asf|avi|flv|m4v|mov|mp3|mp4|mpeg|mpg|rm|rmvb|wma|wmv)$"
    maxSize="10" 
    enabled="false" />

Best Practices - SharePoint Anti-virus scanning exclusions!!!


Occasionally different anti-virus products can interfere with SharePoint operations. The following is a list of suggested locations to exclude from your AV scanner. Remember, this is merely a suggestion, so use at your own risk!

1.  %PROGRAM FILES%\Common Files\Microsoft Shared\web server extensions\12
2.  %WINNT%\temp
3.  %PROGRAM FILES%\Microsoft Office Server
4.  %WINNT%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
5.  Documents and Settings\All Users\Application Data\Microsoft\SharePoint\Config\     (the config cache)
6.  %WINNT%\Temp\WebTempDir
UPDATE: We've released a KB that covers this.
http://support.microsoft.com/kb/952167
But is you want to SCAN uploading and downloading of documents in SharePoint, You need to configure Antivirus in Central Administration > Operations > Security Configuration and Select Antivirus.
NOTE: You can activate Antivirus measures only after installing a compatible Antivirus scanner. In a server farm, you must install Antivirus software on every Web front-end server in the server farm.

To enable Antivirus Settings section, Select one or all of the following:
  1. Scan documents on upload.
  2. Scan documents on download.
  3. Allow users to download infected documents.
  4. Attempt to clean infected documents.
  5. In the Time out scanning after ___ seconds box, type the number of seconds to allow before timing out the scanning process.

  6. NOTE: The default time is 300 seconds, or 5 minutes. This should be enough time to allow the Antivirus processes to finish without affecting performance. The default time is recommended, but you can adjust this time if you are experiencing performance issues.
  7. In the Allow scanner to use up to ___ threads box, type the number of threads to allow the scanning process to take up.

  8. NOTE: By default, the number of threads is set to 5, which should be sufficient for even a large number of sites. The default number of threads is recommended, but you can adjust the number of threads if you are experiencing performance issues.
  9. Click OK.


    NOTE: Best Practice is to No need to scan for documents which are getting download from 
    SharePoint, but please note it totally depends upon your business need.

Best Practices - Application Pools Limitation in IIS where SharePoint is Installed!!!

For SharePoint web application content, if you have more than 10 application pools on the same server (see here: http://technet.microsoft.com/en-us/library/cc262787.aspx), you are outside support. You have a choice between sharing application pools between several web applications for performance, or having some *specific* web apps in their own pool. Each time you do this it uses more CPU and RAM resources. However, a separate app pool may make my web app less vulnerable to other web apps crashing on the same server. Generally, I only have separate application pools for web apps when I have a specific security or stability requirement; e.g. my Corporate Published Intranet web app should be separate from the My Sites and Team Sites self-service-site-provisioning ones.


The above content is according to Microsoft Recommendation.