IPermissions Interface |
Namespace: AskiaPortalCmn.Common
The IPermissions type exposes the following members.
Name | Description | |
---|---|---|
IsModified |
Flag to indicates if the object
has been modified since his initialization.
|
Name | Description | |
---|---|---|
Can(PermissionTo) |
Returns the value of the specified
`AskiaPortal` permission as boolean.
| |
Can(String, NullableGuid) |
Returns the value of the specified permission as boolean.
| |
Change(AccessTo, AccessLevel) |
Change the value of the
specified `AskiaPortal` permission. It will not save the change in the database unless you explicitly call the Save method. | |
Change(PermissionTo, Boolean) |
Change the value of the
specified `AskiaPortal` permission. It will not save the change in the database unless you explicitly call the Save method. | |
Change(String, AccessLevel, NullableGuid) |
Change the value of the specified permission. It will not save the change in the database unless you explicitly call the Save method. | |
Change(String, Boolean, NullableGuid) |
Change the value of the specified permission. It will not save the change in the database unless you explicitly call the Save method. | |
Clear |
Remove all permissions of the user It will not save the change in the database unless you explicitly call the Save method. | |
GetAllItems |
Returns all permission items.
| |
GetItems |
Returns the permission items of
the specified module guid.
| |
GetLevel(AccessTo) |
Returns the value of the specified `AskiaPortal` permission.
| |
GetLevel(String, NullableGuid) |
Returns the value of the specified permission.
| |
Reload |
Reload the permissions using the current database
values.
| |
Remove(AccessTo) |
Remove the specified AskiaPortal permission item. It will not save the change in the database unless you explicitly call the Save method. | |
Remove(PermissionTo) |
Remove the specified AskiaPortal permission item. It will not save the change in the database unless you explicitly call the Save method. | |
Remove(String, NullableGuid) |
Remove the specified permission item. It will not save the change in the database unless you explicitly call the Save method. | |
RemoveAll |
Remove all permissions of the specified module. It will not save the change in the database unless you explicitly call the Save method. | |
Save |
Save the modification in the database
if the object has been modified.
|
This example looks the permission of the current user to access `groups`.
using system; using AskiaPortalCmn; namespace MyApp { class Program { static void Main(string[] args) { // Initialize the current module AskiaPortalCmnApi.InitializeModule(Guid.Parse("26f6ab8b-2fdb-4f4f-ad14-7507892846a5")); var context = ContextFactory.CreateByLoginAndPassword("login", "secret"); var contextValidation = context.Validate(); if (!contextValidation.Success) { Console.Error.Write(contextValidation.Exception.Message); return; } switch (context.User.Permissions.GetLevel(AccessTo.Groups)) { case AccessLevel.None: Console.WriteLine("You don't have permission to access groups"); break; case AccessLevel.ReadOnly: Console.WriteLine("You can only view groups"); break; case AccessLevel.EditOnly: Console.WriteLine("You can only edit groups"); break; case AccessLevel.CreateAndEdit: Console.WriteLine("You're allowed to view, create, edit groups"); break; case AccessLevel.FullControl: Console.WriteLine("You have full control on groups (view, create, edit, delete and restore)"); break; } } } }