Click or drag to resize

IManagedGroups Interface

Accessor to the list of groups managed by the user

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
public interface IManagedGroups

The IManagedGroups type exposes the following members.

Properties
  NameDescription
Public propertyIsModified
Flag to indicates if the object has been modified since his initialization
Top
Methods
  NameDescription
Public methodAdd(IListInt32)
Add groups to manage
It will not save the change in the database unless you explicitly save the user
Public methodAdd(Int32)
Add a group to manage
It will not save the change in the database unless you explicitly save the user
Public methodClear
Clear the list of all managed group.
It will not save the change in the database unless you explicitly save the user
Public methodContains
Returns true if the user can manage the group with the specified id
Public methodGetAllIds
Returns the entire list of group ids managed by the user
Public methodGetIds
Returns the non-recursive list of group ids managed by the user
Public methodReload
Reload the managed groups using the current database values
Public methodRemove(IListInt32)
Remove groups from the management
It will not save the change in the database unless you explicitly save the user
Public methodRemove(Int32)
Remove a group from the management
It will not save the change in the database unless you explicitly save the user
Public methodSave
Save the modification in the database if the object has been modified.
Top
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