question

scorpio_thech avatar image
scorpio_thech asked

how to make a sql login to act as SA and excute a stored proc on OS level

here is my scenario, there is a sql server login (Sector_1) with dbo and EXCUTE privileges on the db/server. we are trying to login as Sector_1 and excute a stored procedure which checks if a file exists on a disk at OS level which is from a linked server. but if this login was SA or windows authenticated login, it returned the results but with its current permission which is non-sa it returnes false, as if the file didn't exist on the remote server.so obviously i can not give them SA permission but i really need a way to solve this issue,any help is much appreciated. Thanks
linked-serverpermissionssa
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
emil87b avatar image
emil87b answered
I had similar problem some time ago, i wanted a user to be able to execute stored procedure that interior required at least 'securityadmin' role, without giving him more than execute premission on procedure. One way is to give login ability to impersonate SA login i.e: EXECUTE ('SELECT SUSER_SNAME()') AS LOGIN = 'sa' but this is a bit dangerous EXECUTE ('DROP TABLE dbo.table') AS LOGIN = 'sa' Other way (and definetly safer) is to sign procedure with certificate, i found the following link very helpfull in doing that: http://sommarskog.se/grantperm.html#Certificates
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

scorpio_thech avatar image scorpio_thech commented ·
thanks a lot, that link was helpful as well, but still, what are the possible risks of using EXECUTE AS to impersonate the login?
0 Likes 0 ·
emil87b avatar image emil87b scorpio_thech commented ·
It basically is giving the same premissions to someone. Any piece of code can be executed by using EXEC ('Some nasty code') AS LOGIN='sa'
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.