Working with permissions
Hi there,
I'm wondering how can I work with permissions (e.g. add, save, request the permissions) if my custom module does not use OpenAccess?
Let's say I created a model with one class Person. It releases the members of the interface ISecurableObject.
All what I want to do is to grant the default permissions of the custom module to the new item Person. I have the following code:
var securityRoot =
this
.GetSecurityRoot();
if
(securityRoot !=
null
)
Person c =
new
Person();
p.Id = Guid.NewGuid();
foreach
(Permission permission
in
securityRoot.Permissions)
p.Permissions.Add(permission);
Hello Anton Mernov,
You are right that our managers will persist the secured object automatically. Unfortunately they can work with OA only. All the logic should be implemented by the developer in case you use other manager classes, and your own provider for storing the items. The only thing I can point you now is to our guide on permissions - you may be able to pick ideas from there - http://www.sitefinity.com/40/help/developers-guide/deep-dive-security.html
All the best,Hi Georgi,
Thank you for response!
I investigated that every time when new permissions are added to object that inherits ISecuredObject interface a new record is added to sf_permissions table. Also some references are made between this record and Content item object.
As far as understand the first thing I need to do is add a new permission set into sf_permissions table. After this I can get an ID of new record and add it to my table that will store references between my custom object and a permission set in Sitefinity.
My question is: How can I add a new record in sf_permissions table with fields prencipal_id, object_id, etc?
Best regards,
Anton
Hello Anton Mernov,
Unfortunately I am not able to answer this before I dig in this deeper - we are using an ORM and our API takes care of the relations automatically.
Is it an option for you to use the API only?
Guys,
I have a question about Permissions. I am trying to make a Role that is able to manage Users, but not delete my Super Account. How do I restrict a Role that has teh right to manage users, the right to delete a given account?
Also, I deleted the Designer role and made my own roles. Everytime I create a new Page Template, I cannot edit it unless I am an Administrator. It keeps adding the Designer Role by deafult to the Edit permissions for the new template. That is silly, How do I specify that ANY page template can be modified by a role or another. It seems that I have to do it for each Page Template through and Administrator. That's silly.
Anyway, hope there is a way. Thanks,
Andrei