本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}