Exemple #1
0
    /// <summary>
    /// Load ACLItems for the selected document.
    /// </summary>
    /// <param name="reload">Forces reload of listbox</param>
    private void LoadACLItems(bool reload)
    {
        if ((dsAclItems != null) && !reload)
        {
            return;
        }

        var orderBy = new[] { "OperatorName", "Operator", "Inherited DESC" };
        var columns = new[] { "Operator", "ACLOwnerNodeID", "OperatorName", "OperatorFullName", "Allowed", "Denied", "RoleGroupID", "RoleID", "SiteID", "CASE WHEN (ACLOwnerNodeID = " + Node.NodeID + ") THEN 0 ELSE 1 END AS Inherited" };

        string where = GetWhereCondition();
        dsAclItems   = AclItemInfoProvider.GetACLItemsAndOperators(Node.NodeID)
                       .Where(where)
                       .OrderBy(orderBy)
                       .Columns(columns);
    }
Exemple #2
0
    /// <summary>
    /// After node created, solver role permissions.
    /// </summary>
    private void AddRoles(object sender, EventArgs e)
    {
        var    tree    = new TreeProvider(MembershipContext.AuthenticatedUser);
        string roleIds = ";" + usRoles.Value + ";";

        // Check if ACL should inherit from parent
        if (InheritParentPermissions)
        {
            AclInfoProvider.EnsureOwnAcl(EditedNode);
        }
        else
        {
            // If node has already own ACL don't leave permissions, otherwise break inheritance
            if (!EditedNode.NodeIsACLOwner)
            {
                AclInfoProvider.BreakInheritance(EditedNode, false);
                var breakInheritanceNode = tree.SelectSingleNode(EditedNode.NodeID);
                DocumentSynchronizationHelper.LogDocumentChange(breakInheritanceNode, TaskTypeEnum.BreakACLInheritance, tree, SynchronizationInfoProvider.ENABLED_SERVERS, null, tree.AllowAsyncActions);
            }
        }

        // Get original ACLItems
        DataSet ds = AclItemInfoProvider.GetACLItemsAndOperators(EditedNode.NodeID)
                     .WhereStartsWith("Operator", "R")
                     .WhereEquals("ACLID", EditedNode.NodeACLID)
                     .Columns("Operator", "Allowed", "Denied");

        // Change original values
        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string op        = DataHelper.GetNotEmpty(dr["Operator"], "R");
                int    allowed   = ValidationHelper.GetInteger(dr["Allowed"], 0);
                int    denied    = ValidationHelper.GetInteger(dr["Denied"], 0);
                int    aclRoleId = ValidationHelper.GetInteger(op.Substring(1), 0);

                if (aclRoleId != 0)
                {
                    // Check if read permission should be set or removed
                    if (roleIds.Contains(";" + aclRoleId + ";"))
                    {
                        // Remove role from processed role and adjust permissions in database
                        roleIds  = roleIds.Replace(";" + aclRoleId + ";", ";");
                        allowed |= 1;
                    }
                    else
                    {
                        allowed &= 126;
                    }

                    RoleInfo ri = RoleInfoProvider.GetRoleInfo(aclRoleId);
                    AclItemInfoProvider.SetRolePermissions(EditedNode, allowed, denied, ri);
                }
            }
        }


        if (roleIds.Trim(';') != "")
        {
            // Create ACL items for new roles
            string[] roles = roleIds.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string role in roles)
            {
                RoleInfo ri = RoleInfoProvider.GetRoleInfo(int.Parse(role));
                AclItemInfoProvider.SetRolePermissions(EditedNode, 1, 0, ri);
            }
        }

        var node = tree.SelectSingleNode(EditedNode.NodeID);

        DocumentSynchronizationHelper.LogDocumentChange(node, TaskTypeEnum.UpdateDocument, tree);
    }