IUserPermissions Property |
Namespace: AskiaPortalCmn
This example looks at the `users` permission of the user in the context.
using system; using AskiaPortalCmn; namespace MyApp { class Program { static void Main(string[] args) { var context = ContextFactory.CreateByLoginAndPassword("login", "secret"); var contextValidation = context.Validate(); if (!contextValidation.Success) { Console.Error.WriteLine("Invalid context"); Console.Error.Write(contextValidation.Exception.Message); return; } switch (context.User.Permissions[AccessTo.Users]) { case AccessLevel.None: Console.WriteLine("You don't have permission to access users"); break; case AccessLevel.ReadOnly: Console.WriteLine("You can only view users"); break; case AccessLevel.CreateAndEdit: Console.WriteLine("You're allowed to view, create, edit users"); break; case AccessLevel.FullControl: Console.WriteLine("You have full control on users (view, create, edit, delete and restore)"); break; } } } }