nvisionative / nvQuickTheme

nvQuickTheme is more than just a great minimalist DNN (DotNetNuke) theme. It is a powerful theme building framework and developer workflow.
https://nvisionative.github.io/nvQuickTheme/
Other
41 stars 40 forks source link

change sp_addrolemember for ALTER ROLE #377

Closed leedavi closed 1 month ago

leedavi commented 1 month ago

The sp_addrolemember in SQL will be removed in future. You probably know!

https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-addrolemember-transact-sql?view=sql-server-ver16

I was automating some work and took some of your DB permissions code to do it. The sp_addrolemember gave me some issues with roles already being assigned. I changed it to the ALTER ROLE and the problem was solved.

Change

SqlCommand addRoleMember = new SqlCommand($"sp_addrolemember 'db_owner', '{appPoolName}'", myConn);

to

SqlCommand addRoleMember = new SqlCommand($"ALTER ROLE [db_owner] ADD MEMBER [{appPoolName}] ", myConn);
leedavi commented 1 month ago

Whoops... wrong repo. Sorry... I'll move it.