1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| SELECT user_name(p.grantor) AS GRANTOR, user_name(p.uid) AS GRANTEE, db_name() AS TABLE_CATALOG, user_name(o.uid) AS TABLE_SCHEMA,
o.name AS TABLE_NAME, c.name AS COLUMN_NAME,
CASE p.action WHEN 193 THEN 'SELECT' WHEN 197 THEN 'UPDATE' ELSE 'REFERENCES' END AS PRIVILEGE_TYPE,
CASE WHEN p.protecttype = 205 THEN 'NO' ELSE 'YES' END AS IS_GRANTABLE
FROM sysprotects p, sysobjects o, syscolumns c
WHERE (is_member(user_name(p.uid)) = 1 OR
p.grantor = user_id()) AND (p.protecttype = 204 OR
(p.protecttype = 205 AND NOT EXISTS
(SELECT *
FROM sysprotects p2
WHERE p2.id = p.id AND p2.uid = p.uid AND p2.action = p.action AND p2.columns = p.columns AND p2.grantor = p.grantor AND
p2.protecttype = 204))) AND p.action IN (26, 193, 197) AND p.id = o.id AND o.xtype IN ('U', 'V') AND o.id = c.id AND (((CONVERT(tinyint,
substring(p.columns, 1, 1)) & 1) = 0 AND (CONVERT(int, substring(p.columns, c.colid / 8 + 1, 1)) & power(2, c.colid & 7)) != 0) OR
((CONVERT(tinyint, substring(p.columns, 1, 1)) & 1) != 0 AND (CONVERT(int, substring(p.columns, c.colid / 8 + 1, 1)) & power(2, c.colid & 7)) = 0)) AND
0 != (permissions(o.id, c.name) & CASE p.action WHEN 26 THEN 4 WHEN 193 THEN 1 WHEN 197 THEN 2 END) |
Partager