Saturday, April 13, 2013

How to avoid the fatidic UnauthorizedAccessException (0×80070005)

Recently I came across a series of issues when a client I had worked with changed their security matrix.

I had a webpart that applied a CAML query on a list to retrieve data and then present it. The problem I was having, when the customer changed their security matrix, was that some users no longer had permissions to retrieve the list where the data was being stored.
(...)

Friday, April 12, 2013

How to disable Search to index content inside documents

Have you ever had a requirement from a client to customize SharePoint Search, to disallow users from querying for any content inside documents?
I had this request recently, and it was a while until I found solution for it..

To accomplish this, I had to remove some internal Crawled properties from the Search Service Application.
(...)

Thursday, April 4, 2013

Restore site or list from backup without attaching database

A great improvement to Restore/Backups was made to SharePoint 2010. In MOSS2007 the restore/backup functionality was restricted to Farm, Web Applications and Content Databases.

In the 2010 version, using just the OOTB options, we can be as granular as choosing an individual list. This greatly improves the flexibility of this functionality. Not surprisingly, the feature is called Granular Backup.
(...)

Tuesday, March 26, 2013

Welcome João!

It is with the utmost pleasure that I announce the new member of Get-SP.com...João Lopes!

I've been working with João for the last year and a half. He's one of the best developers I've had the chance of working with, so having him on board is great!

One of the things I like the most about him is his dedication towards developing solutions using the best practices.
(...)

Sunday, March 24, 2013

Renewed focus, new domain, new image!

I've been very quiet in the last few months, in the blog and also in the MSDN/TechNet forums.

The main reason was, when I returned from my Summer vacations (to see how long ago it was!), I felt like I needed the blog, and my "community" efforts, to be re-focused.

After some ups and downs, I believe I've reached a good place.
(...)

Wednesday, June 20, 2012

April 2012 CU is back!


The April 2012 CU is now available again from Microsoft: http://support.microsoft.com/kb/2598151.

Their reason for the recall that happened about a month ago:
“A recent, isolated issue was discovered in the SharePoint 2010 Products April 2012 Cumulative Update that could result in an HTTP 500 error when users delete objects to include documents, lists, and Webs and a new  object is created using the same path where the original object remains in the Recycle Bin. […]This issue has been resolved in the revised packages.”

Friday, May 25, 2012

ULS Viewer real-time feeds NOT working

I've had this issue in the Development VM I'm using, where ULS Viewer would never load the logs in real-time from the LOGS folder.

I ended up finding the issue, or at least a solution for my case, in some comments on the Microsoft tool page (here), which was deleting all the old log files. The current one will be in use and won't be deleted, which is fine.

Another workaround was deleting the upgrade*.log files only, but I didn't have any, so the problem was probably in another log file. It seems that if the logs that don't follow the  formatting ULS Viewer expects, RT feeds won't work correctly.

Saturday, May 12, 2012

Regain control of SQL Server

I started using a VM from a template someone else built in the last couple of days. My account was a local machine admin, but not a SQL Server admin. I actually had no access configured in SQL Server for my account. But I needed to get control over it and had no one available to help me in that moment.

