To change automatically the permissions once the document's classification has been changed

Hi,
For example I have a document where its classification is Public (so all users can see) and it is changed to Restricted. Is there a way that when the classification property is changed in a document library, only the restricted users will have permission
to access it please? I need to be done automatically NOT manually.
Thanks

Hi,
Extending the solution of Gilles, you can consider the code as below for setting item level permission:
using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
namespace ItemLevelSecurity.ItemSecurity
/// <summary>
/// List Item Events
/// </summary>
public class ItemSecurity : SPItemEventReceiver
/// <summary>
/// An item was added.
/// </summary>
public override void ItemAdded(SPItemEventProperties properties)
SPSecurity.RunWithElevatedPrivileges(delegate()
try
using (SPSite oSPSite = new SPSite(properties.SiteId))
using (SPWeb oSPWeb = oSPSite.OpenWeb(properties.RelativeWebUrl))
//get the list item that was created
SPListItem item = oSPWeb.Lists[properties.ListId].GetItemById(properties.ListItem.ID);
//get the author user who created the item
SPFieldUserValue valAuthor = new SPFieldUserValue(properties.Web, item["Created By"].ToString());
SPUser oAuthor = valAuthor.User;
//assign read permission to item author
AssignPermissionsToItem(item,oAuthor,SPRoleType.Reader);
//update the item
item.Update();
base.ItemAdded(properties);
catch (Exception ex)
properties.ErrorMessage = ex.Message;
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.Cancel = true;
public static void AssignPermissionsToItem(SPListItem item, SPPrincipal obj, SPRoleType roleType)
if (!item.HasUniqueRoleAssignments)
item.BreakRoleInheritance(false, true);
SPRoleAssignment roleAssignment = new SPRoleAssignment(obj);
SPRoleDefinition roleDefinition = item.Web.RoleDefinitions.GetByType(roleType);
roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
item.RoleAssignments.Add(roleAssignment);
Reference:
https://social.technet.microsoft.com/Forums/en-US/c5b445c1-a6c9-44ca-8fc6-ec18aedc35f1/setting-item-level-access-rights-on-sharepoint-list-item-in-itemadding-event-handler?forum=sharepointdevelopment
Best Regards,
Eric
Eric Tao
TechNet Community Support

Similar Messages

  • I'm having trouble with my Pages app. Over half of my document are updating, and do not finish. I cannot get to the documents. This has been going for 2 weeks now, they do not update.

    I'm having trouble with my Pages app. Over half of my document show that they are updating. I cannot open or delete the documents. Does anyone know a fix for this? Please help.

    Try this  - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.) No data/files will be erased. http://support.apple.com/kb/ht1430http://support.apple.com/kb/ht1430
    Troubleshooting apps purchased from the App Store
    http://support.apple.com/kb/TS1702http://support.apple.com/kb/TS1702
     Cheers, Tom

  • Is there any options to know what is the particular field that has been changed or updated in AR invoice?

    Hi...
    Is there any option to know what is the actual field that has been updated / changed in the AR Invoice document.
    ADOC and ADO1 Contains the history of the updated documents .....
    but i need what is the exact field that has been changed....?
    Is there any option.....?

    Hi Gopi,
    Please check below links.
    http://help.sap.com/saphelp_sbo882/helpdata/en/45/06b97f7d720487e10000000a155369/content.htm
    Queries off the Change Log
    Query for Change Log
    In above links, You can Modify Query as per your requirement.
    Hope this help
    Regards::::
    Atul Chakraborty

  • Can the genre of a song or album in my itunes library be changed?  While loading to the itunes library, or after the song or album has been loaded?

    Can the genre of a song or album in my itunes library be changed?  While loading to the itunes library, or after the song or album has been loaded?

    Kay -
    Glad it helped.  Enjoy the music!
    Ed

  • My biggest 'pain' at the moment is that every time I go to change then save a Photoshop CS3 file it says 'cannot save as the file as it has been left open or is in use by another application'

    My biggest 'pain' at the moment is that every time I go to change then save a Photoshop CS3 file it says 'cannot save as the file as it has been left open or is in use by another application'

    Rule Number One - NEVER go directly uinto the iPhoto library - there are no user servicable parts in it and making any change no matter how small can corrupt your library and cause data or photo loss
    Exactly how were you trying to save a copy of your iPhoto library?
    Albumdata.xml does not contain your photos - and again NEVER make any changes to the content of the iPhoto library - no dragging - no changes - never go into the library
    We need to know exactly what you did
    And probalby the easiest solution is to load your backup from before you messed things up
    For reference after you get things working
    Moving the iPhoto library is safe and simple - quit iPhoto and drag the iPhoto library intact as a single entity to the external drive - depress the option key and launch iPhoto using the "select library" option to point to the new location on the external drive - fully test it and then trash the old library on the internal drive (test one more time prior to emptying the trash)
    And be sure that the External drive is formatted Mac OS extended (journaled) (iPhoto does not work with drives with other formats) and that it is always available prior to launching iPhoto
    And backup soon and often - having your iPhoto library on an external drive is not a backup and if you are using Time Machine you need to check and be sure that TM is backing up your external drive
    LN

  • Is there a size limit to the document? I have been  trying to convert a pdf to excel without success

    Is there a size limit to the document? I have been  trying to convert a pdf to excel without success

    Is there a size limit to the document? I have been  trying to convert a pdf to excel without success

  • TS3048 My MacBook OSX 10.6.8 detects the wireless keyboard apple A1255 but once the passkey is ask the "pairing" process stops and displays a warning saying it was unsuccessful. Bateries are new on the keyboard and it has been paired to this MacBook .

    My MacBook OSX 10.6.8 detects the wireless keyboard apple A1255 but once the passkey step show on the screen the "pairing" process stops and displays a warning saying it was unsuccessful. Bateries are new on the keyboard and it has been paired to this MacBook before. Mouse, iphone and other bluertooth devices have no problem pairing via bluetooth. Any suggestions where to look?

    I read somwhere that firefox disables certain versions of java because it might give control of your computer to other malicious websites
    I think you have to go to the java website and down load the version you need and enable it in firefox's prefrences
    Sorry I may be a veteran in using firefox, but I know very little since I hardly had problems with mozilla untill just very recently hope this helps

  • What has the Apple support team done to the Top Sites screen? I just accepted an automatic update to be downloaded to my iMAC, and as a result of this "fix installation" the layout of the Top Sites screen has been terribly "destroyed"! What's the idea?

    What has the Apple support team done to the Top Sites screen? I just accepted an automatic update to be downloaded to my iMAC, and as a result of this "fix installation" the layout of the Top Sites screen has been terribly "destroyed"! What's the idea?

    If you are referring to the non-panorama , but rather the flat look, well that's what they did.
    You can give your opinion here:
    http://www.apple.com/feedback

  • Failed to start workflow. The workflow cannot access the item that it has been applied to.

    I have a quick question for you and it would be great if you can answer me on this.
    I'm working through SharePoint Workflow issue (developed using Nintex) that started recently where people are getting workflow error and I don't see issues if I submit it myself. Current error. - "Failed to start workflow. The workflow cannot access
    the item that it has been applied to."
    I haven't made any major changes to Workflow except for changing email notification content and publishing it. My question is, do I need to publish the rest of the workflows too that are associated to the list after I publish changes of one workflow? Looks
    like users have required permissions to submit the form. Please let me know how to get rid of this error.
    smith

    Hi Smithspd,
    According to your description, my understanding is that your users got a workflow error, and the workflow is created by Nintex.
    For SharePoint Designer workflow, once we do any change in a workflow, we need to re-publish the workflow.
    For your issue, I suggest you re-publish the workflow, compare the result.
    In addition, as your workflow is created by Nintex and this forum is for SharePoint Designer, I suggest you ask Nintex support or forum for better help.  Thanks for your understanding.
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • Note: Due to heavy load, the latest workflow operation has been queued. It will attempt to resume at a later time

    Dear all,
    sorry for opening another thread on this.
    I think I have a performance issue with workflows attached to document sets in SharePoint. And I say “I think” because people keep telling me that this is the way it just is.
    The user creates a new document set, which triggers a workflow in which the user has to confirm/review/approve a series of tasks. The time it takes from clicking the OK button on those task form to the workflow status moving to the next step is about 4 seconds.
    And visiting that status page within those 4 seconds brings up the infamous “Note: Due to heavy load, the latest workflow operation has been queued. It will attempt to resume at a later time.” message.
    Hitting Refresh in the browser after those 4 seconds will make the new workflow status appear and the red text go away.
    Is that normal? Is that the performance that everyone else is seeing as well?
    I struggle to see why simply moving a workflow from one task to another should take that on a machine that isn’t doing anything else at the time.
    (1)   
    I have a standalone (non-clustered) SharePoint box, 4 CPUs, 8 GB of memory, more than half of that available, acting as application server and wfe; only the database is on different box.
    (2)   
    The CPU only goes up to 18 or 19%, so CPU does not seem to be the bottleneck. Half the RAM is also still free.
    (3)   
    The workflow is designed with Nintex, and has about 9 flexi and review tasks – the last 2 of them in a loop iterating over typically 3 or 4 items.
    (4)   
    Looking at the logs it looks like the processing in Nintex only takes about 1 second – I don’t know where the other 3 seconds are going.
    (5)   
    There is nothing obvious in the logs.
    (6)   
    We’ve looked at all the “theoretical” improvements around throttling and batch sizes etc. – none of them appeared make any difference. And the workflow is so small that it looks like my tasks gets executed straight away. The problem appears
    to be that the execution takes too long(?) and therefore has not finished by the time the page get redrawn.
    (7)   
    I am running perfmon and I can e.g. see one(!) workflow being loaded into memory – as expected as I am the only user.
    (8)   
    I am seeing a total of 3(?) SQL queries being executed(?). I get the Bytes Sent/sec spiking at 25K, and Bytes received at 18K. But is this good or bad or a bottleneck?
    Where do I take it from here?
    I have been told that “[…] most customers have no issue with this as they are used to the way SP operates and it can be slow at times.” Is it really that bad?
    If it is worth watching more performance counters then I’d need to know what to compare them to.
    Is there something else I am missing?
    Thanks
    Martin

    Hi,
    Before considering an additional hardware try to change following configurations for workflow:
    Increase Throttle Size
    Increase Batch Size
    Time Out
    Workflow Timer Interval
    AutoCleanUpDays
    Increase Throttle Size
    The Workflow throttle setting controls how many Workflows can be processing at any one time on the entire server farm. By increasing the throttle it will allow the number of Workflows execution or can be initiated at a time.
    Use below PowerShell command to get the current Throttle Size:
    Get-SPFarmConfig | Select WorkflowPostponeThreshold
    Use below PowerShell command to set new Throttle Size:
    Set-SPFarmConfig -WorkflowPostponeThreshold 100
    Increase Batch Size
    This is the size that determines number of events processed for a single Workflow instance. Default value is 100, but it can be range from 1 to any number.
    Use below PowerShell command to get the current Batch Size:
    Get-SPFarmConfig | Select WorkflowBatchSize
    Use below PowerShell command to set new Batch Size:
    Set-SPFarmConfig -WorkflowBatchSize 200
    Time Out
    This decides the time out of the Workflow event. The default value is 5 and can be any integer. The time is in minute.
    Use below STSADM command to get the current Time Out value:
    stsadm -o getproperty -pn workflow-eventdelivery-timeout
    Use below STSADM command to get the current Time Out value:
    stsadm -o setproperty -pn workflow-eventdelivery-timeout -pv “15″
    Workflow Timer Interval
    This setting is applicable at Web Application level and not the farm level. The workflow timer interval specifies how often the workflow SPTimer job fires to process pending workflow tasks. This interval also represents the granularity of delay timers within
    your workflow. If a timer is set to delay for one minute, but the interval timer fires only every five minutes, the workflow delays for five minutes, not one minute.
    Use below STSADM command to get the current Workflow Timer Interval value:
    stsadm -o getproperty -pn job-workflow -url <Web Application Url>
    Use below STSADM command to get the current Workflow Timer Interval value:
    stsadm -o setproperty -pn job-workflow -pv “Every 10 minutes between 0 and 30″ -url <Web Application Url>
    Here is the url for reference :
    http://praveenkasireddy.wordpress.com/2013/06/14/workflow-due-to-heavy-load-the-latest-workflow-operation-has-been-queued-it-will-attempt-to-resume-at-a-later-time/

  • Payroll Error msg "The gross wages do not cover the negative offset that has been forwarded, therefore, no grossup is permitted".

    Hi Experts,
    I am getting the below error msg while running payroll for an US employee.
    "The gross wages do not cover the negative offset that has been forwarded; therefore, no grossup is permitted."
    I am getting this error msg just after USTAX function processing part of UTX0 subschema. I am highlighting below facts & findings for your reference.
    As per a client requirement,  I have configured a new gross up WT (ER benefit contribution) for a benefit plan (IT 0168) and the changes are in QAS system. The changes have to be reflected in period 20/2014 (4th May'14- 10th May'14) with retro effective 01/01/2014 as per the benefit plan record maintained from 01/01/2014.
    This error msg is coming only for few employees. In my example, when I am running payroll in period 20/2014 with forced retro as 01/01/2014, system is giving error in period 14/2014 (23rd Mar'14-29th Mar'14). When I checked the pay result of this employee for period 14/2014, I can see the /101 is in -ve value and there is claim generated for this period. So I think, eventhough, a value of $ 2.53 is getting added as per the IT 0168 record, its not helping to give a +ve gross value and thus tax is not able to recoved on the same.
    I hope you have come across this issue and can help me to assist to resolve the error msg.
    Regards,
    Prakash  

    If you have correctly configured payroll the system should automatically off set that and should create wage tyes /561 or /563 in RT.

  • Due to heavy load, the latest workflow operation has been queued. It will attempt to resume at a later time.

    I have SharePoint 2010 Enterprise running SP1. Configuration is one SharePoint server in the farm and a SQL 2008 R2 database for the backend. Our user environment is 80 users with very little load on the SharePoint server. I have the workflow timer
    set to 1 minute.
    I have a SPD workflow that starts manually on a form library. Whenever I publish a new version of the workflow, the next time I start the workflow it takes the full minute to finish. If I click on the workflow status before it finishes, I see the message
    "Due to heavy load, the latest workflow operation has been queued. It will
    attempt to resume at a later time.". After the minute completes the workflow finishes.
    Here's the weird thing, the next time I start the workflow, it runs in a couple of seconds - almost instantly. I've tried up to 15 times after the inital publishing and everything seems to work fine on initiation.
    Well, that would be fine for me, however, I intermintantly get this heavy load message during task processes that are running inside the workflow. It's probably less than 5% of the time. It's really frustrating though so I appreciate some help. I'm look
    online and haven't found anything that describes my situation.
    Thank you in advance!

    Hi,
    Before considering an additional hardware try to change following configurations for workflow:
    Increase Throttle Size
    Increase Batch Size
    Time Out
    Workflow Timer Interval
    AutoCleanUpDays
    Increase Throttle Size
    The Workflow throttle setting controls how many Workflows can be processing at any one time on the entire server farm. By increasing the throttle it will allow the number of Workflows execution or can be initiated at a time.
    Use below PowerShell command to get the current Throttle Size:
    Get-SPFarmConfig |
    Select WorkflowPostponeThreshold
    Use below PowerShell command to set new Throttle Size:
    Set-SPFarmConfig -WorkflowPostponeThreshold
    100
    Increase Batch Size
    This is the size that determines number of events processed for a single Workflow instance. Default value is 100, but it can be range from 1 to any number.
    Use below PowerShell command to get the current Batch Size:
    Get-SPFarmConfig |
    Select WorkflowBatchSize
    Use below PowerShell command to set new Batch Size:
    Set-SPFarmConfig -WorkflowBatchSize
    200
    Time Out
    This decides the time out of the Workflow event. The default value is 5 and can be any integer. The time is in minute.
    Use below STSADM command to get the current Time Out value:
    stsadm -o getproperty -pn workflow-eventdelivery-timeout
    Use below STSADM command to get the current Time Out value:
    stsadm -o setproperty -pn workflow-eventdelivery-timeout -pv “15″
    Workflow Timer Interval
    This setting is applicable at Web Application level and not the farm level. The workflow timer interval specifies how often the workflow SPTimer job fires to process pending workflow tasks. This interval also represents the granularity of delay timers within
    your workflow. If a timer is set to delay for one minute, but the interval timer fires only every five minutes, the workflow delays for five minutes, not one minute.
    Use below STSADM command to get the current Workflow Timer Interval value:
    stsadm -o getproperty -pn job-workflow -url <Web Application Url>
    Use below STSADM command to get the current Workflow Timer Interval value:
    stsadm -o setproperty -pn job-workflow -pv “Every 10 minutes between 0 and 30″ -url <Web Application Url>
    Here is the url for reference :
    http://praveenkasireddy.wordpress.com/2013/06/14/workflow-due-to-heavy-load-the-latest-workflow-operation-has-been-queued-it-will-attempt-to-resume-at-a-later-time/

  • Every time I start iTunes I get the message: "iTunes exec has been set to run in compatability mode for an older version of Windows. Turn off compatability mode for iTunes before you open it." How do I turn off the compatability mode?

    Every time I start iTunes I get the message: "iTunes exec has been set to run in compatability mode for an older version of Windows. Turn off compatability mode for iTunes before you open it." How do I turn off the compatability mode? Particularly when I have to do it before I turn on iTunes.

    Try the following document, only be sure that none of the boxes in the compatibility mode tab are checked (not just the compatibility mode box itself):
    iTunes for Windows: How to turn off Compatibility Mode

  • Is there an EASY way to submit podcasts to the itunes store? i've tried creating podcasts in garageband, then somewhere after wordpress  itunes  doesn't recognize the feed. my process has been (i am open to suggestions for other free and EASY services/me

    is there an EASY way to submit podcasts to the itunes store? i've tried creating podcasts in garageband, then somewhere after wordpress  itunes  doesn't recognize the feed.
    my process has been (i am open to suggestions for other free and EASY services/methods):
    garageband : create & edit audio. add 1400x1400 image.
    share to itunes.
    drag file to desktop.
    upload .m4a file to google drive.
    create a link post in wordpress using "podcast" tag & create "podcast" category.
    click on "entries rss" in wordpress, which takes me to the rss subscribe page (which is basically just my wordpress address with "/feed" at the end.
    i copy this url.
    go to itunes store > then "submit a podcast"
    itunes gives me the error message "we had difficulty downloading episodes from your feed."
    when i try to subscribe to my podcast in itunes, it does, but gives me no episodes available.
    i went back into wordpress and changed settings/ reading settings to : "full text" from "summary"
    still the same error message.
    i added a feedburner step after wordpress but got the same errors. i don't think i should have to add feedburner.
    wordpress seems to be encapsulating the rss, what am i doing wrong?
    this so much easier when you could go directly from garage band to iweb to mobileme; i miss those apple days (also idisk).

    if anyone has a super EASY process, i would LOVE to know what it is. EASY, meaning no html and also free. there are many free online storage systems available, many of which i currently use. the above process was just me trying to figure it out, if you have an easier method, please share. thank you so much!

  • I just got a new MacBook Pro, and I tried to bring across my files from my last mac using time machine. After it was done copying I can't find my files anywhere but the space (about 130gb) has been used on my hard drive. Help please!!

    I just got a new MacBook Pro, and I tried to bring across my files from my last mac using time machine. After it was done copying I can't find my files anywhere but the space (about 130gb) has been used on my hard drive. Does anyone know how I can get to them? I did change my user name from 'user' while it was copying, could this have something to do with it?

    You don't want to do that by copying.
    Your best bet, by far, is to use Setup Assistant.  If your Mac is running Snow Leopard, see Using Setup Assistant on Snow Leopard or Leopard.
    If it came with Lion, it's a bit different: Using Setup Assistant on Lion

Maybe you are looking for

  • Ipod refuses to "update"

    i've downloaded the newest update from the web site for my ipod+video, but when i try to run the update program from itunes, i receive the message, "The ipod, "Ashle's ipod" couldn't be updated. The required file cannot be found." Where can I get the

  • HR Tables Join Condition

    Hello,   My requirment to extract data from the below HR Tables to BW.   Fot that purpose i am developing a VIEW based on these tables...   what are fields that are present in all tables as i can use them in by join condition HR Tables HRP1000 HRP100

  • Reducing QTw/alpha channel file size

    I was just handed a 01:30min QuickTime file (with and Alpha Channel) that is 960 MB. The client wants the file size to be significantly (10mb/min) smaller, for internet/flash use. I figured out how to export it (thanks to the forums) without loosing

  • Pac Man won't sync

    80 gig, plays video and has the org 3 games on it bought the game went to games tab, nothing there, in my Library it shows ipod Games, I click on it and it shows its there.......... Message was edited by: raventhi

  • Monitoring for Inbound Emails

    Hi There! I have been asked by a client who recently had an outage of inbound emails due to corrupted Kasepersky Definitions in GWAVA, that we setup something that alerts them when new emails have no come into the receive folder from externally withi