views:

16

answers:

2

I am using the publish to provider feature in .net 2008 to produce a database creation script.

In the script exists the following line:

/****** Object:  Role [srvTTAS]    Script Date: 01/20/2010 09:14:14 ******/
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'srvTTAS')
BEGIN
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'srvTTAS' AND type = 'R')
CREATE ROLE [srvTTAS]

This causes a problem as I have a USER called "srvTTAS" setup in my database, and not a role. So when I run this script I have to manually delete the role in order to create a user of the same name. This means the script produced does not create a exact copy of the database in question, is there a way to make publish to provider create a user? (as I have specified in the database?)

A: 

I suspect the first SELECT statement is missing AND type = 'R'

AUSteve
+1  A: 

The name of any "principal" in the database must be unique. Roles and users are both principals.

Does this publisher have a bug? Or perhaps it can't distinguish principals correctly (for example, Metadata visibility)?

Anyhow, what are using srvTTAS for? For permissioning, it should be a role anyway with your database user in the role.

gbn
I am using srvTTAS for permissioning (uid=srvTTAS in my connectionstring) Can you put a role in a connectionstring?
Grayson Mitchell
@Grayson Mitchell: no.
gbn
hmmm, ok will have to continue to edit the script each time then, what a pain.(I have looked into using Kerberos, but that proved problematic in our environment - so I went as simple as I could on security)
Grayson Mitchell