if not exists (select * FROM sys.sysobjects where id = object_id(N'dbo.DomainUsers')) 
create table dbo.DomainUsers 
(
    ID uniqueidentifier constraint DF_DomainUsers_ID default newid() not null,
	UPN nvarchar(100) not null,
	UserID uniqueidentifier constraint FK_DomainUsers_UserID foreign key references dbo.UserAccount(ID) on delete set null,
    Sid nvarchar(100) not null,
	DistinguishedName nvarchar(200) null,
	FirstName nvarchar(100) null,
	LastName nvarchar(100) null,
	Email nvarchar(200) null,
	DomainName nvarchar(100) not null,
    DomainType nvarchar(100) not null,
	NetbiosName nvarchar(100) not null,
	SamAccountName nvarchar(100) not null,
	Groups nvarchar(max) not null,
	LastSync DateTime not null constraint DF_DomainUsers_LastSync default getutcdate(),
	constraint PK_DomainUsers primary key clustered (ID)
);