-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: findout table permissions
PostPosted: Fri Apr 07, 2006 8:09 am 
Newbie

Joined: Fri Apr 07, 2006 7:36 am
Posts: 5
Location: Linz, Austria
Hi,

I'm new at NHibernate and didn't find any hints in the doc.

How can i find out the permissions that the connected user has on a mapped table.
Need this to enable/disable CRUD operations, menues...
Is there a possibility to read this from database with NHibernate?

using NHibernate 1.0.2, SQL Server 2005, VS 2005 .Net 2.0

tia
cyberernesto


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 11:02 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
No, it's not possible to do this with NHibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 08, 2006 11:11 am 
Newbie

Joined: Fri Apr 07, 2006 7:36 am
Posts: 5
Location: Linz, Austria
sergey wrote:
No, it's not possible to do this with NHibernate.


hmm, thx.
How can i solve this problem generaly?
Can I find this out with ADO.Net or are there any other possibilities?
Any key words for me to dig into help?

tia cybere


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 09, 2006 8:28 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
hehe, you could write a stored procedure that inserts all of that information in a table and select it...
ouch


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 5:51 am 
Newbie

Joined: Fri Apr 07, 2006 7:36 am
Posts: 5
Location: Linz, Austria
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());
    }
}
------------------------------------------------------------------------


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.