Avatar of CousinDupree
CousinDupree
Flag for United States of America asked on

Is it possible to allow a stored procedure to be called only from a particular application or from an application running from a specific location?

I have a database on a MSSQL 2008 server that has several stored procedures.  The only way of interacting with the data in the tables is through those stored procedures.  Is there any way to restrict access to the stored procedures to applications that run from a particular location - i.e. a specific network share?  A large number of users need access to the data, but we would like to tightly control how they access it.
Microsoft SQL Server

Avatar of undefined
Last Comment
lcohan

8/22/2022 - Mon
lcohan

I suggest use SQL Database role security and add one DB role for your app like application_users then grant all EXEC rights on the stored proc(s) and/or dependent UDF functions plus SELECT,INSERT,UPDATE,DELETE to all tables/views and objects to linked to this SP.

Then you add only SQL or NT logins to application_users comming from that network segment so nothing else can access that SP other than SA.
CousinDupree

ASKER
How would I go about adding only SQL or NT logins that come from a particular place? When you say 'particular network segment', what exactly are you referring to?
lcohan

"Is it possible to allow a stored procedure to be called only from a particular application or from an application running from a specific location?"

Well I guess my answer is direct for the first part of your question as that "particular application " should (idealy) have its own login to the database right? If you impersonate users then you would add all those users to the new application_users database role (you can call it whatever you want) and only they can run that SP right?

As far as network segments and IP trafic you can selectively block (incomming/outgoing) port 1433 (or whatever port you use for your SQL) traffic in the firewall right?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
CousinDupree

ASKER
I see, your intent was to use the firewall to control access to the SQL server.  My ultimate goal is to allow users to access the data through an application that calls the stored procedures, but to prevent a programmer from writing an unapproved application that can be used to access the data.
ASKER CERTIFIED SOLUTION
lcohan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.