Is there a way to revoke all permissions? I want to setup a test database
with permissions that make more sense than the random ones that have been
placed on the database over the years (SQL 2000). There are too many
factors to know for sure the plan will cover all scenarios without a test.
Hoping... is there is a way to revoke all permissions and then re-add them
[via a script] so that the permission set is clean and based solely on t
he
security script being used on the test database?
--
Regards,
JamieScott Morris answered this one for me in another post with a script to check
for orphaned users.
Thanks Scott.
--
set nocount on
go
if exists(select * from tempdb..sysobjects where id =
object_id('tempdb..#t_users'))
drop table #t_users
CREATE TABLE #t_users ( [name] sysname)
INSERT #t_users ( [name] )
SELECT [name] from sysusers where status = 2 and name <> 'dbo' order by
name
declare @.lc_name sysname
SET @.lc_name = (SELECT MIN([name]) FROM #t_users)
WHILE @.lc_name IS NOT NULL
BEGIN
IF exists(select * FROM master..syslogins WHERE [name] = @.lc_name)
EXEC sp_change_users_login 'AUTO_FIX', @.lc_name
else
PRINT '*** not fixing ' + @.lc_name
SET @.lc_name = (SELECT MIN([name]) FROM #t_users WHERE [name] >
@.lc_name )
END
go
Regards,
Jamie
"thejamie" wrote:
> Is there a way to revoke all permissions? I want to setup a test database
> with permissions that make more sense than the random ones that have been
> placed on the database over the years (SQL 2000). There are too many
> factors to know for sure the plan will cover all scenarios without a test.
> Hoping... is there is a way to revoke all permissions and then re-add them
> [via a script] so that the permission set is clean and based solely on
the
> security script being used on the test database?
> --
> Regards,
> Jamie
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment