Click or drag to resize

ShareFactoryFindAllRules Method (IContext, String, IUser, NullableInt32, NullableGuid)

Find or calculate all the appropriate share rules for the specified object type and user.

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
public static IEnumerable<IShareRule> FindAllRules(
	IContext context,
	string objectType,
	IUser user,
	Nullable<int> surveyId = null,
	Nullable<Guid> moduleGuid = null
)

Parameters

context
Type: AskiaPortalCmnIContext
Context of execution.
objectType
Type: SystemString
Type of objects to find.
user
Type: AskiaPortalCmnIUser
Contact to find.
surveyId (Optional)
Type: SystemNullableInt32
Id of the survey, to scope the search.
moduleGuid (Optional)
Type: SystemNullableGuid
Guid of the module that manage the objects (if null use the CurrentModule).

Return Value

Type: IEnumerableIShareRule
Return the list of share rules
Remarks

This method return the more accurate shares.

- If the share is apply on the group and the user, the share of the user will be returned.
- The share apply on group closer to the user will be returned.

The rules find could be database records or calculated rules, specially for administrators.

A user that can manage a group is like a membership of that group.

Examples

Find all share rules for `template`.

var context = ContextFactory.CreateByUserGuid(Guid.Parse("20BE5F84-F006-49A0-9674-4B16A090AF2D"));   
var contextValidation = context.Validate();
if (!contextValidation.Success)
{
    throw contextValidation.Exception;
}
var user = UserFactory.FindById(context, 2);
if (user == null)
{
    Console.WriteLine("The specified user doesn't exist, or the current user within the context could not access it");
}

var rules = ShareFactory.FindAllRules(context, "template", user);
foreach(var rule in rules)
{
    Console.WriteLine($@"The user have the permission {rule.Permission} on the template id `{rule.ObjectId}`");
}
See Also