Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / July 2008

Tip: Looking for answers? Try searching our database.

Restricting DB access through a View

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard Speiss - 31 Jul 2008 20:29 GMT
I have a database (SQL 2005) that is used internally and the various
internal user's applications can access the tables, views, stored
procedures, etc.  Note that the owner on all objects within the db is 'dbo'

They want an external user to access specific data in the database (Let's
call the database InsideDB).  So I want to restrict this user from doing
absolutely anything but accessing a custom view.

Here is a simplified example of what I did

- I created a SCHEMA named [OutsideSchema]
- I created a VIEW named [OutsideSchema].[OutsideView]
- I created a role named [OutsideRole]
- I created a user named [OutsideUser]
- I made [OutsideUser] a member of [OutsideRole]
- I executed 'GRANT SELECT ON SCHEMA::[OutsideSchema] TO [OutsideRole]
- I executed 'REVOKE VIEW ANY DATABASE FROM PUBLIC'

I then logged in as [OutsideUser] and was not able to see any databases nor
SELECT from any tables in InsideDB.

However, I was able to SELECT * FROM dbo.vwItems (and all other views) as
well as execute the user stored procedures.

Looking at the various permissions it seems that all logged in users belong
to PUBLIC which gives them SELECT permissions into the views.

There doesn't seem to be a way to delete PUBLIC.  I know that I can go
through each individual view and remove SELECT permissions but what happens
when a new VIEW is added?  Won't this user get access to it automatically
unless I go back and remove the permissions for the new VIEW as well?

I thought it should be easy to create a new user/schema that has absolutely
no permissions for anything to start with.  And then built up only what is
necessary.  Is this possible?

I am very aware that I need more understanding of SQL and the various
permission structures, etc. so if anyone also has a suggestion for a good
book on the subject I wouldn't mind getting a recommendation.

Many thanks

Richard
Daniel Jameson - 31 Jul 2008 23:30 GMT
Richard,

It sounds like you had a bunch of objects to which the public role had
previously been GRANTed select/execute permission.  There was a lot of that
approach to permissioning when I arrived at my current assignment.  You are
correct that without a GRANT statement that objects have no permissions
granted other than to the object owner.

The right way to really fix this is determine which inside
users/applications need access to which objects and create appropriate roles
and assign approriate permissions to those roles.  Then you can remove the
permissions assigned to the public role.

On kludge you might consider is creating another database and use
replication (in the same server) to populate what your outside users need to
see.  It sounds like overkill, but it is probably a lot easier and quicker
to implement than cleaning up your public role access situation.

Signature

Thank you,

Daniel Jameson
SQL Server DBA
Children's Oncology Group
www.childrensoncologygroup.org

>I have a database (SQL 2005) that is used internally and the various
>internal user's applications can access the tables, views, stored
[quoted text clipped - 40 lines]
>
> Richard
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.