question

SHUOH-8693 avatar image
0 Votes"
SHUOH-8693 asked RaytheonXie-MSFT commented

Regarding Intecepting permission of document library by Event Reciever

Hi there,

Just wondering is it possible to use event receiver to intercept permission of document library (Stop Inherent)?? I mean when a user add user permission into SharePoint Permission Group of document library, we could get any information by event receiver. I know the permission of web can be fulfilled by using SPSecurityEventReceiver Class. does anyone have any idea on it.

thanks

sharepoint-devoffice-sharepoint-server-developmentoffice-sharepoint-server-customization
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered RaytheonXie-MSFT commented

Hi @SHUOH-8693
You can catch permissions changing by add RoleAssignmentAdded event receiver for site or web. It will catch permission changing on list or item levels too.

 public class MyClass_PermissionEventReceiver : SPSecurityEventReceiver
 {
     public override void RoleAssignmentAdded(SPSecurityEventProperties properties)
     {
         base.RoleAssignmentAdded(properties);
     }
    
     public override void RoleAssignmentAdding(SPSecurityEventProperties properties)
     {
         base.RoleAssignmentAdding(properties);
     }
 }



· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RaytheonXie-MSFT,

I would like to reconfirm the way to intercept the "PERMISSION OF DOCUMNET LIBRARY" NOT List Item. If I use the Sample Code you provided, It will also catch the permission changing in the PERMISSION OF DOCUMNET LIBRARY SETTINGS including with PERMISSION GROUP OF DOCUMNET LIBRARY and USERS OF DOCUMNET LIBRARY.

Thanks

123484-image.png


0 Votes 0 ·
image.png (235.5 KiB)

@RaytheonXie-MSFT

I mean if we STOP INHERENT PERMISSION in the Document Library <NOT Document or List Item>, we still can catch the PERMISSION CHANGING

Thanks

0 Votes 0 ·

Hi @SHUOH-8693
Per my test, we set event receiver for document library to catch permission changes ,won't be affected by stop inherent.

0 Votes 0 ·
RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered SHUOH-8693 commented

Hi @SHUOH-8693
Please refer to the following link to create an event receiver:
https://www.c-sharpcorner.com/UploadFile/anavijai/create-groupuseradded-event-receiver-in-sharepoint-2013/

Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RaytheonXie-MSFT, the sample is just only for site level. If my site structure is like this:

Site Collection - A
Document Library - D1 - Stop Inherent

that mean there is a permission group called "Approvers" in A, and we stop inherent in D1. We add user called AAronp in A, AAronp will be added in D1. But I need a solution to monitor the Permission of D1, when a user was added in it.

Is there any way to do this??

thanks

0 Votes 0 ·