Wwi update (#255)

Awesome update!
This commit is contained in:
Jos de Bruijn
2017-06-28 14:48:06 -07:00
committed by Perry Skountrianos
parent ee01508b0b
commit 58bd2e8d2c
397 changed files with 147397 additions and 75539 deletions
@@ -29,6 +29,7 @@ GO
-- 1a. In Object Explorer, expand the security node in WideWorldImporters, then expand
-- the Always Encrypted Keys node and note the contents.
-- If you do not see the Always Encrypted node, install the latest version of Management Studio (17.X or higher): https://aka.ms/ssms
-- 1b. Right-click the Column Master Keys node and click New Column Master Key.
-- 1c. For the name, enter WWI_ColumnMasterKey.
-- 1d. Note the available entries in the Key store dropdown list. Choose Windows Certificate Store - Current User.
@@ -78,6 +78,7 @@ GO
GRANT SELECT, UPDATE ON Sales.Customers TO [Great Lakes Sales];
GRANT SELECT ON [Application].Cities TO [Great Lakes Sales];
GRANT SELECT ON [Application].StateProvinces TO [Great Lakes Sales];
GRANT SELECT ON [Application].Countries TO [Great Lakes Sales];
GO
@@ -94,20 +95,37 @@ GO
-- where are those customers?
-- note the spatial results tab
SELECT c.Border
SELECT c.Border
FROM [Application].Countries AS c
WHERE c.CountryName = N'United States'
UNION ALL
SELECT c.DeliveryLocation
FROM Sales.Customers AS c;
SELECT c.DeliveryLocation
FROM Sales.Customers AS c
GO
-----------------------------------------------------------------------
-- updating rows that are accessible to a non-accessible row is blocked
-----------------------------------------------------------------------
DECLARE @GreatLakesCustomerID INT
DECLARE @NonGreatLakesCityID INT
UPDATE Sales.Customers -- Attempt to update
SET DeliveryCityID = 3 -- to a city that is not in the Great Lakes Sales Territory
WHERE DeliveryCityID = 32887; -- for a customer that is in the Great Lakes Sales Territory
-- pick a customer in the Great Lakes sales territory
SELECT TOP 1 @GreatLakesCustomerID=c.CustomerID
FROM Sales.Customers c JOIN Application.Cities ci ON c.DeliveryCityID=ci.CityID
JOIN Application.StateProvinces sp ON ci.StateProvinceID=sp.StateProvinceID
WHERE sp.SalesTerritory=N'Great Lakes'
-- pick a City outside of the Great Lakes sales territory
SELECT @NonGreatLakesCityID=c.CityID
FROM Application.Cities c JOIN Application.StateProvinces sp ON c.StateProvinceID=sp.StateProvinceID
WHERE CityName=N'Seattle' AND sp.StateProvinceCode=N'WA'
UPDATE Sales.Customers -- Attempt to update
SET DeliveryCityID = @NonGreatLakesCityID -- to a city that is not in the Great Lakes Sales Territory
WHERE CustomerID = @GreatLakesCustomerID; -- for a customer that is in the Great Lakes Sales Territory
GO
-- revert the impersonation
REVERT;
GO
@@ -133,9 +151,6 @@ REVOKE SELECT ON [Application].Cities FROM [Website];
REVOKE SELECT ON [Application].Countries FROM [Website];
GO
EXEC [Application].Configuration_RemoveRowLevelSecurity;
GO
DROP USER GreatLakesUser;
GO