Hello,
Does anybody have the transact SQL to find the permissions granted to the public role in a Database ?
Also looking for the SQL to find the permissions granted to the user Guest in a database ?
thanksYou can do both of them using the following SELECT statement:SELECT a.[name] + ' ' + v.[name] + ' ON ' + QuoteName(oo.[name])
+ '.' + QuoteName(o.[name]) + ' TO ' + QuoteName(u.[name])
FROM dbo.sysprotects AS p
JOIN master.dbo.spt_values AS a
ON (a.number = p.protecttype
AND 'T' = a.type)
JOIN master.dbo.spt_values AS v
ON (v.number = p.action
AND 'T' = v.type)
JOIN dbo.sysobjects AS o
ON (o.id = p.id)
JOIN dbo.sysusers AS oo
ON (oo.uid = o.uid)
JOIN dbo.sysusers AS u
ON (u.uid = p.uid)
WHERE 'public' = u.name-PatP|||Pat Phelan,
Thanks for this. It works perfectely for Public Role.
However how will it work for the Guest user ?|||However how will it work for the Guest user ?Yes, if you change the constant it will work for any user.
-PatP|||You can also use:
sp_helprotect @.username='public'
sp_helprotect @.username='guest'
Regards,
hmscott|||thanks hmscott and PatP for the solutions.
No comments:
Post a Comment