当前位置: 首页>>代码示例>>C#>>正文


C# CurrentUserInfo.IsAuthorizedPerClassName方法代码示例

本文整理汇总了C#中CurrentUserInfo.IsAuthorizedPerClassName方法的典型用法代码示例。如果您正苦于以下问题:C# CurrentUserInfo.IsAuthorizedPerClassName方法的具体用法?C# CurrentUserInfo.IsAuthorizedPerClassName怎么用?C# CurrentUserInfo.IsAuthorizedPerClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CurrentUserInfo的用法示例。


在下文中一共展示了CurrentUserInfo.IsAuthorizedPerClassName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        currentUser = CMSContext.CurrentUser;
        if (currentUser == null)
        {
            return;
        }

        // No cms.blog doc. type
        if (DataClassInfoProvider.GetDataClass("cms.blog") == null)
        {
            RedirectToInformation(GetString("blog.noblogdoctype"));
        }

        // Check if user is authorized to manage
        isAuthorized = currentUser.IsAuthorizedPerResource("CMS.Blog", "Manage") || (currentUser.IsAuthorizedPerClassName("cms.blog", "Manage", CMSContext.CurrentSiteName) &&
                       currentUser.IsAuthorizedPerClassName("cms.blogpost", "Manage", CMSContext.CurrentSiteName));

        // Register grid events
        this.gridBlogs.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridBlogs_OnExternalDataBound);
        this.gridBlogs.OnDataReload += new OnDataReloadEventHandler(gridBlogs_OnDataReload);

        // Get ClassID of the 'cms.blogpost' class
        DataClassInfo dci = DataClassInfoProvider.GetDataClass("cms.blogpost");
        string classId = "";
        string script = "";

        if (dci != null)
        {
            classId = dci.ClassID.ToString();
        }

        // Get scritp to redirect to new blog post page
        script += "function NewPost(parentId, culture) { \n";
        script += "     if (parentId != 0) { \n";
        script += "         parent.parent.parent.location.href = \"" + ResolveUrl("~/CMSDesk/default.aspx") + "?section=content&action=new&nodeid=\" + parentId + \"&classid=" + classId + "&culture=\" + culture;";
        script += "}} \n";

        // Generate javascript code
        ltlScript.Text = ScriptHelper.GetScript(script);
    }
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:41,代码来源:MyBlogs_Blogs_List.aspx.cs

示例2: IsAuthorizedPerDocument

    /// <summary>
    /// Check user permissions for document.
    /// </summary>
    /// <param name="document">Document</param>
    /// <param name="permission">Permissions</param>
    /// <param name="user">User</param>
    /// <returns>TreeNode if authorized, null otherwise</returns>
    public bool IsAuthorizedPerDocument(TreeNode document, string permission, CurrentUserInfo user)
    {
        // Check global permission
        bool userHasGlobalPerm = user.IsAuthorizedPerResource("CMS.Content", permission);

        // Get the values form deleted node
        string className = document.NodeClassName;

        bool additionalPermission = false;

        if (permission.ToLowerCSafe() == "create")
        {
            additionalPermission = user.IsAuthorizedPerClassName(className, "CreateSpecific");
        }

        // Check permissions
        if (userHasGlobalPerm || user.IsAuthorizedPerClassName(className, permission) || additionalPermission)
        {
            return true;
        }

        return false;
    }
开发者ID:arvind-web-developer,项目名称:csharp-projects-Jemena-Kentico-CMS,代码行数:30,代码来源:RecycleBin.ascx.cs

示例3: IsAuthorizedPerDocument

    /// <summary>
    /// Check user permissions for document.
    /// </summary>
    /// <param name="document">Document</param>
    /// <param name="permission">Permissions</param>
    /// <param name="user">User</param>
    /// <returns>TreeNode if authorized, null otherwise</returns>
    public bool IsAuthorizedPerDocument(TreeNode document, string permission, CurrentUserInfo user)
    {
        // Initialize variables
        string className = null;

        // Check global permission
        bool userHasGlobalPerm = user.IsAuthorizedPerResource("CMS.Content", permission);

        // Get node properties
        try
        {
            // Get the values form deleted node
            className = document.NodeClassName;
        }
        catch (ThreadAbortException)
        {
            throw;
        }
        catch (Exception ex)
        {
            CurrentError = "Error occurred: " + ex.Message;
            AddLog(CurrentError);
        }

        bool additionalPermission = false;

        if (permission.ToLower() == "create")
        {
            additionalPermission = user.IsAuthorizedPerClassName(className, "CreateSpecific");
        }

        // Check permissions
        if (userHasGlobalPerm || user.IsAuthorizedPerClassName(className, permission) || additionalPermission)
        {
            return true;
        }

        return false;
    }
开发者ID:v-jli,项目名称:jean0407large,代码行数:46,代码来源:RecycleBin.ascx.cs

示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        currentUser = CMSContext.CurrentUser;
        if (currentUser == null)
        {
            return;
        }

        // No cms.blog doc. type
        if (DataClassInfoProvider.GetDataClass("cms.blog") == null)
        {
            RedirectToInformation(GetString("blog.noblogdoctype"));
        }

        // Check if user is authorized to manage
        isAuthorized = currentUser.IsAuthorizedPerResource("CMS.Blog", "Manage") || (currentUser.IsAuthorizedPerClassName("cms.blog", "Manage", CMSContext.CurrentSiteName) &&
                                                                                     currentUser.IsAuthorizedPerClassName("cms.blogpost", "Manage", CMSContext.CurrentSiteName));

        // Register grid events
        gridBlogs.OnExternalDataBound += gridBlogs_OnExternalDataBound;
        gridBlogs.OnDataReload += gridBlogs_OnDataReload;
        gridBlogs.ShowActionsMenu = true;
        gridBlogs.Columns = "BlogID, ClassName, BlogName, NodeID, DocumentCulture, NodeOwner, BlogModerators";

        // Get all possible columns to retrieve
        IDataClass nodeClass = DataClassFactory.NewDataClass("CMS.Tree");
        DocumentInfo di = new DocumentInfo();
        BlogInfo bi = new BlogInfo();
        gridBlogs.AllColumns = SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(SqlHelperClass.MergeColumns(bi.ColumnNames), SqlHelperClass.MergeColumns(di.ColumnNames)), SqlHelperClass.MergeColumns(nodeClass.ColumnNames));

        // Get ClassID of the 'cms.blogpost' class
        DataClassInfo dci = DataClassInfoProvider.GetDataClass("cms.blogpost");
        string classId = "";
        string script = "";

        if (dci != null)
        {
            classId = dci.ClassID.ToString();
        }

        // Get script to redirect to new blog post page
        script += "function NewPost(parentId, culture) { \n";
        script += "     if (parentId != 0) { \n";
        script += "         parent.parent.parent.location.href = \"" + ResolveUrl("~/CMSDesk/default.aspx") + "?section=content&action=new&nodeid=\" + parentId + \"&classid=" + classId + "&culture=\" + culture;";
        script += "}} \n";

        // Generate javascript code
        ltlScript.Text = ScriptHelper.GetScript(script);
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:49,代码来源:MyBlogs_Blogs_List.aspx.cs


注:本文中的CurrentUserInfo.IsAuthorizedPerClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。