コード例 #1
0
    /// <summary>
    /// Expects the "CreateDocumentStructure" method to be run first.
    /// </summary>
    private bool BreakPermissionInheritance()
    {
        // Create an instance of the Tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Get default culture code
        string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");

        // Get the API Example document
        TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example/API-Example-subpage", culture);

        if (node != null)
        {
            // Create an instance of ACL provider
            AclProvider acl = new AclProvider(tree);

            // Break permission inheritance (without copying parent permissions)
            bool copyParentPermissions = false;
            acl.BreakInherintance(node, copyParentPermissions);

            return(true);
        }

        return(false);
    }
コード例 #2
0
    protected void lnkBreakWithClear_Click(Object sender, EventArgs e)
    {
        // Check permission
        CheckModifyPermission(true);

        // Break permission inheritance and clear permissions
        AclProvider.BreakInherintance(Node, false);

        // Log staging task and flush cache
        DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.BreakACLInheritance, Node.TreeProvider, SynchronizationInfoProvider.ENABLED_SERVERS, null, Node.TreeProvider.AllowAsyncActions);
        CacheHelper.TouchKeys(TreeProvider.GetDependencyCacheKeys(Node, Node.NodeSiteName));

        // Insert information about this event to event log.
        if (DocumentManager.Tree.LogEvents)
        {
            EventLog.LogEvent(EventLogProvider.EVENT_TYPE_INFORMATION, DateTime.Now, "Content", "DOCPERMISSIONSMODIFIED", currentUser.UserID, currentUser.UserName, Node.NodeID, DocumentName, ipAddress, ResHelper.GetAPIString("security.documentpermissionsbreakclear", "Inheritance of the parent document permissions have been broken."), Node.NodeSiteID, eventUrl);
        }

        lblInheritanceInfo.Text = GetString("Security.InheritsInfo.DoesNotInherit");
        SwitchBackToPermissionsMode();

        // Clear and reload
        securityElem.InvalidateAcls();
        securityElem.LoadOperators(true);
    }
コード例 #3
0
    protected void lnkBreakWithCopy_Click(Object sender, EventArgs e)
    {
        // Check permission
        CanModifyPermission(true);

        // Break permission inheritance and copy parent permissions
        AclProvider.BreakInherintance(Node, true);

        // Log staging task
        TaskParameters taskParam = new TaskParameters();

        taskParam.SetParameter("copyPermissions", true);
        DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.BreakACLInheritance, Node.TreeProvider, SynchronizationInfoProvider.ENABLED_SERVERS, taskParam, Node.TreeProvider.AllowAsyncActions);

        // Insert information about this event to eventlog.
        if (Tree.LogEvents)
        {
            EventLog.LogEvent(EventLogProvider.EVENT_TYPE_INFORMATION, DateTime.Now, "Content", "DOCPERMISSIONSMODIFIED", Tree.UserInfo.UserID, Tree.UserInfo.UserName, Node.NodeID, DocumentName, ipAddress, ResHelper.GetAPIString("security.documentpermissionsbreakcopy", "Inheritance of the parent document permissions have been broken. Parent document permissions have been copied."), Node.NodeSiteID, eventUrl);
        }

        lblInheritanceInfo.Text = GetString("Security.InheritsInfo.DoesNotInherit");
        SwitchBackToPermissionsMode();

        // Clear and reload
        securityElem.InvalidateAcls();
        securityElem.LoadOperators(true);
    }
