Item Level Security in WSS Custom Lists 

Tags:

WSS v3 has very powerful item level security features that were completely non-existent in previous versions of SharePoint.  This wiki discusses how to take advantage of those features for custom lists.
 
There are several ways to implement item-level security depending on your needs:
  • Manual Item Security - simple, but cumbersome
  • Manual Folder Security - easy with some flexibility, but requires some maintenance
  • Item Owner Security - easy and low maintenance, but limited
  • Programmatic Security - completely flexible, but requires developer implementation and testing

Ideally we would be able to add one more item to the list above for modifying permissions through SharePoint Designer workflows, but the out of the box activities with SPD workflows do not currently have this capability.

A last option not mentioned above is separating your data out into multiple lists and then just managing the permissions on the lists instead of managing item level permissions.

Manual Item Security

This solution is good if you don't need to manage permissions on very many items and you need some flexibility in how they are managed.

This is simply the act of managing the permissions on an individual list item.  This must be done by an individual who has Full Control permission for the list.  This is cumbersome because it must be done manually for each and every item in the list.  One could set up alerts to know when an item is added or updated, then go in and modify the permissions, but this would be very cumbersome if it was needed on many items.

Manual Folder Security

This solution is good if you don't need to manage permissions for large number of folders, but you need to provide flexibility where subsets of individuals need access to certain items.  This works well in the scenario where managers need access to their direct reports, but not those of other managers.  It can even go multiple levels with regional managers, etc.  This breaks down the quickest if folders are being added regularly that need permissions set on them.

This is simply the act of managing permissions on folders within a list.  The list must first be set to allow for folders to be created from within the advanced settings of the custom list (Settings->List Settings->Advanced Settings).

New Folder

As folders are created you can click on drop down to the right of the folder and choose Manage Permissions to grant or deny permissions to other individuals/groups.  You must have full control to be able to manage permissions and you must have designer permissions to be able to add folders.

The nice part about this approach is that you can show the list as a hierarchical list with folders or you can show it as a flat list without folders.  In either case, you only see what you are allowed to see.  The hierarchical vs. flat setting is done within each view.

Folder View

Item Owner Security

This solution is good if your requirements are such that individuals can only see (or edit) only the items they created or if they can see/edit all items.  It does not work well if individuals need to view/edit entries they did not create such as a manager seeing their direct reports' entries, but not other managers' entries.

By default, contributors and readers for a list have access to all items within the list.  However, within the advanced settings of a custom list (Settings->List Settings->Advanced Settings) you can specify that users can read "All items" (the default) or "Only their own".  In addition, you can specify that users can edit "All items" (the default), "Only their own", or "None".  These settings apply to individuals with contributor or reader permission for the list.   Users with designer or full control will be able to read and edit all items regardless of these settings.

Item Level Permissions

You can change these settings at any time and the behavior works as expected.  When adding this restriction to a list with existing data the behavior is based on who it is Created By, not by whom it is last Modified By.

Some caveats with this approach:

  • Either you see or can edit all items or only the items you created.  There is no middle ground.
  • For users that need to see and/or edit all items, they must be given designer or full control permissions.  This means that they can change the list settings such as columns, etc.
  • Coupling this approach with folders (described above) is not recommended because it has some strange side effects:
    • As a list designer or individual with full control, you can create a folder at the root level then give designer or full control permissions of that folder to a list contributor (or reader).  However, the recipient of this permission will not be able to see the folder.
      • If you provide the link to the folder, the recipient can access it to see the contents as well as create sub-folders.
      • This issue can be avoided if you use a view that does not show folders, but this might negate the benefits of using folders in the first place.
    • Even if an individual has full control on a sub-folder, they cannot manage permissions on a folder or item within that sub-folder unless they have full control on the list itself.  The "Manage Permissions" item shows in the drop-down on the title, but give you an error when you try to access it.  This is likely a bug.

Programmatic Security

The SharePoint object model allows you to programmatically update the security on a list item.  There are several scenarios that this could cover, but I will demonstrate one example below.  See the references further below for examples from others.

