IUserProfilePermissions Property |
Namespace: AskiaPortalCmn
This example looks the user profile 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; } if (!Context.User.UserProfileId.HasValue) { Console.Error.WriteLine("The user doesn't have a user profile attached to him"); return; } var profile = UserProfileFactory.FindById(context, Context.User.UserProfileId.Value); switch (profile.Permissions[AccessTo.Users]) { case AccessLevel.None: Console.WriteLine("The user profile don't have permission to access users"); break; case AccessLevel.ReadOnly: Console.WriteLine("The user profile can only view users"); break; case AccessLevel.CreateAndEdit: Console.WriteLine("The user profile are allowed to view, create, edit users"); break; case AccessLevel.FullControl: Console.WriteLine("The user profile have full control on users (view, create, edit, delete and restore)"); break; } } } }