コード例 #4
0
    /// <summary>
    /// Changes permission inheritance for documents filtered by permission 'Modify permissions'
    /// </summary>
    private bool FilterDataSet()
    {
        // Create an instance of the Tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Set the parameters for getting documents
        string siteName  = CMSContext.CurrentSiteName;
        string aliasPath = "/%";
        string culture   = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");
        bool   combineWithDefaultCulture = true;

        // Get data set with documents
        DataSet documents = tree.SelectNodes(siteName, aliasPath, culture, combineWithDefaultCulture);

        // Get the user
        UserInfo user = UserInfoProvider.GetUserInfo("CMSEditor");

        if (user != null)
        {
            // Filter the data set by the user permissions
            TreeSecurityProvider.FilterDataSetByPermissions(documents, NodePermissionsEnum.ModifyPermissions, user);

            if (!DataHelper.DataSourceIsEmpty(documents))
            {
                // Create an instance of ACL provider
                AclProvider acl = new AclProvider(tree);

                // Loop through filtered documents
                foreach (DataRow documentRow in documents.Tables[0].Rows)
                {
                    // Create a new Tree node from the data row
                    TreeNode node = TreeNode.New(documentRow, "CMS.MenuItem", tree);

                    // Break permission inheritance (with copying parent permissions)
                    acl.BreakInherintance(node, true);
                }

                // Data set filtered successfully - permission inheritance broken for filtered items
                apiFilterDataSet.InfoMessage = "Data set with all documents filtered successfully by permission 'Modify permissions' for user 'CMSEditor'. Permission inheritance broken for filtered items.";
            }
            else
            {
                // Data set filtered successfully - no items left in data set
                apiFilterDataSet.InfoMessage = "Data set with all documents filtered successfully by permission 'Modify permissions' for user 'CMSEditor'. No items left in data set.";
            }

            return(true);
        }

        return(false);
    }
コード例 #5
0
ファイル: Default.aspx.cs プロジェクト: KuduApps/Kentico
    /// <summary>
    /// Expects the "CreateDocumentStructure" method to be run first.
    /// </summary>
    private bool BreakPermissionInheritance()
    {
        // Create an instance of the Tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Get default culture code
        string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");

        // Get the API Example document
        TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example/API-Example-subpage", culture);

        if (node != null)
        {
            // Create an instance of ACL provider
            AclProvider acl = new AclProvider(tree);

            // Break permission inheritance (without copying parent permissions)
            bool copyParentPermissions = false;
            acl.BreakInherintance(node, copyParentPermissions);

            return true;
        }

        return false;
    }
コード例 #6
0
ファイル: Default.aspx.cs プロジェクト: KuduApps/Kentico
    /// <summary>
    /// Changes permission inheritance for documents filtered by permission 'Modify permissions' 
    /// </summary>
    private bool FilterDataSet()
    {
        // Create an instance of the Tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Set the parameters for getting documents
        string siteName = CMSContext.CurrentSiteName;
        string aliasPath = "/%";
        string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");
        bool combineWithDefaultCulture = true;

        // Get data set with documents
        DataSet documents = tree.SelectNodes(siteName, aliasPath, culture, combineWithDefaultCulture);

        // Get the user
        UserInfo user = UserInfoProvider.GetUserInfo("CMSEditor");

        if (user != null)
        {
            // Filter the data set by the user permissions
            TreeSecurityProvider.FilterDataSetByPermissions(documents, NodePermissionsEnum.ModifyPermissions, user);

            if (!DataHelper.DataSourceIsEmpty(documents))
            {
                // Create an instance of ACL provider
                AclProvider acl = new AclProvider(tree);

                // Loop through filtered documents
                foreach (DataRow documentRow in documents.Tables[0].Rows)
                {
                    // Create a new Tree node from the data row
                    TreeNode node = TreeNode.New(documentRow, "CMS.MenuItem", tree);

                    // Break permission inheritance (with copying parent permissions)
                    acl.BreakInherintance(node, true);
                }

                // Data set filtered successfully - permission inheritance broken for filtered items
                apiFilterDataSet.InfoMessage = "Data set with all documents filtered successfully by permission 'Modify permissions' for user 'CMSEditor'. Permission inheritance broken for filtered items.";
            }
            else
            {
                // Data set filtered successfully - no items left in data set
                apiFilterDataSet.InfoMessage = "Data set with all documents filtered successfully by permission 'Modify permissions' for user 'CMSEditor'. No items left in data set.";
            }

            return true;
        }

        return false;
    }