locked
Amend the security rights of a document prior to saving RRS feed

  • Question

  • Is it possible to amend the security rights of a document prior to saving in SharePoint library?
    • Changed type Mike Walsh FIN Sunday, August 7, 2011 7:16 AM question
    • Edited by Mike Walsh FIN Sunday, August 7, 2011 7:17 AM Bold and link removed from text. Post questions only in normal text.
    • Moved by Mike Walsh FIN Sunday, August 7, 2011 7:18 AM admin q (From:SharePoint - General Question and Answers and Discussion (pre-SharePoint 2010))
    Sunday, August 7, 2011 2:27 AM

Answers

  • you can add use either itemcheckin or itemupdated or itemadded event refer below code

     

      try

                                        {

                                             strqueryXml = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + properties.ListItem.ID + "</Value></Eq></Where>";

                                          SPListItem objDocItem = //get listitem from the current list using spquery object

                                        }

                                        catch { }

                                        if (objDocItem != null)

                                        {

                                            //First break role inheritence of the item

                                            if (objDocItem.HasUniqueRoleAssignments)

                                            {

                                                objDocItem.ResetRoleInheritance();

                                                objDocItem.BreakRoleInheritance(false);

                                            }

                                            else

                                            {

                                                objDocItem.BreakRoleInheritance(false);

                                            }

    //add,edit or delete permissions as per your need


    Rahul Sharma -------------------------- Coding is all about passion !!!!!!
    Sunday, August 7, 2011 1:35 PM

All replies

  • you can add use either itemcheckin or itemupdated or itemadded event refer below code

     

      try

                                        {

                                             strqueryXml = @"<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + properties.ListItem.ID + "</Value></Eq></Where>";

                                          SPListItem objDocItem = //get listitem from the current list using spquery object

                                        }

                                        catch { }

                                        if (objDocItem != null)

                                        {

                                            //First break role inheritence of the item

                                            if (objDocItem.HasUniqueRoleAssignments)

                                            {

                                                objDocItem.ResetRoleInheritance();

                                                objDocItem.BreakRoleInheritance(false);

                                            }

                                            else

                                            {

                                                objDocItem.BreakRoleInheritance(false);

                                            }

    //add,edit or delete permissions as per your need


    Rahul Sharma -------------------------- Coding is all about passion !!!!!!
    Sunday, August 7, 2011 1:35 PM
  • Thank your for your reply.

     

    I agree with you and i have done the same using a SPD workflow. Is it possible to amend the security like blocking from printing, copying, sending email while saving into document library.

    Monday, August 8, 2011 5:24 AM
  • For that You need to configure IRM server. Information Right Management. There is no OOB way to restrict user for printing , blocking etc. Thats why SharePoint gives you power to install IRM on your server and configure it 
    -------------------------------------------------------- Rahul Sharma -------------------------------------------------------- Coding is all about passion !!!!!! -------------------------------------------------------- http://sharepointarrow.blogspot.com/
    Monday, August 8, 2011 6:56 AM