private void CheckUnitPermission(AUOperationType opType, string permissionName, AdminUnit unit) { unit.NullCheck("unit"); if (unit.Status != SchemaObjectStatus.Normal) { throw new AUStatusCheckException(unit, opType); } if (this._NeedCheckPermissions) { if (unit == null || unit.Status != SchemaObjectStatus.Normal) { throw new ArgumentException(string.Format("不存在参数 unit 指定的管理单元", "unit")); } if (DeluxePrincipal.Current.HasPermissions(permissionName, new string[] { unit.ID }) == false) { //如果没有权限,检查是否超级管理员或者拥有架构权限 if (AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current) == false) { var schema = unit.GetUnitSchema(); if (string.IsNullOrEmpty(schema.MasterRole) || DeluxePrincipal.Current.IsInRole(schema.MasterRole) == false) { throw CreateAclException(opType, unit.Schema, permissionName); } } } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); bool isSuperVisior = AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current); this.lnkSysMan.Visible = isSuperVisior; }
private bool IsASuperVisior() { bool enabled = AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current); if (enabled == false) { if (string.IsNullOrEmpty(Schema.MasterRole) == false) { enabled = DeluxePrincipal.Current.IsInRole(this.Schema.MasterRole); } } return(enabled); }
public static ValidationResult DoClientValidation(string schemaID, string parentID, string name, string codeName) { ValidationResult result = new ValidationResult(); ValidateCodeName(codeName, parentID, result); if (result.Passed) { var schema = (AU.AUSchema)AU.Adapters.AUSnapshotAdapter.Instance.LoadAUSchema(schemaID, true, DateTime.MinValue).FirstOrDefault(); SchemaObjectBase targetUnit = null; if (schema == null) { result.Passed = false; result.TargetValidationResult = "管理架构不存在或已删除"; } else { bool hasPermission; hasPermission = AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current) || (string.IsNullOrEmpty(schema.MasterRole) == false && DeluxePrincipal.Current.IsInRole(schema.MasterRole)); if (parentID == schemaID || parentID == null) { targetUnit = schema; } else { targetUnit = AUCommon.DoDbProcess(() => (AdminUnit)PC.Adapters.SchemaObjectAdapter.Instance.Load(parentID)); if (hasPermission == false) { hasPermission = CheckAddSubPermission(schema, (AdminUnit)targetUnit); } } result.Passed &= hasPermission; result.TargetValidationResult = hasPermission ? "通过" : "没有在目标添加子单元的权限"; if (result.Passed) { ValidateName(name, codeName, result, schema, targetUnit); } } } return(result); }
public override void ProcessRequest(HttpContext context) { if (AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current) == false) { context.Response.Redirect("~/Default.aspx"); } else { if (context.Request.QueryString["action"] == "genSnapshot") { context.Server.ScriptTimeout = 60 * 60; AUCommon.DoDbAction(() => SCSnapshotBasicAdapter.Instance.GenerateAllSchemaSnapshot()); context.Response.ContentType = "image/gif"; context.Response.WriteFile("~/images/ajax-loader2.gif"); } else { base.ProcessRequest(context); } } }
protected override bool IsCreateEnabled() { return(AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current)); }
private static bool IsSupervisior() { return(AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current)); }