示例#1
0
        public static bool GetIsUserDirectlyAssociatedWithSecurityRole(
            this IPluginContextBase pluginCtx,
            Guid userId,
            string rootRoleId     = null,
            string templateRoleId = null)
        {
            var invalidAgrs = rootRoleId == null && templateRoleId == null;

            if (invalidAgrs)
            {
                throw new ArgumentOutOfRangeException($"Neither {nameof(rootRoleId)} nor {nameof(templateRoleId)} is provided.");
            }

            string[] rootRoleIds = null;
            if (rootRoleId != null)
            {
                rootRoleIds = new[] { rootRoleId };
            }

            string[] templateRoleIds = null;
            if (templateRoleId != null)
            {
                templateRoleIds = new[] { templateRoleId };
            }

            return(pluginCtx.GetIsUserDirectlyAssociatedWithSecurityRole(userId, rootRoleIds, templateRoleIds));
        }
示例#2
0
 public static bool GetIsUserDirectlyAssociatedWithSecurityRole(
     this IPluginContextBase pluginCtx,
     string[] rootRoleIds     = null,
     string[] templateRoleIds = null)
 {
     return(pluginCtx.GetIsUserDirectlyAssociatedWithSecurityRole(
                pluginCtx.InitiatingUserId,
                rootRoleIds,
                templateRoleIds));
 }
示例#3
0
 /// <summary>
 /// Gets if the user is a system administrator.
 /// </summary>
 /// <param name="pluginCtx">The plugin context.</param>
 /// <param name="userId">The user identifier.</param>
 /// <returns></returns>
 public static bool GetIsAdminUser(this IPluginContextBase pluginCtx, Guid userId)
 {
     return(pluginCtx.GetIsUserDirectlyAssociatedWithSecurityRole(
                userId,
                templateRoleId: TemplateSecurityRoleIds.SystemAdministratorRoleTemplateId));
 }