Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I re-create my Dev Database with a Visual Studio DB Project twice a week.

Today I fixed my permissions to be Active Directory group based rather than giving individuals permissions.

After I re-ran my build I noticed that one domain/windows use was still in there. I searched all through the DB project and could not find this user in there anywhere.

So to test, I created a different database (ie MyDummyDb). Sure enough the user was added to that db too.

This user does not even have a valid login (I changed the logins to be AD Group based too).

So I have to assume there is a server level setting that controls which users get automatically added to a new database.

Is this right? Does anyone know where this setting is?

share|improve this question
    
Are you seeing the user as a login to the server instance or a user in the database as well? What kind of server and database permissions is the user getting? What do you see if you trace this with Profiler? –  sisdog Feb 25 '12 at 22:52
    
@sisdog - just on the db. There is no loving of the same name. (Though there used to be a while ago) I have not thought to trace. I bet that can give some good info. –  Vaccano Feb 26 '12 at 7:39
    
@downvoter - why the down vote? Please leave a comment as to why my question did not meet your standards. –  Vaccano Feb 26 '12 at 7:41
add comment

migrated from stackoverflow.com Feb 26 '12 at 17:36

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 4 down vote accepted

You have a user defined in the model database. Good odds someone mis-clicked once upon a time and created the spurious user in model accidentally. model is the template for any databases created on an instance, so if a user exists there it will exist in all databases you create.

Run the script below (on a development instance!) and you'll see a user created in model is added to the TestForModelUser database.

USE [master]
GO

CREATE LOGIN [ModelUser] WITH PASSWORD=N'', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO

USE [model]
GO

CREATE USER [ModelUser] FOR LOGIN [ModelUser]
GO

CREATE DATABASE TestForModelUser
GO

USE [TestForModelUser]
GO

SELECT * FROM sys.sysusers WHERE [name] = 'ModelUser'
GO

USE [master]
GO

DROP DATABASE [TestForModelUser]
GO

USE [model]
GO

DROP USER [ModelUser]
GO

USE [master]
GO

DROP LOGIN [ModelUser]
GO
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.