Just reading this link:
http://msdn.microsoft.com/en-us/library/aa833199.aspx
It states: You cannot add users to roles in a Data-tier Application (DAC) project because DAC projects do not support the EXEC StoredProcedure construct, except within the body of an object, such as a stored procedure or function. For more information, see the following page on the Microsoft Web site: Features Supported in Data-tier Applications.
So, how is it possible to grant any permission to anything as part of the deployment?
After much digging and hacking, I finally have a solution.
A few notes first:
To add a given domain user as a server login and db user with specific permissions:
Step 1: create a Login
DOMAIN\USERjust enterUSER) and hit <Enter>enter this for your code then save and close the file (USER.login.sql)
Step 2: create a User
DOMAIN\USERjust enterUSER) and hit <Enter>enter this for your code then save and close the file (USER.user.sql)
Step 3: grant the privileges on the user and/or login
enter this for your code then save and close the file
note that a set of grant statements can be substituted for the sp_addrolemember
Ultimately, I think the real difficulty in doing this was how the post-deployment script is run. When run, the current Use database is initially set to master, but in order to issue the
exec sp_addrolememberand/orgrants, theuse [DAC-DB-NAME];must set the current database first. [End of pure speculation]Happy Coding!
Robert McCall
“Lasting peace & happiness for ALL human beings!”
Footnote: PowerShell script (using DAC PS Scripts) to uninstall & drop a DAC db