Using logins, users, permissions in SQL Server 2005 Express

1k views Asked by At

I connected to SQL Server with Windows Authentication (Admin).

Then, I created a login for my SQL Server 2005 Express as:

CREATE LOGIN bob WITH PASSWORD = 'bobpass'. 

Now, I closed SQL Server & then again opened it & this time I connected it with the login 'bob'.

Now, I executed this : SELECT CURRENT_USER.

It gave the output : guest

Why so?

Is this because I didn't create any user inside the bob login?

1

There are 1 answers

4
Remus Rusanu On BEST ANSWER

CURRENT_USER will return a database principal (an user). bob is a server principal (a login). If you didn't grant access to any database and you didn't add bob to any builtin server security groups, then he will not have access to any database except master and tempdb. In those two databases, he will be recognized as guest. This is the default, you may notice differences from this description if you have something changed in your deployment from a fresh installation (eg. you may discover that bob has access to more databases because those databases have enabled guest).

So basically you guessed right:bob is guest because he does not have an explicit database principal (an user) nor is he member of sysadmin (in which case he would be dbo in every database).