What I want to do
Im trying to write a software that is able to remove write permissions from all unsers for a file or folder so noone can modify/delete/overwrite the file.
What I already did
I know how to assign groups and permissions to a file. My Problem is, that I need the permissions based on the file's location. To make it easier, I dont have to use the filepath but can use the permission. Our sharepoint is set up in the following way:
Root -Marketing -IT --Development --ServiceDesk ...
All users in the group Marketing have access (Role: Edit) to all folders/files beneath Marketing. The same with IT and others. My idea is to get a file/folder, read all permissions/groups, remove the current roles and add them again with readonly.
I cant find a way to get all groups that have permission to a file.
How can I get all Groups from one file (if possible with their role)? Is there a better way to achieve what I want to do?