User is not able to access the database master
Creating the user account and get permission to the user is one of the day to day task for database administrator.
The user told me they got issue when their end user trying to connect to the database, they got the following error message, also they mentioned they’re pretty sure that user has access to the database.
ADDITIONAL INFORMATION:
The server principal "NewUser" is not able to access the database "master" under the current security context.
Cannot open user default database. Login failed.
Login failed for user 'NewUser'. (Microsoft SQL Server, Error: 916)
For help, click: https://docs.microsoft.com/sql/relational-databases/errors-events/mssqlserver-916-database-engine-error
Before starting this topic I want to mentioned about “least privilege rule” that means every application and system administrator should only have access to information that their job requires them to access, so in our case it means if the user needs only read access to the database you don’t need to get them access to master database or any other objects.
You only need to ask the user when they type their username and password click on the “option” like the following screenshot then in the next page type the database name in “connect to database” then click on the connect button. Please see the following screenshots.
If you also have the application you should point to the target database instead of “Master”, I saw some DBAs instead of this give permission to the master database for their end user which I believe not required.