TheShark wrote:
hehe, you could write a stored procedure that inserts all of that information in a table and select it...
ouch
this was just a bit helpful ;-)
but anyway it's capable of development
with great help from Elmar Boye in microsoft.public.de.sqlserver:
stored procedure, selects permissions from tables and views
------------------------------------------------------------------------
Code:
IF OBJECT_ID ( 'dbo.uspMyPermissions', 'P' ) IS NOT NULL
DROP PROCEDURE dbo.uspMyPermissions;
GO
CREATE PROCEDURE dbo.uspMyPermissions
AS
SELECT
ObjectName,
p.permission_name AS Permission,
o.TYPE
FROM (SELECT
--QUOTENAME(SCHEMA_NAME(schema_id)) + '.' +
QUOTENAME(OBJECT_NAME(object_id)) AS ObjectName,
TYPE
FROM sys.objects
WHERE TYPE IN ('U', 'V')) AS o
INNER JOIN sys.fn_builtin_permissions('OBJECT') AS p
ON has_perms_by_name(ObjectName, 'OBJECT', permission_name) <> 0
ORDER BY TYPE, ObjectName, Permission
------------------------------------------------------------------------
//fetching permissions into frontend via NHibernate connection
------------------------------------------------------------------------
Code:
private void MyPermissions() {
IDbCommand cmd = Session.Connection.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "uspMyPermissions";
IDataReader dr = cmd.ExecuteReader();
while (dr.Read()) {
Debug.Print(dr["ObjectName"].ToString()
+ " " + dr["Permission"].ToString()
+ " " + dr["TYPE"].ToString());
}
}
------------------------------------------------------------------------