// Bld 5, remote office where satallite link is

USE [master]
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'P@ssw0rd'


/****** Object:  Database [Maintenance]    Script Date: 10/26/2005 11:19:17 ******/
IF  EXISTS (SELECT name FROM sys.databases WHERE name = N'Equipment')
DROP DATABASE Equipment
GO

CREATE DATABASE Equipment
GO

ALTER DATABASE Equipment
SET ENABLE_BROKER
GO
ALTER DATABASE Equipment
SET RECOVERY SIMPLE
GO
-- must be trustworthy to communicate with others
ALTER DATABASE Equipment
SET TRUSTWORTHY ON

--DROP CERTIFICATE [Bld5]

// needs cert in master to be able to authenticate by cert
CREATE CERTIFICATE [Bld5]
WITH SUBJECT = 'Bld 5'
GO

// save the public version for others to use
BACKUP CERTIFICATE [Bld5] 
TO FILE = 'C:\Bld5.crt'

// need endpoint based on cert auth
CREATE ENDPOINT [Bld5 EP]
STATE = STARTED
AS TCP (LISTENER_PORT = 5700)
FOR SERVICE_BROKER (AUTHENTICATION = CERTIFICATE [Bld5])
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

-- need login and user for to work with Parker Street
CREATE LOGIN [ParkerStreet] WITH PASSWORD = 'P@ssw0rd'

CREATE USER [ParkerStreet]

CREATE CERTIFICATE [ParketStreetPubCert] AUTHORIZATION [ParkerStreet]
FROM FILE = 'C:\ParkerStreet.crt'

GRANT CONNECT ON ENDPOINT::[Bld5 EP]
TO [ParkerStreet]
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


use [Equipment]

CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'P@ssw0rd'

CREATE USER [ParkerStreet]


// Inspection team
CREATE MESSAGE TYPE MsgT1 VALIDATION = NONE
CREATE CONTRACT Con1 (MsgT1 SENT BY ANY)


CREATE 
--DROP
QUEUE [Inspection Queue]

CREATE 
--DROP
SERVICE [Inspection Team]
ON QUEUE [Inspection Queue]
([DEFAULT])

CREATE ROUTE Inspection
WITH SERVICE_NAME = 'Central Maintenance',
ADDRESS = N'TCP://ParkerSt:5700'


CREATE USER Inspector
WITHOUT LOGIN

CREATE CERTIFICATE InspectorCert
Authorization Inspector
FROM FILE = 'C:\InspectorPub.crt'



CREATE 
--DROP
CERTIFICATE InspectorCert
AUTHORIZATION Inspector
FROM FILE = 'C:\ParkerStreet.crt'

CREATE REMOTE SERVICE BINDING PKStreet
TO SERVICE 'Central Maintenance'
WITH USER = Inspector;



