Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rtutus
Aged Yak Warrior
522 Posts |
Posted - 2007-03-04 : 14:24:41
|
Hi I use exec helprotect to put a user's perimssion into a temp table called #permissions defined with these columns : (DBname,[Owner] ,[Object],[Grantee] , [Grantor] , [ProtectType] , [Action] , [Col] ) like this:Now when I get those permissions I use this script inside a cursor to replicate each permission to the user: @newLoginParam My question: is there any big business scenario in which my script might fail or miss some permissions for any user?here is the main part of my script:declare @objj as varchar(8000)declare @grantee as varchar(8000)declare @action as varchar(8000)declare @col as varchar(8000)declare @sqlGrant as varchar(8000)declare @ProtectType as varchar(8000)declare @count as intset @count=0declare crsMyTblPermis cursor for select Object,Grantee,ProtectType , Action, Col from #permissionsopen crsMyTblPermisfetch next from crsMyTblPermis into @objj, @grantee, @ProtectType, @action,@colwhile @@fetch_status=0 beginif (@objj!='.' and (@col = '.' OR @col = '(All+New)'))beginset @sqlGrant = @ProtectType +@action + ' on ' + @objj + ' to ' + @newLoginParam end if (@objj!='.' and @col != '.' and @col != '(All+New)')beginset @sqlGrant = @ProtectType +@action + ' on ' + @objj + '(' + @col + ') to ' + @newLoginParam endif (@objj='.')beginset @sqlGrant = @ProtectType +@action + ' to ' + @newLoginParam endexec(@sqlGrant)fetch next from...........etcP.S: The main reason is that I can t test my script now on the production platform on which the script will be runThanks for your advice . |
|
|
|
|
|
|