SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Do Users based on logins in master have access to other databases?


Do Users based on logins in master have access to other databases?

Author
Message
clintonG
clintonG
SSC Veteran
SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)

Group: General Forum Members
Points: 235 Visits: 37
When I create a user and select master as the default database does that mean or imply that user can login to other databases on the same instance of SQLExpress 2012? If so how is a user created that can only login to a specific database?

I understand a User can be mapped to a specific database but in certain circumstances the User must be created manually --before the database-- because the database the User is logging into is being generated by a sql script generated by a tool; Visual Studio LightSwitch 2012 to be specific.

Lots of generation going on except in my brain. lol



arunyadav007
arunyadav007
Old Hand
Old Hand (312 reputation)Old Hand (312 reputation)Old Hand (312 reputation)Old Hand (312 reputation)Old Hand (312 reputation)Old Hand (312 reputation)Old Hand (312 reputation)Old Hand (312 reputation)

Group: General Forum Members
Points: 312 Visits: 299
If you create a login and set 'master' as default database then, the user will only be created in the master database. The login/user will not have access to any of the user/system databases untill and unless you map the user to other databases. Upon trying to access any other database it should result into the belwo error:

TITLE: Microsoft SQL Server Management Studio
------------------------------

The database 'MyUserDB' is not accessible. (ObjectExplorer)

------------------------------
OTF
OTF
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2472 Visits: 4128
clintonG (3/14/2013)

I understand a User can be mapped to a specific database but in certain circumstances the User must be created manually --before the database-- because the database the User is logging into is being generated by a sql script generated by a tool; Visual Studio LightSwitch 2012 to be specific.


Unless I'm reading this incorrectly, how would LightSwitch create a user before the database actually exists unless, maybe, you are referring to Logins?
Divine Flame
Divine Flame
SSCertifiable
SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)

Group: General Forum Members
Points: 7339 Visits: 2816
clintonG (3/14/2013)
When I create a user and select master as the default database does that mean or imply that user can login to other databases on the same instance of SQLExpress 2012? If so how is a user created that can only login to a specific database?

I understand a User can be mapped to a specific database but in certain circumstances the User must be created manually --before the database-- because the database the User is logging into is being generated by a sql script generated by a tool; Visual Studio LightSwitch 2012 to be specific.

Lots of generation going on except in my brain. lol


Only a login can have the "default_database" setting, a user cannot. Default database setting let you choose a database which this login will be connected to whenever he logins into SQL Server (If the user has not specified any database name explicitly).

Logins & Users are completely different from each other. Logins are create at server scope whereas users are created in database scope.

So, You can create users only after the database is created.

Another important thing to note here is, though SQL Server allows you to set [master] database as the default_database for new logins that you are creating, it doesn't mean they will be granted access to master database as a user. [master] database will just work as a landing database for them, nothing else.

For more information on this you can check below link:

Logins & Users in SQL Server


Sujeet Singh
clintonG
clintonG
SSC Veteran
SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)

Group: General Forum Members
Points: 235 Visits: 37
I've been reading BOL but the nuance you provided is not there so thanks for some added clarification.



kevaburg
kevaburg
SSCrazy Eights
SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)SSCrazy Eights (8K reputation)

Group: General Forum Members
Points: 8041 Visits: 1104
Logins created within the instance have by default no automatic access to any database within that instance. Each created user needs to be explicitly mapped to a database and assigned roles as appropriate.

The master database contains the structures of the databases on the instance and access to it does not imply access to other databases. It is really worth reading the security articles pertaining to fixed server roles and database level permissions to ensure to don't end up opening a security hole where you don't want one.
clintonG
clintonG
SSC Veteran
SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)

Group: General Forum Members
Points: 235 Visits: 37
kevaburg (3/17/2013)
Logins created within the instance have by default no automatic access to any database within that instance. Each created user needs to be explicitly mapped to a database and assigned roles as appropriate.

The master database contains the structures of the databases on the instance and access to it does not imply access to other databases. It is really worth reading the security articles pertaining to fixed server roles and database level permissions to ensure to don't end up opening a security hole where you don't want one.



Thanks for comments.
I've been reading more about security and fixed server roles.
This article explains how my endeavor may be futile anyway...
http://www.netspi.com/blog/2012/08/16/sql-server-2008-local-administrator-privilege-escalation/

However all I really need to do is disallow Users from deleting data while using a LightSwitch app and I will continue to read and learn how to do so



Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)

Group: General Forum Members
Points: 166938 Visits: 39467
clintonG (3/17/2013)
kevaburg (3/17/2013)
Logins created within the instance have by default no automatic access to any database within that instance. Each created user needs to be explicitly mapped to a database and assigned roles as appropriate.

The master database contains the structures of the databases on the instance and access to it does not imply access to other databases. It is really worth reading the security articles pertaining to fixed server roles and database level permissions to ensure to don't end up opening a security hole where you don't want one.



Thanks for comments.
I've been reading more about security and fixed server roles.
This article explains how my endeavor may be futile anyway...
http://www.netspi.com/blog/2012/08/16/sql-server-2008-local-administrator-privilege-escalation/

However all I really need to do is disallow Users from deleting data while using a LightSwitch app and I will continue to read and learn how to do so


Let's make it easier for others to read:

http://www.netspi.com/blog/2012/08/16/sql-server-2008-local-administrator-privilege-escalation/

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
GilaMonster
GilaMonster
SSC Guru
SSC Guru (412K reputation)SSC Guru (412K reputation)SSC Guru (412K reputation)SSC Guru (412K reputation)SSC Guru (412K reputation)SSC Guru (412K reputation)SSC Guru (412K reputation)SSC Guru (412K reputation)

Group: General Forum Members
Points: 412556 Visits: 47118
clintonG (3/17/2013)
However all I really need to do is disallow Users from deleting data while using a LightSwitch app and I will continue to read and learn how to do so


Let me simplify...

If the database is on the user's machine and the user has local administrator permissions, there is nothing you can do to keep that user out of the database if they want access. You can slow them down, that's all.

If you want to restrict access, the database needs to be on a server. The bear minimum of people must be admin of that server (typically sysadmins and maybe DBAs), the users then have logins to SQL and only the rights you want to give them.

TL;DR If you give the database to someone (put it on their machine), they can do what they like.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


clintonG
clintonG
SSC Veteran
SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)

Group: General Forum Members
Points: 235 Visits: 37
[quote
...
...
TL;DR If you give the database to someone (put it on their machine), they can do what they like.[/quote]

This and similar projects use P2P LANs. The SQLExpress database will be intsalled on a share of a Windows7 machine and the LightSwitch client installed on other Windows7 machines will use a connection string to use the database.

That's the architecture I have to work with. So where things are at for me right now I am looking at creating a Role that does not allow delete and I will add users to that role. If that's the best I can do that will have to do.



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search