Skip to content

Commit

Permalink
0005528: Allowed SQL Server log-based replication without ALTER ANY D…
Browse files Browse the repository at this point in the history
…ATABASE permission
  • Loading branch information
evan-miller-jumpmind committed Oct 12, 2022
1 parent 50c5700 commit 860bd56
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,16 @@ protected PermissionResult getLogMinePermission() {
try {
if (getSqlTemplate().queryForInt("SELECT COUNT(*) FROM fn_my_permissions(NULL, 'SERVER') WHERE permission_name='ALTER ANY DATABASE'") > 0) {
result.setStatus(Status.PASS);
} else if (getSqlTemplate().queryForInt("SELECT COUNT(*) FROM sys.change_tracking_databases WHERE database_id=DB_ID()") > 0) {
if (getSqlTemplate().queryForInt("SELECT COUNT(*) FROM sys.databases WHERE database_id=DB_ID() AND snapshot_isolation_state=1") > 0) {
result.setStatus(Status.PASS);
} else {
result.setStatus(Status.FAIL);
result.setSolution("Enable snapshot isolation for this database.");
}
} else {
result.setStatus(Status.FAIL);
result.setSolution("Grant alter any database to this user.");
result.setSolution("Grant alter any database to this user. Or, enable change tracking for this database.");
}
} catch (Exception e) {
result.setSolution("Error occurred checking user permissions");
Expand Down

0 comments on commit 860bd56

Please sign in to comment.