home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
WindowsServerTrial
/
server.iso
/
sources
/
install.wim
/
1
/
Windows
/
System32
/
azroles.dll
/
FILE
/
102
next >
Wrap
Text File
|
2008-01-19
|
31KB
|
1,107 lines
CREATE TABLE [dbo].[AzMan_AzApplicationGroup] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[ObjectGuid] [uniqueidentifier] NULL,
[StoreID] [int] ,
[AppID] [int] ,
[ScopeID] [int] ,
[ParentType] [tinyint] NOT NULL ,
[Name] [nvarchar] (64) ,
[Description] [nvarchar] (1024) ,
[ApplicationData] [ntext] ,
[GroupType] [tinyint] NULL,
[LdapQueryID] [int] NULL,
[RowUpdateTimeStamp] [timestamp] NULL ,
[ChildUpdateTimeStamp] [binary] (8) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_AzAuthorizationStore] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[ObjectGuid] [uniqueidentifier] NULL,
[Description] [nvarchar] (1024) ,
[Name] [nvarchar] (512) ,
[ApplicationData] [ntext] ,
[DomainTimeout] [int] NULL ,
[ScriptEngineTimeout] [int] NULL ,
[MaxScriptEngines] [int] NULL ,
[TargetMachine] [nvarchar] (50) ,
[ApplyStoreSacl] [bit] NULL ,
[GenerateAudits] [bit] NULL ,
[MajorVersion] [int] NULL,
[MinorVersion] [int] NULL,
[RowUpdateTimeStamp] [timestamp] NULL ,
[ChildUpdateTimeStamp] [binary] (8) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_AzApplication] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[ObjectGuid] [uniqueidentifier] NULL,
[StoreID] [int] NOT NULL ,
[Name] [nvarchar] (512) ,
[Description] [nvarchar] (1024) ,
[ApplicationData] [ntext] ,
[ApplyStoreSacl] [bit] NULL ,
[GenerateAudits] [bit] NULL ,
[AuthzInterfaceClsId] [int] NULL ,
[ApplicationVersion] [nvarchar] (50),
[RowUpdateTimeStamp] [timestamp] NULL ,
[ChildUpdateTimeStamp] [binary] (8) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_BizRule_To_Task] (
[BizRuleID] [int] NOT NULL ,
[TaskID] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_BizRule_To_Group] (
[BizRuleID] [int] NOT NULL ,
[GroupID] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_BizRule] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[ParentId] [int] NOT NULL ,
[ParentType] [tinyint] not NULL,
[BizRuleImportedPath] [nvarchar] (512) ,
[BizRule] [ntext] ,
[BizRuleLanguage] [nvarchar] (64),
[RowUpdateTimeStamp] [timestamp] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_LDAPQuery] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[GroupID] [int] NOT NULL ,
[LdapQuery] [ntext] ,
[RowUpdateTimeStamp] [timestamp] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_Group_SIDMember] (
[GroupID] [int] NOT NULL ,
[MemberSID] [varbinary] (85) NOT NULL ,
[Member] [bit] Not NULL ,
[RowUpdateTimeStamp] [timestamp] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_Group_AppMember] (
[GroupID] [int] NOT NULL ,
[ChildID] [int] NOT NULL ,
[Member] [bit] Not NULL ,
[RowUpdateTimeStamp] [timestamp] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_AzOperation] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[ObjectGuid] [uniqueidentifier] NULL,
[AppID] [int] NOT NULL ,
[Name] [nvarchar] (64) ,
[Description] [nvarchar] (1024) ,
[ApplicationData] [ntext] ,
[OperationID] [int] NULL,
[RowUpdateTimeStamp] [timestamp] NULL ,
[ChildUpdateTimeStamp] [binary] (8) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_AzTask] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[ObjectGuid] [uniqueidentifier] NULL,
[AppID] [int],
[ScopeID] [int],
[ParentType] [tinyint] NOT NULL ,
[Name] [nvarchar] (64) ,
[Description] [nvarchar] (1024) ,
[ApplicationData] [ntext] ,
[IsRoleDefinition] [bit] NULL ,
[RowUpdateTimeStamp] [timestamp] NULL ,
[ChildUpdateTimeStamp] [binary] (8) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_AzScope] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[AppID] [int] NOT NULL ,
[Name] [ntext],
[NameLen] [int] NOT NULL,
[NameHash] [Binary] (32) NULL,
[Description] [nvarchar] (1024) ,
[ApplicationData] [ntext] ,
[ObjectGuid] [uniqueidentifier] NULL,
[RowUpdateTimeStamp] [timestamp] NULL ,
[ChildUpdateTimeStamp] [binary] (8) NULL,
[HasSpecificUsers] [bit] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_AzRoleAssignment] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[AppID] [int],
[ScopeID] [int],
[ParentType] [tinyint] NOT NULL ,
[Name] [nvarchar] (64) ,
[Description] [nvarchar] (1024) ,
[ApplicationData] [ntext] ,
[ObjectGuid] [uniqueidentifier] NULL ,
[RowUpdateTimeStamp] [timestamp] NULL ,
[ChildUpdateTimeStamp] [binary] (8) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_Role_SIDMember] (
[RoleID] [int] NOT NULL ,
[MemberSID] [varbinary] (85) NOT NULL,
[RowUpdateTimeStamp] [timestamp] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_Role_AppMember] (
[RoleID] [int] NOT NULL ,
[ChildID] [int] NOT NULL ,
[RowUpdateTimeStamp] [timestamp] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_Role_To_Task_Link] (
[TaskID] [int] NOT NULL ,
[RoleID] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_Role_To_Operation_Link] (
[OperationID] [int] NOT NULL ,
[RoleID] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_Task_To_Task_Link] (
[TaskID] [int] NOT NULL ,
[ChildID] [int] NOT NULL
) ON [PRIMARY]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Azman_SQLRole]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Azman_SQLRole]
GO
CREATE TABLE [dbo].[Azman_SQLRole] (
[uid] [int] not null,
[ObjectID] [int] NULL ,
[ObjectType] [tinyint] NULL ,
[SQLRoleName] [nvarchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[RoleType] [tinyint] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[AzMan_Task_To_Operation_Link] (
[OperationID] [int] NOT NULL ,
[TaskID] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzApplication_StoreID] ON [dbo].[AzMan_AzApplication]([StoreId]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzApplicationGroup_AppID] ON [dbo].[AzMan_AzApplicationGroup]([AppID]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzApplicationGroup_ScopeID] ON [dbo].[AzMan_AzApplicationGroup]([ScopeID]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzApplicationGroup_Name] ON [dbo].[AzMan_AzApplicationGroup]([Name]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzOperation_Name] ON [dbo].[AzMan_AzOperation]([Name]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzOperation_AppID] ON [dbo].[AzMan_AzOperation]([AppID]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzRoleAssignment_AppID] ON [dbo].[AzMan_AzRoleAssignment]([AppID]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzRoleAssignment_ScopeID] ON [dbo].[AzMan_AzRoleAssignment]([ScopeID]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzRoleAssignment_Name] ON [dbo].[AzMan_AzRoleAssignment]([Name]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzScope_AppID] ON [dbo].[AzMan_AzScope]([AppID]) ON [PRIMARY]
GO
CREATE INDEX [IX_Azman_Scope_Name] ON [dbo].[AzMan_AzScope] ([AppID], [NameHash]) ON [PRIMARY]
Go
CREATE INDEX [IX_AzMan_AzTask_AppID] ON [dbo].[AzMan_AzTask]([AppID]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzTask_ScopeID] ON [dbo].[AzMan_AzTask]([ScopeID]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_AzTask_Name] ON [dbo].[AzMan_AzTask]([Name]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_BizRule_Parent] ON [dbo].[AzMan_BizRule]([ParentId], [ParentType]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_Group_AppMember_GroupID] ON [dbo].[AzMan_Group_AppMember]([GroupId]) ON [PRIMARY]
GO
CREATE INDEX [IX_AzMan_LDAPQuery_GroupID] ON [dbo].[AzMan_LDAPQuery]([GroupID]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_AzApplication] WITH NOCHECK ADD
CONSTRAINT [PK_AzMan_AzApplication] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_AzAuthorizationStore] WITH NOCHECK ADD
CONSTRAINT [PK_AzMan_AzAuthorizationStore] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_AzScope] WITH NOCHECK ADD
CONSTRAINT [PK_AzMan_AzScope] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_AzApplicationGroup] WITH NOCHECK ADD
CONSTRAINT [PK_AzMan_AzApplicationGroup] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY] ,
CONSTRAINT [FK_AzMan_AzAppGroup_AzMan_AzApplication] FOREIGN KEY
(
[AppID]
) REFERENCES [dbo].[AzMan_AzApplication] (
[ID]
) ,
CONSTRAINT [FK_AzMan_AzAppGroup_AzMan_AzAuthorizationStore] FOREIGN KEY
(
[StoreID]
) REFERENCES [dbo].[AzMan_AzAuthorizationStore] (
[ID]
) ,
CONSTRAINT [FK_AzMan_AzAppGroup_AzMan_AzScope] FOREIGN KEY
(
[ScopeID]
) REFERENCES [dbo].[AzMan_AzScope] (
[ID]
)
GO
ALTER TABLE [dbo].[AzMan_AzApplicationGroup] WITH NOCHECK ADD
CONSTRAINT [CK_AzMan_AzApplicationGroup] CHECK (sign(coalesce([StoreID],0)) + sign(coalesce([AppID],0)) + sign(coalesce([ScopeID],0)) = 1)
GO
ALTER TABLE [dbo].[AzMan_AzRoleAssignment] WITH NOCHECK ADD
CONSTRAINT [CK_AzMan_AzRoleAssignment] CHECK (sign(coalesce([AppID],0)) + sign(coalesce([ScopeID],0)) = 1)
GO
ALTER TABLE [dbo].[AzMan_AzTask] WITH NOCHECK ADD
CONSTRAINT [CK_AzMan_AzTask] CHECK (sign(coalesce([AppID],0)) + sign(coalesce([ScopeID],0)) = 1)
GO
alter table [dbo].[AzMan_AzApplicationGroup] nocheck constraint [FK_AzMan_AzAppGroup_AzMan_AzApplication]
GO
alter table [dbo].[AzMan_AzApplicationGroup] nocheck constraint [FK_AzMan_AzAppGroup_AzMan_AzAuthorizationStore]
GO
alter table [dbo].[AzMan_AzApplicationGroup] nocheck constraint [FK_AzMan_AzAppGroup_AzMan_AzScope]
GO
ALTER TABLE [dbo].[AzMan_AzOperation] WITH NOCHECK ADD
CONSTRAINT [PK_AzMan_AzOperation] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_AzRoleAssignment] WITH NOCHECK ADD
CONSTRAINT [PK_AzMan_AzRoleAssignment] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY] ,
CONSTRAINT [FK_AzMan_Role_To_App] FOREIGN KEY
(
[AppID]
) REFERENCES [dbo].[AzMan_AzApplication] (
[ID]
) ,
CONSTRAINT [FK_AzMan_Role_To_Scope] FOREIGN KEY
(
[ScopeID]
) REFERENCES [dbo].[AzMan_AzScope] (
[ID]
)
GO
alter table [dbo].[AzMan_AzRoleAssignment] nocheck constraint [FK_AzMan_Role_To_App]
GO
alter table [dbo].[AzMan_AzRoleAssignment] nocheck constraint FK_AzMan_Role_To_Scope
GO
ALTER TABLE [dbo].[AzMan_AzTask] WITH NOCHECK ADD
CONSTRAINT [PK_AzMan_AzTask] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY] ,
CONSTRAINT [FK_AzMan_AzTask_To_App] FOREIGN KEY
(
[AppID]
) REFERENCES [dbo].[AzMan_AzApplication] (
[ID]
) ,
CONSTRAINT [FK_AzMan_AzTask_To_Scope] FOREIGN KEY
(
[ScopeID]
) REFERENCES [dbo].[AzMan_AzScope] (
[ID]
)
GO
alter table [dbo].[AzMan_AzTask] nocheck constraint [FK_AzMan_AzTask_To_App]
GO
alter table [dbo].[AzMan_AzTask] nocheck constraint [FK_AzMan_AzTask_To_Scope]
GO
ALTER TABLE [dbo].[AzMan_BizRule] WITH NOCHECK ADD
CONSTRAINT [PK_AzMan_BizRule] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_LDAPQuery] WITH NOCHECK ADD
CONSTRAINT [PK_AzMan_LDAPQuery] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_AzOperation] WITH NOCHECK ADD
CONSTRAINT [IX_AzMan_AzOperation_OpID] UNIQUE NONCLUSTERED
(
[OperationID],
[AppID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Group_AppMember] WITH NOCHECK ADD
CONSTRAINT [IX_AzMan_Group_AppMember_member] UNIQUE NONCLUSTERED
(
[GroupID],
[ChildID],
[Member]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Group_SIDMember] WITH NOCHECK ADD
CONSTRAINT [IX_AzMan_Group_SIDMember_member] UNIQUE NONCLUSTERED
(
[GroupID],
[MemberSID],
[Member]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Role_AppMember] WITH NOCHECK ADD
CONSTRAINT [IX_AzMan_Role_AppMember_member] UNIQUE NONCLUSTERED
(
[RoleID],
[ChildID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Role_SIDMember] WITH NOCHECK ADD
CONSTRAINT [IX_AzMan_Role_SIDMember_member] UNIQUE NONCLUSTERED
(
[RoleID],
[MemberSID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_AzApplication] ADD
CONSTRAINT [FK_AzMan_AzApplication_AzMan_AzAuthorizationStore] FOREIGN KEY
(
[StoreID]
) REFERENCES [dbo].[AzMan_AzAuthorizationStore] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[AzMan_AzOperation] ADD
CONSTRAINT [FK_AzMan_AzOperation_AzMan_AzApplication] FOREIGN KEY
(
[AppID]
) REFERENCES [dbo].[AzMan_AzApplication] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[AzMan_AzScope] ADD
CONSTRAINT [FK_AzMan_AzScope_AzMan_AzApplication] FOREIGN KEY
(
[AppID]
) REFERENCES [dbo].[AzMan_AzApplication] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[AzMan_BizRule_To_Group] ADD
CONSTRAINT [FK_AzMan_BizRule_To_Group_AzMan_AzApplicationGroup] FOREIGN KEY
(
[GroupID]
) REFERENCES [dbo].[AzMan_AzApplicationGroup] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [FK_AzMan_BizRule_To_Group_AzManBizrule] FOREIGN KEY
(
[BizRuleID]
) REFERENCES [dbo].[AzMan_BizRule] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [PK_AzMan_BizRule_To_Group] PRIMARY KEY CLUSTERED
(
[BizRuleID],
[GroupID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_BizRule_To_Task] ADD
CONSTRAINT [FK_AzMan_BizRule_To_Task_AzMan_AzTask] FOREIGN KEY
(
[TaskID]
) REFERENCES [dbo].[AzMan_AzTask] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [FK_AzMan_BizRule_To_Task_AzManBizrule] FOREIGN KEY
(
[BizRuleID]
) REFERENCES [dbo].[AzMan_BizRule] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [PK_AzMan_BizRule_To_Task] PRIMARY KEY CLUSTERED
(
[BizRuleID],
[TaskID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Group_AppMember] ADD
CONSTRAINT [FK_AzMan_Group_AppMember_AzMan_AzApplicationGroup] FOREIGN KEY
(
[GroupID]
) REFERENCES [dbo].[AzMan_AzApplicationGroup] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [PK_AzMan_Group_AppMember] PRIMARY KEY CLUSTERED
(
[GroupID],
[ChildID],
[Member]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Group_SIDMember] ADD
CONSTRAINT [FK_AzMan_Group_SIDMember_AzMan_AzApplicationGroup] FOREIGN KEY
(
[GroupID]
) REFERENCES [dbo].[AzMan_AzApplicationGroup] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [PK_AzMan_Group_SIDMember] PRIMARY KEY CLUSTERED
(
[GroupID],
[MemberSID],
[Member]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_LDAPQuery] ADD
CONSTRAINT [FK_AzMan_LDAPQuery_AzMan_AzApplicationGroup] FOREIGN KEY
(
[GroupID]
) REFERENCES [dbo].[AzMan_AzApplicationGroup] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE
GO
ALTER TABLE [dbo].[AzMan_Role_AppMember] ADD
CONSTRAINT [FK_AzMan_Role_AppMember_AzMan_AzRoleAssignment] FOREIGN KEY
(
[RoleID]
) REFERENCES [dbo].[AzMan_AzRoleAssignment] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [PK_AzMan_Role_AppMember] PRIMARY KEY CLUSTERED
(
[RoleID],
[ChildID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Role_SIDMember] ADD
CONSTRAINT [FK_AzMan_Role_SIDMember_AzMan_AzRoleAssignment] FOREIGN KEY
(
[RoleID]
) REFERENCES [dbo].[AzMan_AzRoleAssignment] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [PK_AzMan_Role_SIDMember] PRIMARY KEY CLUSTERED
(
[RoleID],
[MemberSID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Role_To_Operation_Link] ADD
CONSTRAINT [FK_AzMan_Role_To_Operation_Link_AzMan_AzOperation] FOREIGN KEY
(
[OperationID]
) REFERENCES [dbo].[AzMan_AzOperation] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [FK_AzMan_Role_To_Operation_Link_AzMan_AzRoleAssignment] FOREIGN KEY
(
[RoleID]
) REFERENCES [dbo].[AzMan_AzRoleAssignment] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [PK_AzMan_Role_To_Operation_Link] PRIMARY KEY CLUSTERED
(
[RoleID],
[OperationID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Role_To_Task_Link] ADD
CONSTRAINT [FK_AzMan_Role_To_Task_Link_AzMan_AzRoleAssignment] FOREIGN KEY
(
[RoleID]
) REFERENCES [dbo].[AzMan_AzRoleAssignment] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [FK_AzMan_Role_To_Task_Link_AzMan_AzTask] FOREIGN KEY
(
[TaskID]
) REFERENCES [dbo].[AzMan_AzTask] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT [PK_AzMan_Role_To_Task_Link] PRIMARY KEY CLUSTERED
(
[RoleID],
[TaskID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Task_To_Operation_Link] ADD
CONSTRAINT [FK_AzMan_Task_To_Operation_Link_AzMan_AzOperation] FOREIGN KEY
(
[OperationID]
) REFERENCES [dbo].[AzMan_AzOperation] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [FK_AzMan_Task_To_Operation_Link_AzMan_AzTask] FOREIGN KEY
(
[TaskID]
) REFERENCES [dbo].[AzMan_AzTask] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT [PK_AzMan_Task_To_Operation_Link] PRIMARY KEY CLUSTERED
(
[OperationID],
[TaskID]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[AzMan_Task_To_Task_Link] ADD
CONSTRAINT [FK_AzMan_Task_To_Task_Link_AzMan_AzTask] FOREIGN KEY
(
[TaskID]
) REFERENCES [dbo].[AzMan_AzTask] (
[ID]
) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT [PK_AzMan_Task_To_Task_Link] PRIMARY KEY CLUSTERED
(
[TaskID],
[ChildID]
) ON [PRIMARY]
GO
--Trigger for updating Timestamps
CREATE TRIGGER TR_updateStoreTimeStampOnAppDelete ON dbo.[AzMan_AzApplication]
FOR delete
AS
UPDATE [AzMan_AzAuthorizationStore]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT StoreID FROM deleted)
go
CREATE TRIGGER TR_updateStoreTimeStampOnAppModified ON dbo.[AzMan_AzApplication]
FOR INSERT,UPDATE
AS
UPDATE [AzMan_AzAuthorizationStore]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT StoreID FROM inserted)
go
CREATE TRIGGER TR_updateAppTimeStampOnScopeDelete ON dbo.[AzMan_AzScope]
FOR delete
AS
UPDATE [AzMan_AzApplication]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT AppID FROM deleted)
go
CREATE TRIGGER TR_updateAppTimeStampOnScoprModified ON dbo.[AzMan_AzScope]
FOR INSERT,UPDATE
AS
UPDATE [AzMan_AzApplication]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT AppID FROM inserted)
go
CREATE TRIGGER TR_UpdateAppTimeStampOnOpChange ON dbo.[AzMan_AzOperation]
FOR INSERT,UPDATE
AS
UPDATE [AzMan_AzApplication]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT AppID FROM inserted)
go
CREATE TRIGGER TR_UpdateAppTimeStampOnOpDelete ON dbo.[AzMan_AzOperation]
FOR delete
AS
UPDATE [AzMan_AzApplication]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT AppID FROM deleted)
go
Create Procedure UpdateGroupsParentTimeStamp
(
@ParentId [int]
, @ParentType [tinyint]
)
as
if @ParentType = 0
Begin
UPDATE [AzMan_AzAuthorizationStore] SET [ChildUpdateTimeStamp]=@@DBTS WHERE ID=@ParentID
end
else if @ParentType = 1 -- App
Begin
UPDATE [AzMan_AzApplication] SET [ChildUpdateTimeStamp]=@@DBTS WHERE ID=@ParentID
end
else if @ParentType = 4 -- Scope
Begin
UPDATE [AzMan_AzScope] SET [ChildUpdateTimeStamp]=@@DBTS WHERE ID=@ParentID
end
GO
Create Procedure UpdateTasksParentTimeStamp
(
@ParentId [int]
, @ParentType [tinyint]
)
as
if @ParentType = 1 -- App
Begin
UPDATE [AzMan_AzApplication] SET [ChildUpdateTimeStamp]=@@DBTS WHERE ID=@ParentID
end
else if @ParentType = 4 -- Scope
Begin
UPDATE [AzMan_AzScope] SET [ChildUpdateTimeStamp]=@@DBTS WHERE ID=@ParentID
end
GO
Create Procedure UpdateRolesParentTimeStamp
(
@ParentId [int]
, @ParentType [tinyint]
)
as
if @ParentType = 1 -- App
Begin
UPDATE [AzMan_AzApplication] SET [ChildUpdateTimeStamp]=@@DBTS WHERE ID=@ParentID
end
else if @ParentType = 4 -- Scope
Begin
UPDATE [AzMan_AzScope] SET [ChildUpdateTimeStamp]=@@DBTS WHERE ID=@ParentID
end
GO
CREATE TRIGGER TR_UpdateParentTimeStampOnGroupDelete ON dbo.[AzMan_AzApplicationGroup]
FOR delete
AS
DECLARE @ParentID INT
DECLARE @ParentType TinyInt
Declare @StoreID INT
Declare @AppID INT
Declare @ScopeID INT
-- We need to find the parent first
SELECT @StoreID=StoreID, @AppID=AppID, @ScopeID=ScopeID, @ParentType=ParentType FROM deleted
if @@RowCount = 1
Begin
if @ParentType = 0
Begin
set @ParentID = @StoreID
End
else if @ParentType = 1
Begin
set @ParentID = @AppID
End
else if @ParentType = 4
Begin
set @ParentID = @ScopeID
End
exec UpdateGroupsParentTimeStamp @ParentID, @ParentType
End
go
CREATE TRIGGER TR_UpdateParentTimeStampOnGroupInsOrUpd ON dbo.[AzMan_AzApplicationGroup]
FOR INSERT,UPDATE
AS
DECLARE @ParentID INT
DECLARE @ParentType TinyInt
Declare @StoreID INT
Declare @AppID INT
Declare @ScopeID INT
SELECT @StoreID=StoreID, @AppID=AppID, @ScopeID=ScopeID, @ParentType=ParentType FROM inserted
if @@RowCount = 1
Begin
if @ParentType = 0
Begin
set @ParentID = @StoreID
End
else if @ParentType = 1
Begin
set @ParentID = @AppID
End
else if @ParentType = 4
Begin
set @ParentID = @ScopeID
End
exec UpdateGroupsParentTimeStamp @ParentID, @ParentType
End
go
CREATE TRIGGER TR_UpdateParentTimeStampOnTaskDelete ON dbo.[AzMan_AzTask]
FOR delete
AS
DECLARE @ParentID INT
DECLARE @ParentType TinyInt
Declare @AppID INT
Declare @ScopeID INT
-- We need to find the parent first
SELECT @AppID=AppID, @ScopeID=ScopeID, @ParentType=ParentType FROM deleted
if @@RowCount = 1
Begin
if @ParentType = 1
Begin
set @ParentID = @AppID
End
else if @ParentType = 4
Begin
set @ParentID = @ScopeID
End
exec UpdateTasksParentTimeStamp @ParentID, @ParentType
end
go
CREATE TRIGGER TR_UpdateParentTimeStampOnTaskInsOrUpd ON dbo.[AzMan_AzTask]
FOR INSERT,UPDATE
AS
DECLARE @ParentID INT
DECLARE @ParentType TinyInt
Declare @AppID INT
Declare @ScopeID INT
SELECT @AppID=AppID, @ScopeID=ScopeID, @ParentType=ParentType FROM inserted
if @@RowCount = 1
Begin
if @ParentType = 1
Begin
set @ParentID = @AppID
End
else if @ParentType = 4
Begin
set @ParentID = @ScopeID
End
exec UpdateTasksParentTimeStamp @ParentID, @ParentType
end
go
CREATE TRIGGER TR_UpdateParentTimeStampOnRoleDelete ON dbo.[AzMan_AzRoleAssignment]
FOR delete
AS
DECLARE @ParentID INT
DECLARE @ParentType TinyInt
Declare @AppID INT
Declare @ScopeID INT
-- We need to find the parent first
SELECT @AppID=AppID, @ScopeID=ScopeID, @ParentType=ParentType FROM deleted
if @@RowCount = 1
Begin
if @ParentType = 1
Begin
set @ParentID = @AppID
End
else if @ParentType = 4
Begin
set @ParentID = @ScopeID
End
exec UpdateRolesParentTimeStamp @ParentID, @ParentType
end
go
CREATE TRIGGER TR_UpdateParentTimeStampOnRoleInsOrUpd ON dbo.[AzMan_AzRoleAssignment]
FOR INSERT,UPDATE
AS
DECLARE @ParentID INT
DECLARE @ParentType TinyInt
Declare @AppID INT
Declare @ScopeID INT
SELECT @AppID=AppID, @ScopeID=ScopeID, @ParentType=ParentType FROM inserted
if @@RowCount = 1
Begin
if @ParentType = 1
Begin
set @ParentID = @AppID
End
else if @ParentType = 4
Begin
set @ParentID = @ScopeID
End
exec UpdateRolesParentTimeStamp @ParentID, @ParentType
end
go
CREATE TRIGGER TR_UpdateGroupsTimeStampOnSidMemberDel ON dbo.[AzMan_Group_SIDMember]
FOR delete
AS
UPDATE [AzMan_AzApplicationGroup]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT GroupID FROM deleted)
go
CREATE TRIGGER TR_UpdateGroupsTimeStampOnSidMemberInsOrUpd ON dbo.[AzMan_Group_SidMember]
FOR INSERT,UPDATE
AS
UPDATE [AzMan_AzApplicationGroup]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT GroupID FROM inserted)
go
CREATE TRIGGER TR_UpdateGroupsTimeStampOnAppdMemberDel ON dbo.[AzMan_Group_AppMember]
FOR delete
AS
UPDATE [AzMan_AzApplicationGroup]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT GroupID FROM deleted)
go
CREATE TRIGGER TR_UpdateGroupsTimeStampOnAppMemberInsOrUpd ON dbo.[AzMan_Group_AppMember]
FOR INSERT,UPDATE
AS
UPDATE [AzMan_AzApplicationGroup]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT GroupID FROM inserted)
go
CREATE TRIGGER TR_UpdateRolesTimeStampOnSidMemberDel ON dbo.[AzMan_Role_SIDMember]
FOR delete
AS
UPDATE [AzMan_AzRoleAssignment]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT RoleID FROM deleted)
go
CREATE TRIGGER TR_UpdateRolesTimeStampOnSidMemberInsOrUpd ON dbo.[AzMan_Role_SidMember]
FOR INSERT,UPDATE
AS
UPDATE [AzMan_AzRoleAssignment]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT RoleID FROM inserted)
go
CREATE TRIGGER TR_UpdateRolesTimeStampOnAppMemberDel ON dbo.[AzMan_Role_AppMember]
FOR delete
AS
UPDATE [AzMan_AzRoleAssignment]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT RoleID FROM deleted)
go
CREATE TRIGGER TR_UpdateRolesTimeStampOnAppMemberInsOrUpd ON dbo.[AzMan_Role_AppMember]
FOR INSERT,UPDATE
AS
UPDATE [AzMan_AzRoleAssignment]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT RoleID FROM inserted)
go
CREATE TRIGGER TR_UpdateRolesTimeStampOnOperationDelete ON dbo.AzMan_Role_To_Operation_Link
FOR DELETE
AS
UPDATE [AzMan_AzRoleAssignment]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT RoleID FROM deleted)
go
CREATE TRIGGER TR_UpdateRolesTimeStampOnOperationInsert ON dbo.AzMan_Role_To_Operation_Link
FOR INSERT
AS
UPDATE [AzMan_AzRoleAssignment]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT RoleID FROM inserted)
go
CREATE TRIGGER TR_UpdateRolesTimeStampOnTaskDelete ON dbo.AzMan_Role_To_Task_Link
FOR DELETE
AS
UPDATE [AzMan_AzRoleAssignment]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT RoleID FROM deleted)
go
CREATE TRIGGER TR_UpdateRolesTimeStampOnTaskInsert ON dbo.AzMan_Role_To_Task_Link
FOR INSERT
AS
UPDATE [AzMan_AzRoleAssignment]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT RoleID FROM inserted)
go
CREATE TRIGGER TR_UpdateTaskTimeStampOnOperationDelete ON dbo.AzMan_Task_To_Operation_Link
FOR DELETE
AS
UPDATE [AzMan_AzTask]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT TaskID FROM deleted)
go
CREATE TRIGGER TR_UpdateTaskTimeStampOnOperationInsert ON dbo.AzMan_Task_To_Operation_Link
FOR INSERT
AS
UPDATE [AzMan_AzTask]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT TaskID FROM inserted)
go
CREATE TRIGGER TR_UpdateTaskTimeStampOnTaskDelete ON dbo.AzMan_Task_To_Task_Link
FOR DELETE
AS
UPDATE [AzMan_AzTask]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT TaskID FROM deleted)
go
CREATE TRIGGER TR_UpdateTaskTimeStampOnTaskInsert ON dbo.AzMan_Task_To_Task_Link
FOR INSERT
AS
UPDATE [AzMan_AzTask]
SET [ChildUpdateTimeStamp]=@@DBTS
WHERE ID in (SELECT TaskID FROM inserted)
go
CREATE TRIGGER TR_DeleteGroupForStore ON dbo.[AzMan_AzAuthorizationStore]
FOR delete
AS
delete [AzMan_AzApplicationGroup] where StoreID in (select ID from deleted)
go
CREATE TRIGGER TR_DeleteGroupForApp ON dbo.[AzMan_AzApplication]
FOR delete
AS
delete [AzMan_AzApplicationGroup] where AppID in (SELECT ID FROM deleted)
go
CREATE TRIGGER TR_DeleteGroupForScope ON dbo.[AzMan_AzScope]
FOR delete
AS
delete [AzMan_AzApplicationGroup] where ScopeID in (SELECT ID FROM deleted)
go
CREATE TRIGGER TR_DeleteTaskForApp ON dbo.[AzMan_AzApplication]
FOR delete
AS
delete [AzMan_AzTask] where AppID in (SELECT ID FROM deleted)
go
CREATE TRIGGER TR_DeleteTaskForScope ON dbo.[AzMan_AzScope]
FOR delete
AS
delete [AzMan_AzTask] where ScopeID in (SELECT ID FROM deleted)
go
CREATE TRIGGER TR_DeleteRoleForApp ON dbo.[AzMan_AzApplication]
FOR delete
AS
delete [AzMan_AzRoleAssignment] where AppID in (SELECT ID FROM deleted)
go
CREATE TRIGGER TR_DeleteRoleForScope ON dbo.[AzMan_AzScope]
FOR delete
AS
delete [AzMan_AzRoleAssignment] where ScopeID in (SELECT ID FROM deleted)
go
CREATE TRIGGER TR_DeleteBizRuleForTask ON dbo.[AzMan_BizRule_To_Task]
FOR delete
AS
delete [AzMan_BizRule] where [ID] in (SELECT BizruleID FROM deleted)
go
CREATE TRIGGER TR_DeleteBizRuleForGroup ON dbo.[AzMan_BizRule_To_Group]
FOR delete
AS
delete [AzMan_BizRule] where [ID] in (SELECT BizruleID FROM deleted)
go