dbTalk Databases Forums  

Permissions to specific function

microsoft.public.sqlserver.server microsoft.public.sqlserver.server


Discuss Permissions to specific function in the microsoft.public.sqlserver.server forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
ampo
 
Posts: n/a

Default Permissions to specific function - 07-16-2009 , 07:24 AM






Hello.

I need to grant permissions to specific scalar function in specific database.
How Can I deny execution from everyone except 3 specific users / logins?

Thanks.

Reply With Quote
  #2  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Permissions to specific function - 07-16-2009 , 07:31 AM






Hi
GRANT SELECT ON some_udf TO username -- Grant permission on a single udf



"ampo" <u53310@uwe> wrote

Quote:
Hello.

I need to grant permissions to specific scalar function in specific
database.
How Can I deny execution from everyone except 3 specific users / logins?

Thanks.

Reply With Quote
  #3  
Old   
ampo
 
Posts: n/a

Default Re: Permissions to specific function - 07-16-2009 , 07:42 AM



1. Is this means that the rest of the users, by default, are denied?
2. Should I grand "Select" or "Execute" permissions?

Thanks.


Uri Dimant wrote:
Quote:
Hi
GRANT SELECT ON some_udf TO username -- Grant permission on a single udf

Hello.

[quoted text clipped - 3 lines]

Thanks.

Reply With Quote
  #4  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Permissions to specific function - 07-16-2009 , 08:01 AM



ampo
Quote:
1. Is this means that the rest of the users, by default, are denied?
No, rest of users should no be a member of db_owner database role, sysadmin
server role

Quote:
2. Should I grand "Select" or "Execute" permissions?
Hmm , If I remember well SELECT ,have not done it for a long time, check it
out in BOL



"ampo" <u53310@uwe> wrote

Quote:
1. Is this means that the rest of the users, by default, are denied?
2. Should I grand "Select" or "Execute" permissions?

Thanks.


Uri Dimant wrote:
Hi
GRANT SELECT ON some_udf TO username -- Grant permission on a single udf

Hello.

[quoted text clipped - 3 lines]

Thanks.

Reply With Quote
  #5  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Permissions to specific function - 07-16-2009 , 04:11 PM



ampo (u53310@uwe) writes:
Quote:
1. Is this means that the rest of the users, by default, are denied?
Unless they have permission by some other mean, for instance permission on
the schema.

Also, keep in mind that if the function is called from within a stored
procedure with the same owner, it does not matter who is the caller.

Quote:
2. Should I grand "Select" or "Execute" permissions?
Let's see:

CREATE FUNCTION testis () RETURNS int AS
BEGIN
RETURN 2
END
go
GRANT SELECT ON testis TO public
GRANT EXECUTE ON testis TO public
go
DROP FUNCTION testis

Gives:

Msg 4606, Level 16, State 1, Line 1
Granted or revoked privilege SELECT is not compatible with object.

Looks like you should grant EXECUTE.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
  #6  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Permissions to specific function - 07-17-2009 , 02:34 PM



Thanks Erland for testing




"Erland Sommarskog" <esquel (AT) sommarskog (DOT) se> wrote

Quote:
ampo (u53310@uwe) writes:
1. Is this means that the rest of the users, by default, are denied?

Unless they have permission by some other mean, for instance permission on
the schema.

Also, keep in mind that if the function is called from within a stored
procedure with the same owner, it does not matter who is the caller.

2. Should I grand "Select" or "Execute" permissions?

Let's see:

CREATE FUNCTION testis () RETURNS int AS
BEGIN
RETURN 2
END
go
GRANT SELECT ON testis TO public
GRANT EXECUTE ON testis TO public
go
DROP FUNCTION testis

Gives:

Msg 4606, Level 16, State 1, Line 1
Granted or revoked privilege SELECT is not compatible with object.

Looks like you should grant EXECUTE.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000:
http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.