Chat with us, powered by LiveChat Lab # 7 ? part 2 - DATABASE AUDITING (lab) This lab has been tested in Oracle 10g express. ?You may copy an - Writeedu

Lab # 7 ? part 2 – DATABASE AUDITING (lab) This lab has been tested in Oracle 10g express. ?You may copy an

Lab # 7 part 2 – DATABASE AUDITING (lab)

This lab has been tested in Oracle 10g express.  You may copy and paste directly from this file. Note that if you need to edit this file, it is better to do so in NOTEPAD (copy & paste it to notepad),  word sometimes puts in characters that Oracle will not recognize it.  Also, note that as you copy & paste the stored procedures and triggers, you may need to copy & paste everything except for the slash and then paste the slash. Your job is to create an audit table in MS-SQL Server. Then create a trigger that puts data into the table. Then issue the command that will activate the trigger. You can translate some of the triggers in this assignment, copy and paste triggers from the web-site or create your own trigger. Regardless, your deliverable should be: a small text in English explaining what the trigger is doing and why is it useful, the Audit table, the Trigger, the command that execute the trigger.

Part  0 – only if you are doing it on a newly installed version

— Open an SQL window. Create a user & grant the user dba privileges. Example:

CREATE  USER  cit540 IDENTIFIED BY  c; 

GRANT  DBA   TO  cit540;  – In SQL Server, you grant all privileges to this user through login/security

— Create another user and grant this user create session privileges. Example:

CREATE  USER   smith  IDENTIFIED  BY  s;

GRANT    CREATE  SESSION   TO  smith;

Part  1 – audit login and logout

— Login as the user CIT540 with dba privileges 

CONNECT  cit540/c;

— Create a table to keep track of user login and logoff  

CREATE TABLE  login_logoff

(

      USERIDVARCHAR2(30),

      SESSIONIDNUMBER(8),

      HOSTVARCHAR2(30),

      LOGIN_DAYDATE,

      LOGIN_TIME            VARCHAR2(10),

      LOGOUT_DAYDATE,

     LOGOUT_TIME         VARCHAR2(10)

);

/

— Create a trigger that will insert a row in the login_logoff table every time user logs in

CREATE OR REPLACE TRIGGER

     audit_login

AFTER  LOGON  ON  DATABASE

BEGIN

INSERT  INTO  login_logoff  values (

         USER,

         sys_context ('USERENV','SESSIONID'),          

​  sys_context ('USERENV','HOST'),

                          sysdate,

                          to_char(sysdate, 'hh24:mi:ss'),

                          null,

                          null  );

                 COMMIT;

                 END;          

/

— Create a trigger that will insert data in a row in the login_logoff table every time user logs out

CREATE OR REPLACE TRIGGER

    audit_logoff

BEFORE  LOGOFF ON DATABASE

BEGIN

  UPDATE  login_logoff

  SET

    logout_day = sysdate, logout_time=to_char(sysdate,'hh24:mi:ss')

WHERE

  sys_context('USERENV','SESSIONID')=sessionid;

END;

/

–Do not close your  SQL session. Open another SQL window and login as the user that does — not have dba privilege.

connect  smith/s; 

— leave the SQL session

Exit;

— connect as administrator (in this example, cit540

Connect  cit540/c;

— From the user CIT540 session that does have DBA privileges, verify the login

SELECT USERID, SESSIONID, HOST, LOGIN_DAY, LOGIN_TIME FROM LOGIN_LOGOFF;

Display. Your results.  Howe many rows did you see ?

You should see something like (but with CIT540 and Smith) :

Logout and type in:

SELECT  *  FROM  LOGIN_LOGOFF;

—————————————–

Creating Audit table and Audit Trigger

You will copy and paste everything that is in green. Deliverable: Screenshots of query with results.

1) get current date and current user

select  getDate();

select  suser_sname();

2) Create an audit table

CREATE TABLE UpdateProductAudit (date_updated  date,  who  varchar(50));

3) Create a trigger that inserts a row into the AuditProductChanges every time the Products table is updated

create trigger AuditProductChanges on Products

after update

as

begin

insert into dbo.UpdateProductAudit values(getDate(), suser_sname()); 

end

go

4) udate the Products table

UPDATE Products set quantity = quantity * 1.1;

5) view the update in the audit table

SELECT * from dbo.UdateProductAudit;

6) Do the exercises in the link below. Your professor will discuss the link in class.

https://www.mssqltips.com/sqlservertip/4055/create-a-simple-sql-server-trigger-to-build-an-audit-trail/

Submit the screenshots of the results. Create the table inside your own database. Alter each table name and trigger name to have your initials.  Consequently , you also need to order each reference to the table to have your initials also.

7) Go to https://docs.microsoft.com/en-us/sql/relational-databases/security/auditing/create-a-server-audit-and-database-audit-specification?view=sql-server-2017

And create a server audit specification (either in SSMS or SQL)

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteEdu. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

Do you need help with this question?

Get assignment help from WriteEdu.com Paper Writing Website and forget about your problems.

WriteEdu provides custom & cheap essay writing 100% original, plagiarism free essays, assignments & dissertations.

With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.

Chat with us today! We are always waiting to answer all your questions.

Click here to Place your Order Now