private void SaveRecord() { try { _Storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted); foreach (ListViewItem item in lvwStoreGroups.Items) { #region update checked items only, not selected if (item.Checked) { _SelectedItems.Add(item); #region 立即 save IAzManDBUser dbUser = _Storage.GetDBUser(item.SubItems[0].Text); _StoreGroup.CreateStoreGroupMember(dbUser.CustomSid, WhereDefined.Database, _IsMember); #endregion } #endregion } _Storage.CommitTransaction(); } catch (Exception ex) { _Storage.RollBackTransaction(); throw (ex); } }
public void EditUserRole(string owner, string userName, Dictionary <string, List <Role> > applications) { foreach (var apps in applications) { List <Role> UserPermissions = GetUserPermissions(_store.GetDBUser(userName).CustomSid.StringValue, "CATS", apps.Key); UserPermissions = UserPermissions.Except(apps.Value).ToList(); foreach (var item in apps.Value.ToArray()) { _store["CATS"][apps.Key][item.RoleName].CreateAuthorization(_store.GetDBUser(userName).CustomSid, WhereDefined.Database, _store.GetDBUser(userName).CustomSid, WhereDefined.Database, AuthorizationType.Allow, DateTime.Now, DateTime.Now); } foreach (var permission in UserPermissions) { _store["CATS"][apps.Key][permission.RoleName].CreateAuthorization(_store.GetDBUser(userName).CustomSid, WhereDefined.Database, _store.GetDBUser(userName).CustomSid, WhereDefined.Database, AuthorizationType.Deny, DateTime.Now, DateTime.Now); } } }
private void SaveRecord() { _Storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted); foreach (ListViewItem item in lvwStoreGroups.Items) { #region update checked items only, not selected if (item.Checked) { _SelectedItems.Add(item); #region 立即 save IAzManDBUser dbUser = _Storage.GetDBUser(item.SubItems[0].Text); IAzManAuthorization auth = _AuthItem.CreateAuthorization( new SqlAzManSID(dbUser.CustomSid.ToString(), this._CurrentOwnerSidWhereDefined == WhereDefined.Database), this._CurrentOwnerSidWhereDefined, new SqlAzManSID(dbUser.CustomSid.ToString(), true), WhereDefined.Database, AuthorizationType.Neutral, null, null); #endregion } #endregion } _Storage.CommitTransaction(); }
/// <summary> /// Constructor that builds a hierarchical menu based upon authorization right of the user /// in the given store. /// </summary> /// <param name="store">String that represents the store that the menu is built upon.</param> /// <param name="user">User name.</param> /// <param name="baseUrl">Base url for generated menu urls.</param> /// <param name="menuUrl">Base url for menu resolved.</param> /// <param name="displayFullMenu">Whether to display full menu</param> public PemsMenu(string store, string user, string baseUrl, string menuUrl, bool displayFullMenu) { _displayFullMenu = displayFullMenu; _storage = new SqlAzManStorage(connectionString: ConfigurationManager.ConnectionStrings[Constants.Security.RbacConnectionStringName].ConnectionString); _dbUser = _storage.GetDBUser(user); _baseUrl = baseUrl; _store = store; _menuUrl = menuUrl; // Create the menu GetMenu(); }
protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } IPrincipal user = httpContext.User; if (!user.Identity.IsAuthenticated) { return(false); } AuthorizationType authorization = AzManStore.CheckAccess(Store, Application.ToString().Replace('_', ' '), Item.ToString().Replace('_', ' '), AzManStore.GetDBUser(User), DateTime.Now, false, null); if (authorization == AuthorizationType.Allow || authorization == AuthorizationType.AllowWithDelegation) { return(true); } else { return(false); } }