In this example I have a people picker field ("Technician") that can be set by contributors on the list.  When this is set, the specified technician is given contributor access to the list item, but previously did not have access to the list item.  Basically technicians do not have reader permissions on the list, but are programmatically given access to specific items.  This code is initiated through an ItemUpdated event (see SharePoint Events for more details).

        public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);
            this.SetTechnicianSecurity(properties);
        }

        public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);
            this.SetTechnicianSecurity(properties);
        }

        private void SetTechnicianSecurity(SPItemEventProperties properties)
        {
            // Get the list item from the event
            SPListItem item = properties.ListItem;

            // Get the SPUser object from the Technician field
            string lookupUser = item["Technician"] as string;
            SPUser user = null;
            if (lookupUser != null && lookupUser.Length > 0)
            {
                int userId = ItemHelpers.GetLookupID(lookupUser);
                user = item.Web.SiteUsers.GetByID(userId);
            }

            if (user != null)
            {
                // Create a role assignment for our user and give it contributor bindings
                SPRoleAssignment roleAssignment = new SPRoleAssignment(user);
                roleAssignment.RoleDefinitionBindings.Add(item.Web.RoleDefinitions.GetByType(SPRoleType.Contributor));

                // If we are currently inheriting our security, we need to break this inheritance
                if (!item.HasUniqueRoleAssignments)
                {
                    item.BreakRoleInheritance(true);
                }

                // Add the role assignment to our list item
                item.RoleAssignments.Add(roleAssignment);
            }
        }

To get an Id from a lookup field, you might want to use some helper code (see below).  Note that what is stored in the lookup is different if you are using an item from an event or AfterProperties from an event.  The two helpers below are used depending on the situation.

    public class ItemHelpers
    {
        public static Int32 GetLookupID(string lookupValue)
        {
            int index = lookupValue.IndexOf(';');
            int id = Int32.Parse(lookupValue.Substring(0, index));
            return id;
        }

        public static String GetLookupValue(string lookupValue)
        {
            int index = lookupValue.IndexOf(";#");
            String val = lookupValue.Substring(index + 2, lookupValue.Length - (index + 2));
            return val;
        }
    }

Some notes on the code provided:

  • The code above is just an example with error handling, constants, and other good practices removed to make the example smaller.
  • You can lookup existing users via Web.SiteUsers, but there are other types of user collections as well (Web.AllUsers, Web.Users, Web.SiteUserInfoList).  If you are trying to find a user that is already set from a people picker use SiteUsers or SiteUserInfoList.
  • The Web.SiteUsers collection and the Web.SiteUserInfoList come from the UserInfo table in the database WSS v3 database.  The drop-down on any people pickers for a datasheet view appears to read from here.
  • If you want to run this code from an Updating event, be careful because the user may not already be in the SiteUsers collection.
    • A user is placed in SiteUsers the first time that user is put in a people picker anywhere in the site collection.  This includes using a people picker when editing a list item, but also includes using a people picker to give permissions to a site or list.  Note that it does not include using a people picker to give permission to a group that the individual is in.
    • During an Updating event, the picked user has not been committed yet so if this is the first time the user is entered, it will not be found in SiteUsers.  This is not a problem with asynchronous events such as Added and Updated.

