I want to allow a non-admin account the ability to query a linked server.
If I create a linked server with the following under a sysadmin account like below.
EXEC master.dbo.sp_addlinkedserver @server = N'LINKEDSERVER', @srvproduct=N'', @provider=N'IhOLEDB.iHistorian', @datasrc=N'linkedservername'
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'LINKEDSERVER',@useself=N'False',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL
When I run SELECT * FROM OPENQUERY(LINKEDSERVER, 'SELECT * FROM ihTags')
from a sysadmin account (no matter what account it is), it works.
If I run the query from a non-sysadmin account I get the following error.
Msg 7416, Level 16, State 2, Line 2
Access to the remote server is denied because no login-mapping exists.
SELECT * FROM ihTags
bit if you know this will always be run againstLINKEDSERVER
), or you'll have to give them appropriate permissions against the linked server. This doesn't meansysadmin
but it's obviously more than they've got now, and I'm not sure if you're using Windows credentials or not but you'll need to add additional logins with the right permissions usingsp_addlinkedsrvlogin
.