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

  • 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

  • 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)

    ------------------------------

  • 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?

  • 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

  • I've been reading BOL but the nuance you provided is not there so thanks for some added clarification.

  • 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.

  • 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

  • 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/

  • 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
  • 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.

  • clintonG (3/17/2013)


    The SQLExpress database will be intsalled on a share of a Windows7 machine

    Errrr....

    SQL is not Access. It's not a file-based database that sits on a share. It's a service that other machines connect to.

    With the SQL Service running on a Windows 7 machine, anyone who has administrative access to that Windows 7 machine can do what they like to your database (and that includes dropping it, uninstalling the service, etc).

    You need to lock that machine down and treat it like a server if it's serving data.

    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
  • GilaMonster (3/17/2013)


    clintonG (3/17/2013)


    The SQLExpress database will be intsalled on a share of a Windows7 machine

    Errrr....

    SQL is not Access. It's not a file-based database that sits on a share. It's a service that other machines connect to.

    With the SQL Service running on a Windows 7 machine, anyone who has administrative access to that Windows 7 machine can do what they like to your database (and that includes dropping it, uninstalling the service, etc).

    You need to lock that machine down and treat it like a server if it's serving data.

    I understand thank you. However doesn't Group Policy Editor remain accessible to any Windows 7 Administrator anyway?

    So with your insights and those of others I've worked through creating a login, user, flexible role with DENY DELETE and the app does not allow deleting data when it is being used which is all I wanted to learn get done at the moment.

  • When I look at the SSMS console for a database, I can see under the Permissions section that for a given user/group, DENY DELETE can be granted. Is that not what you are looking for?

  • I have just created a role called "DENY DELETE", and assigned a user called "TESTUSER" to it after adding that user to new role. Is that sufficient?

  • clintonG (3/18/2013)


    However doesn't Group Policy Editor remain accessible to any Windows 7 Administrator anyway?

    Err, huh?

    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

Viewing 15 posts - 1 through 15 (of 32 total)

You must be logged in to reply to this topic. Login to reply