Exemplo n.º 1
0
        /// <summary>
        ///     Called to write save audit log entries.
        /// </summary>
        /// <param name="success">if set to <c>true</c> [success].</param>
        /// <param name="accessRuleDetails">The role details.</param>
        protected override void OnWriteSaveAuditLogEntries(bool success, AuditLogRoleDetails accessRuleDetails)
        {
            if (accessRuleDetails.IsTemporaryId)
            {
                // Role is being created
                AuditLog.OnCreateUserRole(success, accessRuleDetails.RoleName);
            }

            if (!accessRuleDetails.IsTemporaryId &&
                accessRuleDetails.OldRoleName != accessRuleDetails.RoleName)
            {
                // Name has changed
                AuditLog.OnRenameUserRole(success, accessRuleDetails.OldRoleName, accessRuleDetails.RoleName);
            }

            if (accessRuleDetails.AddedMembers.Count > 0 || accessRuleDetails.RemovedMembers.Count > 0)
            {
                // Role membership has changed
                AuditLog.OnChangeUserRoleMembers(success, accessRuleDetails.RoleName, accessRuleDetails.AddedMembers, accessRuleDetails.RemovedMembers);
            }

            ISet <string> currentRole = new HashSet <string> {
                accessRuleDetails.RoleName
            };

            if (accessRuleDetails.AddedIncludedByRoles.Count > 0)
            {
                foreach (string addedIncludedByRole in accessRuleDetails.AddedIncludedByRoles)
                {
                    // Role membership has changed
                    AuditLog.OnChangeUserRoleMembers(success, addedIncludedByRole, currentRole, new SortedSet <string>());
                }
            }

            if (accessRuleDetails.RemovedIncludedByRoles.Count > 0)
            {
                foreach (string removedIncludedByRole in accessRuleDetails.RemovedIncludedByRoles)
                {
                    // Role membership has changed
                    AuditLog.OnChangeUserRoleMembers(success, removedIncludedByRole, new SortedSet <string>(), currentRole);
                }
            }
        }