mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-28 06:01:08 +01:00
Changing DROP USER query to a more compatible version
This commit is contained in:
parent
7fa20ef8e4
commit
bfa943c771
@ -121,8 +121,7 @@ func (b *backend) secretCredsRevoke(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
revokeStmts = append(revokeStmts, fmt.Sprintf(
|
||||
"USE [%s]; DROP USER IF EXISTS [%s];", dbName, qUsername))
|
||||
revokeStmts = append(revokeStmts, fmt.Sprintf(dropUserSQL, dbName, username, username))
|
||||
}
|
||||
|
||||
// we do not stop on error, as we want to remove as
|
||||
@ -163,12 +162,23 @@ func (b *backend) secretCredsRevoke(
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
const dropUserSQL = `
|
||||
USE [%s]
|
||||
IF EXISTS
|
||||
(SELECT name
|
||||
FROM sys.database_principals
|
||||
WHERE name = N'%s')
|
||||
BEGIN
|
||||
DROP USER [%s]
|
||||
END
|
||||
`
|
||||
|
||||
const dropLoginSQL = `
|
||||
IF EXISTS
|
||||
(SELECT name
|
||||
FROM master.sys.server_principals
|
||||
WHERE name = '%s')
|
||||
WHERE name = N'%s')
|
||||
BEGIN
|
||||
DROP LOGIN [%s]
|
||||
DROP LOGIN [%s]
|
||||
END
|
||||
`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user