Skip to content

Commit

Permalink
5018: Add permission check for database altering before allowing user…
Browse files Browse the repository at this point in the history
… to install SQL Server node with log-based replication (#159)

* 5018: add permission check for altering databases to wizard for sql server log-based repl

* 5018: add permission check for altering databases to wizard for sql server log-based repl
  • Loading branch information
rudiejd committed Jun 10, 2021
1 parent 8fc6797 commit 2c4845d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,7 +1,7 @@
/.DS_Store
/.project
*.iml

.clover/*
/.idea/*
*.ipr
*.iws
Expand Up @@ -72,8 +72,22 @@ public long getEstimatedRowCount(Table table) {
@Override
protected PermissionResult getLogMinePermission() {
final PermissionResult result = new PermissionResult(PermissionType.LOG_MINE, "");
result.setStatus(Status.PASS);
try {
if (getSqlTemplate().queryForInt("SELECT COUNT(*) FROM fn_my_permissions(NULL, 'SERVER') WHERE permission_name='ALTER'") > 0) {

This comment has been minimized.

Copy link
@Christian-PK

Christian-PK Sep 21, 2021

@rudiejd
We are trying to build a POC and can not use Log based on 3.12.11 because of permissions. Should the where clause not be
where permission_name='ALTER ANY DATABASE'?

This comment has been minimized.

Copy link
@rudiejd

rudiejd Sep 21, 2021

Author Contributor

I think you're correct - this one is just looking for whether the account has server permission to alter anything

This comment has been minimized.

Copy link
@rudiejd

rudiejd Sep 21, 2021

Author Contributor

This comment has been minimized.

Copy link
@Christian-PK

Christian-PK Sep 21, 2021

Thanks for the quick response!

result.setStatus(Status.PASS);
} else {
result.setStatus(Status.FAIL);
result.setSolution("Grant alter any database to this user.");
}

} catch (Exception e) {
result.setSolution("Error occurred checking user permissions");
result.setException(e);
}
return result;
}




}

0 comments on commit 2c4845d

Please sign in to comment.