In order to get sysadmin permissions on SQL Server, I did this:
  1. Shut down SQL Server Services
  2. Open a command line as Administrator
  3. Change to you SQL Server Binn dir
    • cd "c:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn"
  4. Run SQL Server in single-user mode
    • sqlservr.exe -m -s MSSQLSERVER
  5. Open a new command line as Administrator
  6. Connect to SQL Server
    • sqlcmd -S .\ (or sqlcmd -S .\MSSQLSERVER)
  7.  Execute commands
    • 1> sp_addsrvrolemember 'domain\user', 'sysadmin'
    • 2> GO
  8. CTRL+C in both windows to exit sessions
  9. Restart SQL Server Services 
  10.  
    PS: You may need to be quick connecting to SQL (step 6) after starting it in single-user mode (step 4), otherwise some other process may pick up the session (remember, obviously, only one connection will be allowed...we're running in single-user mode!). Not a bad idea to have both command line windows open and ready to click Enter.

Tuesday, May 1, 2012

Unreliable Item Count in Search Scopes

Beware with the Item Count column present in Central Administration, in the Search Scope Properties and Rules interface, as it may not be accurate.

It does state it is "approximate", but what does it mean?

What happens is it queries the Search Service to get this Item Count, using the current logged on account (in Central Admin) which may or may not have permissions to see all the results. So the Item Count retrieved is actually the one pertaining the current logged user viewing this page, and not a global result.

This will be an issue in highly security trimmed contexts, where there is probably no account with access to the entire index (except for the crawler account). Therefore, the Item Count will be pretty much useless.

This design flaw in the Central Administration seems to be present since MOSS2007, as it can be seen here.

Wednesday, April 25, 2012

Run Away from Item Level Security!

I have been involved in some discussions regarding Item Level Security and its impact on the performance of a SharePoint farm. Interesting topic. Microsoft has a thorough article on this, download it here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=9030.

Here is the what Microsoft has to say about it, from a boundaries/limits perspective (also here):


"Security scope - 1,000 per list - Threshold
The maximum number of unique security scopes set for a list should not exceed 1,000.
A scope is the security boundary for a securable object and any of its children that do not have a separate security boundary defined. A scope contains an Access Control List (ACL), but unlike NTFS ACLs, a scope can include security principals that are specific to SharePoint Server. The members of an ACL for a scope can include Windows users, user accounts other than Windows users (such as forms-based accounts), Active Directory groups, or SharePoint groups."


This means that if you believe your list will have more than a thousand items, now or in the future, Item Level Security is not recommended. Beware that once you follow that path, it will be tough to re-design your solution.
Also, a major pain point is governance. How manageable is a solution with Item Level Security? Not much.
You would need some automation: probably workflows/event receivers and some custom coded framework to help power users managing security. This means more complexity, and we still have the threshold to handle.

An important factor on this threshold is that having more than 1,000 ACL's in a list/library impacts the whole farm, not just that list (check a very interesting post about this here).

All in all, my opinion on this topic is that you should run away from Item Level Security as much as you can.
Design the Information Architecture in a way that allows you to set the security boundaries only in site collections, sites and lists/libraries. It will make everyone's lives easier. My motto has always been the simpler, the better. Over-engineering is certainly one of the most common problems a team with good developers/consultants can get.

But, if you still need some sort of Item Level Security, there are other paths you can take. I see 3 possibilities.

First option: Folder Level Security

The way folders work has been enhanced in SharePoint 2010, with things like default metadata values based on folders. It was an improvement that allowed folders to be back on the game, in my opinion.
In terms of security boundaries, it may be a perfect fit. If, inside a library, you have a reasonable amount of separate security boundaries, you may use folders to manage the security. This away, the amount of ACL's in the list would be restricted to the number of folders.
You could make it transparent to the end user, from a viewing perspective, by not using folders on views. From an upload perspective, the end user would learn that when uploading a document, choosing a folder would actually mean choosing a security boundary. Since most users do have a file share background, most will easily understand and accept that putting documents into different folders, will mean those documents  are visible to different users.

Second option: Custom components

Another option is making the list and all items super-secure, with all items inheriting security. Only super-user accounts would have read/write access. All others users would have no permissions.
We would then build custom components to view, upload and edit documents/metadata, that would be run using elevated privileges and would have its own logic.
This is not a trivial solution, there are several limitations, as well as a lot of custom development. Think about what would happen trying to save a document from the Word client, or using Explorer View. This would need to be carefully PoC'ed, planed, agreed with the customer, implemented and tested. It would largely depend on the specific requirements. My advice would be against this path.

Third option: Folder Based and Exception Based Security

A third option I can envisage is more complex. We can have a mixture of Folder Level Security with a number of exceptional behaviours. This can be used in more complex scenarios, but it always falls into the assumption that from a business perspective it is imperative to have all these documents in the same location and that having a predefined number of folders with their security and a restricted set of unique permissions on some of the documents, would solve the problem. We would need some sort of mechanism to monitor the number of exceptions + folders, to keep it within a reasonable amount. Again, my advice would be against this path.

Important factors to consider

The most important thing to have in mind is whether you are able to re-engineer or re-design your customer's process or what they believe should be implemented, in terms of security.
Sometimes, business users mistake visibility with security. Or some sort of responsibility with security. It is important to make concepts clear to them. Security could be seen as a block. Are we setting security only because we want to control what end users see by default? Or do we really need these documents blocked to these end users? I have seen a lot of cases when it is the first option. If that's the case, you can forget security and use other alternatives, like customized views based on metadata or even custom coded components for viewing. It will be much easier, cleaner and manageable to code viewing components based on any sort of logic, than pursuing a solution where you use Item Level Security.
If you do have security boundaries to respect, and these documents must be blocked, then the first option is a clear winner. It might be tough to convince your customer, but the "Software boundaries and limits" page from Microsoft is there to help you. And if they end up choosing to pursue other strategies, you have clearly made your point here, if they have problems in the future.