Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SSDB.non-service_accounts.sql #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions SSDB.non-service_accounts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ PRINT 'check databases owners ... ';
[master].[sys].[databases] AS db
INNER JOIN [master].[sys].[syslogins] AS sl ON db.[owner_sid] = sl.[sid]
WHERE
1=1
AND sl.[Name] NOT IN(SELECT [Login_Name] FROM #service_accounts)
sl.[Name] NOT IN(SELECT [Login_Name] FROM #service_accounts)
AND (sl.[Name] = N'$(login_name)' OR N'$(login_name)' = N'')
ORDER BY
db.[Name]
Expand Down Expand Up @@ -81,8 +80,7 @@ PRINT 'check databases users ... ';
[sys].[database_principals] AS dp
LEFT JOIN [sys].[database_role_members] AS dm ON dp.[principal_id] = dm.[member_principal_id]
WHERE
1=1
AND dp.[sid] IS NOT NULL
dp.[sid] IS NOT NULL
AND dp.[sid] NOT IN (0x00)
AND dp.[is_fixed_role] != 1
AND dp.[name] NOT LIKE ''##%'''
Expand All @@ -105,8 +103,7 @@ PRINT 'check databases users ... ';
FROM
@dbs_users AS dbu1
WHERE
1=1
AND [User_Name] NOT IN(SELECT [Login_Name] FROM #service_accounts)
[User_Name] NOT IN(SELECT [Login_Name] FROM #service_accounts)
AND [Login_Type] = 'WINDOWS_USER'
AND ([User_Name] = N'$(login_name)' OR N'$(login_name)' = N'')
GROUP BY
Expand Down Expand Up @@ -134,8 +131,7 @@ PRINT 'check agent jobs ... ';
INNER JOIN [master].[sys].[syslogins] AS sl ON sj.[owner_sid] = sl.[sid]
INNER JOIN [msdb].[dbo].[syscategories] AS sc ON sc.[category_id] = sj.[category_id]
WHERE
1=1
AND sl.[Name] NOT IN(SELECT [Login_Name] FROM #service_accounts)
sl.[Name] NOT IN(SELECT [Login_Name] FROM #service_accounts)
AND (sl.[name] = N'$(login_name)' OR N'$(login_name)' = N'')
ORDER BY
sj.[name]
Expand All @@ -162,8 +158,7 @@ PRINT 'check report subscriptions ... ';
INNER JOIN [ReportServer].[dbo].[Users] AS ou ON ou.[UserID] = sb.[OwnerID]
INNER JOIN [ReportServer].[dbo].[Catalog] AS rp ON rp.[ItemID] = sb.[Report_OID]
WHERE
1=1
AND ou.[UserName] NOT IN(SELECT [Login_Name] COLLATE Latin1_General_CI_AS FROM #service_accounts)
ou.[UserName] NOT IN(SELECT [Login_Name] COLLATE Latin1_General_CI_AS FROM #service_accounts)
AND (ou.[UserName] = N'$(login_name)' OR N'$(login_name)' = N'')


Expand Down