mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-29 06:31:10 +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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
revokeStmts = append(revokeStmts, fmt.Sprintf(
|
revokeStmts = append(revokeStmts, fmt.Sprintf(dropUserSQL, dbName, username, username))
|
||||||
"USE [%s]; DROP USER IF EXISTS [%s];", dbName, qUsername))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// we do not stop on error, as we want to remove as
|
// we do not stop on error, as we want to remove as
|
||||||
@ -163,12 +162,23 @@ func (b *backend) secretCredsRevoke(
|
|||||||
return nil, nil
|
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 = `
|
const dropLoginSQL = `
|
||||||
IF EXISTS
|
IF EXISTS
|
||||||
(SELECT name
|
(SELECT name
|
||||||
FROM master.sys.server_principals
|
FROM master.sys.server_principals
|
||||||
WHERE name = '%s')
|
WHERE name = N'%s')
|
||||||
BEGIN
|
BEGIN
|
||||||
DROP LOGIN [%s]
|
DROP LOGIN [%s]
|
||||||
END
|
END
|
||||||
`
|
`
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user