Other Item Level Security Notes

  • If a list has a lookup to another list, the lookup value will not be seen by those who do not have access to the other list.
    • For example, if a Product list has an OrderNumber that is a lookup to an Order list and the user has access to Product, but not Order, the following will occur.  The user will not see any OrderNumber values in their Product list.  If they edit the item, the drop down for OrderNumber will be empty.  If they save this edited item, the OrderNumber field will now be blank.  This is allowed even if the field is required (a flaw, in my opinion).
  • Editing permissions on a list item does not change the modified date for the list item.
  • Users with Full Control appear to have the ability to manage permissions within the list while users with Design rights cannot.  This appears to be the only difference between these two permissions.
  • You can have limited access to a list if you do not have reader access to the list, but have rights on at least one item.
    • If you have limited access to a list, you cannot see the view drop down, but you go to the default view for it when trying to access the list.  You can go to the views if you know the link (you just don't see the views listed in the drop down).

References

 
Posted by Kirk Liemohn on 22-Mar-07
9 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
 

Links to this post

Comments


Ken Liesegang commented on Wednesday, 23-Jul-2008
Nice article! You reference that the aritcle does not address the need for a "manager seeing their direct reports entries, but not other managers entries" That is precicely what I need. Can you point me to a solution for that problem? Thanks in advance.


Kirk Liemohn commented on Wednesday, 23-Jul-2008
Ken, the only way I know of handling this without a special event or workflow is to set up a folder in the list for each individual (e.g., the name of the folder is the name of the individual) and set permissions on the folder such that only that individual and their manager can see the folder. The items within the folder will inherit the folder's permissions.


asd commented on Wednesday, 12-Nov-2008
2GB MP3 PLAYER "In addition to providing . 4GB MP3 PLAYER my own WoW Leveling Guide to help you maximize your. buy wow gold WoW enjoyment I’ll discuss . buying gold world of warcraft other great WoW leveling guides available to you along with. cell phones the problems and benefits of power leveling . cheap cell phones guides and power leveling services. cheap wow gold I may also poke a little fun at the . cheap wow gold WoW forum communities. cheap wow gold for their uncanny persistence . cheapest wow gold so you’ll eventually find both a horde .eve isk One important note about my approach . mp3 players I strictly avoid and discourage cheats and hacks. phones cell and I also strongly discourage paying for leveling services. portable mp3 player This game is meant to be played; it is meant to be FUN. portable mp3 players your money or making yourself feel lame for cheating. sell wow gold Joana’s Horde Leveling Guide and Brian Kopp’s Alliance Leveling Guide. world of warcraft gold give you some extra tips to help you maximize their usage. wow value than any power leveling service or cheat. wow gold you can use them over-and-over for the rest of your life. wow gold And they don’t teach methods that will either get you banned or make you feel lame. wow gold that one might argue you’re already at a disadvantage for not yet using them. wow gold it so boring and tedious that it ruined the game for you. wow gold This is what I want to avoid. wow gold I do encourage some aggressive and creative methods because . wow gold kaufen help you learn methods you could already learn from .wow gold kaufen If you have played World . mp3playershopping.de/Shops/8GB-MP3-Player.aspx">8GB MP3 PLAYER of Warcraft for any amount of time. you will be able to relate to what I'm about to share with you. apple ipodFor the first time ever. buy cheap wow gold my self-used secrets of the power of leveling. which I have used to. canon digital camera count the ones I helped with. cheap world of warcraft gold friends. WARNING This. digital cameraof the way I learned how to level.digital cameras I wanted in World of Warcraft. dvd player Not only that. eve isk leveling speed to. below 6 days /played! We are only . ipod at the beginning of this letter. ipod nano If I were you.ipod shuffle And you are completely right to.ipod touch Look, if I wasn't the guy who used.ipods and seen the process with my own two eyes. mp3 player So let me set the record straight by pulling back . mp3 players mp4 I know you've heard people talk about ""competitive gamers"" before, you know. portable dvd players no life, and they Eat. Sleep and Breath gaming. world of warcraft buy gold So right now. wow I'm going to set the records straight and let you . wow gold I started playing. wow gold Completely blind to any concept of the game. wow leveling This is before The Burning Crusade. wow powerleveling Unfortunately I made that character before I found out. zubehoer mp3 player They talked me into switching servers and playing with them. survived the horrific explosion rallied. buy cheap wow gold landmass in sight. Cheapest wow gold Somehow. by the grace of Elune. des po wow fellow survivors and establish. digital audio mp3 player they surveyed the . wreckage of their. digital mp3 player ripped from the world by the Well's destruction. free online games Malfurion and his companions were left to ponder . free online war games of the new land along with. gold wow he was satisfied that they could cause . gold wow elves landed upon the shores of the new land. lord of the rings online gold Seeking to establish a . lotro gold new home for themselves. mp3 player nestled between the mountain's enormous peaks. online games they found a small. tranquil lake. play war games Sundering as well. po wow and the night elves. wow europe precious waters from the Well of Eternity. wow fr energies quickly ignited and coalesced. wow geld was shocked when Malfurion hunted him down. wow gold Illidan refused to relinquish his magical powers. wow gold cheap With Cenarius' help. wow gold cheapest where he would remain chained and. wow gold verkaufen Maiev Shadowsong, to be Illidan's personal jailor. wow golds Well might bring about an . wow level service leave it be. wow leveling service would never practice the . wow powerleveling arts of magic again. the prospect of making. 20gb mp3 player didn’t seem like a bad idea either. cheap wow power leveling Too deep in his own thoughts. flash mp3 player a human voice said.flash mp3 players he could recollect Loran was some sort of Captain too. HDRO gold I don’t think I’ve seen you around before. level wow hundreds of prisoners .lord of rings online gold all to be quite frank. lotro gold but right now an upper-class. lotro gold trotted off just now. mp3 player 2gb video as Trolls are from my experience quite . mp3 player usb stumble your way into this god forsaken place. mp3 player with video .power level the delivery, although somewhat late. power level Loran continued. usb mp3 players and started walking back. wow level warn Stormwind of the structure. wow leveling “There’s been quite some activity. wow lvl though most of them were Trolls themselves”. wow lvl he didn’t like it too much. wow lvl 60 unable to organize anything more advanced than a barbecue. wow lvl 70 have been transferred up to some sort of execution chamber. wow power leveling Durin noticed the upper-class Stormwind speech. wow powerlevel not a very jolly sight at. wow powerlevel He decided he had to. wow powerleveling


wow gold commented on Sunday, 21-Dec-2008
I had it shipped overnight via UPS and the next day I spent all day waiting for the UPS truck to arrive. With the Christmas delivery season, it didn't arrive at my home until about 8:30pm that night. In my order was my sleek black PSP system and three game titles: Minna no Golf, Vampire Chronicles, and Ridge Racers.wow goldI would spend the next few weeks with my PSP permanently glued to my hands. Once I was finally able to pull myself away from Minna no Golf,wow goldI made the mistake of purchasing the import version of Lumines and spent another 3 weeks glued to the system. It goes without saying, I got my money's worth out of the PSP, even early on, and it was then that my poor DS system began collecting dust on the shelf.


wow gold commented on Sunday, 21-Dec-2008
There aren't many games in my 28 years of playing video games that I genuinely love as much as Final Fantasy X. I think it's the greatest video game ever made, and was just mind-blowing when it first came out. I got the opportunity to share this game with someone that I really cared about and it made the game even more of a moving experience for me. world of warcraft goldbuy wow goldcheap wow goldwow power levelingwow powerlevelingeverquest 2 goldeq2 platfinal fantasy 11 cheap gilbuy ffxi gilffxi gilfinal fantasy xi gilmaple story mesosmaplestory mesosI've always kept my video gaming to myself for fear of tarnishing it by sharing it with someone I was dating in the event things didn't work out, but I took the chance for once and it really paid off. maplestory mesolotro goldlotr goldlord of the ring goldrunescape goldrunescape moneysilkroad goldbuy silkroad golddofus kamaskamas dofuswarhammer goldbuy warhammer goldflyff penyabuy flyff goldflyff moneyAlthough things didn't work out in the end, it was very special to be able to share something I love so much with another person I was close to. So this is a thank you to them for being a part of my life for a while and for sharing in something I love as much as video games and for sitting up with me late while I was trying to beat Seymour Flux. eve iskeve online iskarchlord goldbuy archlord goldstar wars galaxiesswg creditsCheap warhammer goldrunescape itemsworld of warcraft goldwow power levelcheap wow goldwow power levelingwow powerlevelingbuy wow goldcheap ffxi gilI'll always hold onto the two Final Fantasy action figures as a momento of the entire experience. I wish you could have been there when I finally finished the game, ffxi gilfinal fantasy gilMaple Story Mesosmaple story accountmaplestory MesosLOTRO Goldlord of the rings goldLOTR Golddofus kamaskamas dofusrunescape moneyrunescape powerlevelingrunescape goldArchLord goldarchlord powerlevelingarchlord itemsflyff penyaflyff cheapflyff moneyWarhammer goldbuy warhammer goldEverQuest 2 goldeq2 platbut I found the ending of the game kind of fitting considering the way things went for us at the end of our time together. Here's to you


wow gold commented on Sunday, 21-Dec-2008
It goes without saying that the original Sonic the Hedgehog is still one of the greatest 16-bit era games ever made.EverQuest goldEverQuest platbuy eq goldeq plateverquest platinumlineage adenalineage 1 adenalineage 2 adenabuy lineage 2 adenalineage ii adenacheap lineage 2 adenawow goldworld of warcraft goldbuy wow goldcheap wow goldWhile I love all of the 16-bit Sonic titles, the original still holds a special place in my heart and my video game collection, even all these years later. I still drag this game out quite often and play through it again just for fun. wow power levelingwow powerleveling2moons dil2moons goldaion goldbuy aion goldanarchy online creditsanarchy online creditcity of heroes influencecoh influencecity of villains infamycov infamygaia online goldgaia goldguild wars goldI remember making my family drive all over the city of Alamagordo, NM in order for me to find a copy of Sonic the Hedgehog the day it came out while we were on vacation. While they weren't happy about having to spend several hours hunting down a video game store, it was well worth the effort when I got back to my motel room and began playing the game. gw goldhellgate london palladiumhero online goldlast chaos goldpirates of the burning sea goldpotbs doubloonrappelz rupeerappelz goldrf online goldthe sun onlinethe sun online goldsword of the new world vissword of the new world goldtabula rasa creditPotbs goldtabula rasa creditstales of pirates goldvoyage century goldPotbs goldaoc goldage of conan power levelingThey had to drag me kicking and screaming out of the motel from then on as I didn't want to put the game down. No matter how you do it, wow power levelbuy wow goldwow power levelingcheap wow goldlineage adenalineage 1 adenalineage 2 adenabuy lineage 2 adenalineage ii adenacheap lineage 2 adenaEverQuest goldEverQuest platbuy eq goldeq plateq goldeverquest platinum2moons dil2 moons goldAnarchy Online creditsAnarchy Online creditCity of Heroes influencecoh influenceCity of Villains infamyCOV infamytrack down a copy of Sonic the Hedgehog if you already haven't and experience one of the main reasons that many gamers owned the Sega Genesis console back in the day.eve online iskeve iskGaia Online Goldgaia goldGuild Wars GoldGW goldHellgate London PalladiumHero online goldLast Chaos GoldPotBS DoubloonPotbs goldRappelz Rupeerappelz goldSWG CreditsStar Wars Galaxies CreditsSword of the New World Vissword of the new world goldTabula Rasa CreditTabula Rasa CreditsTales of Pirates Goldvoyage century goldSilkroad goldbuy silkroad goldaoc goldaoc power levelingtibia moneytibia goldYou won't be disappointed. Sonic the Hedgehog is still one of the best video games ever made and a real treasure among the platformer genre.


car wash commented on Monday, 29-Dec-2008
Pursestock supplier provides the best Gucci replica,Chanel replica,Louis Vuitton replica; show you every detail of photos of replica handbags. Do you think it is hard to believe that we have such a high-quality wholesale replica handbags,Hermes birkinand Hermes kelly? Let me tell you, when you have our Gucci replica purses, you will understand why Chinese manufacturing industry and replicas products are so well-developed. The authentic Gucci replica, you can buy for collections. But the genuine high prices are outrageous, how many collections you can buy with such a high price,if you like Monogram Canvas,speedy 30,chanel 2.55 bag ? Jadeshow’s replica Tiffany Jewelry and Replica Bvlgari Jewelery looks just like the real thing. Why pay more for a single piece of Tiffany Replica jewelry,Bvlgari Replica Jewelry when you can treat yourself to a number of replica pieces for the same price or less? Be simply spectacular with contemporary Tiffany-inspired jewelry!Jadwshow delights in the opportunity to offer our customers fine Tiffany Bracelets, Tiffany Necklaces, Tiffany Earrings, Tiffany Rings, Tiffany Bangles,Gucci jewelry replica, all at remarkably low prices.

Name:
URL:
Email:
Comments:

CAPTCHA Image Validation