10. April 2012 10:59
10. April 2012 11:35
10. April 2012 11:47
10. April 2012 11:48
Timo Lässer hat geschrieben:Hallo neocortex2001,
zuerst einmal herzlich Willkommen in unserer Community.
Ich hoffe, du hattest ein angenehmes Osterfest.
Zu deiner Frage:
Ob es eine Möglichkeit gibt, die Änderungen SQL-seitig zu protokollieren, und wenn ja, wie, weiß ich leider nicht.
Du könntest jedoch innerhalb von NAV das Änderungsprotokoll auf die Tabellen aktivieren, dann siehst du in den Änderungsprotokollposten, wer wann was von welchem Wert auf welchen Wert geändert bzw. eingefügt oder gelöscht hat.
10. April 2012 12:48
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Volker Strähle
-- Create date: 10.04.2012
-- Description: Logging Of PermissionCahnges
--
-- Script for LogginTable
/* CREATE TABLE [dbo].[PermissionLog](
[RoleID] [varchar](20) NOT NULL,
[ObjectType] [int] NOT NULL,
[ObjectID] [int] NOT NULL,
[ReadPermission] [int] NOT NULL,
[InsertPermission] [int] NOT NULL,
[ModifyPermission] [int] NOT NULL,
[DeletePermission] [int] NOT NULL,
[ExecutePermission] [int] NOT NULL,
[SecurityFilter] [varbinary](252) NOT NULL,
[ExecutingUser] [nvarchar](255)) */
-- =============================================
CREATE TRIGGER LoggingChangesOnPerm
ON dbo.Permission
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;
declare @navuser as nvarchar(255);
declare @RoleID as varchar(20), @Objecttype as Int, @ObjectID as Int, @ReadPermission as Int,
@InsertPermission as Int, @ModifyPermission as Int,
@DeletePermission as Int, @ExecutePermission as Int, @SecurityFilter as Int;
set @navuser=CURRENT_USER
DECLARE Log_Cursor CURSOR FOR
SELECT INSERTED.[Role ID] as RoleID, INSERTED.[Object Type] as Objecttype, INSERTED.[Object ID] as ObjectID, INSERTED.[Read Permission] as ReadPermission,
INSERTED.[Insert Permission] as InsertPermission, INSERTED.[Modify Permission] as ModifyPermission,
INSERTED.[Delete Permission] as DeletePermission, INSERTED.[Execute Permission] as ExecutePermission, INSERTED.[Security Filter] as SecurityFilter
FROM INSERTED;
OPEN Log_Cursor;
FETCH NEXT FROM Item_Cursor into @RoleID, @Objecttype, @ObjectID, @ReadPermission,
@InsertPermission, @ModifyPermission, @DeletePermission, @ExecutePermission, @SecurityFilter;
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO PERMISSIONLOG(RoleID, Objecttype, ObjectID, ReadPermission,
InsertPermission, ModifyPermission, DeletePermission, ExecutePermission, SecurityFilter, ExecutingUser) VALUES (@RoleID, @Objecttype, @ObjectID, @ReadPermission,
@InsertPermission, @ModifyPermission, @DeletePermission, @ExecutePermission, @SecurityFilter, @navuser);
FETCH NEXT FROM Item_Cursor into @RoleID, @Objecttype, @ObjectID, @ReadPermission,
@InsertPermission, @ModifyPermission, @DeletePermission, @ExecutePermission, @SecurityFilter;
END;
CLOSE Log_Cursor;
DEALLOCATE Log_Cursor;
END
GO