Click or drag to resize

IUserManagedGroups Property

Indicates which groups are managed by the user.

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

Property Value

Type: IManagedGroups
Examples

This example looks if the user in the context can manage the group with id 5

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;
                }
                // First look if the user have a permission to at least see groups
                if (context.User.Permissions[AccessTo.Groups] == AccessLevel.None)
                {
                    Console.WriteLine("You don't have enough permission to access groups");
                    return;
                }
                if (context.User.ManagedGroups.Contains(5))
                {
                    Console.WriteLine("You're allowed to manage the group 5!");
                }
                else
                {
                    Console.WriteLine("You're NOT allowed to manage the group 5!");
                }
         }
    }
}
See Also