Click or drag to resize

IUserPermissions Property

Indicates the permissions of the user.

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
IPermissions Permissions { get; }

Property Value

Type: IPermissions
Examples

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;
                }
         }
    }
}
See Also