Advertisement

06.30.2008 at 01:46PM PDT, ID: 23528323
[x]
Attachment Details

Modifiable SQL Function using WITH EXECUTE AS...

Asked by kalliopi in SQL Server 2005, MS SQL Server, SQL Server 2008

Tags: SQL, Function, Transact SQL, SQL Server, INTLINE, MULTILINE, RETURNS, EXECUTE AS

Hi,

Is there ANY way to create an inline table function that impersonates someone else?


More Details:
Specifically, I want to create a table "TableA" that a user does NOT have permission to see/modify in any way.  Then, I want to create a function called FunctionA along the lines of this:

CREATE FUNCTION FunctionA()
RETURNS TABLE
WITH EXECUTE AS N'dbo'
AS
     RETURN (SELECT * FROM TableA where TableA.UserName = user_name())
GO

This would create a function that I could use JUST like a table, but which would only let me see/modify/delete the records that were associated with MY username.  All other data would be filtered out by the function and since my username would NOT have access to the table directly - I would have secure access to my data only.  Does that make any sense?

Anyway - I've been going around and around with INLINE TABLE functions (which don't seem to allow WITH EXECUTE AS) and MULTILINE table functions which don't seem to allow INSERT INTO in the way that INLINE TABLE functions do.

Any suggestions?

Thanks.

EJStart Free Trial
[+][-]06.30.2008 at 01:49PM PDT, ID: 21902923

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 01:51PM PDT, ID: 21902934

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 02:30PM PDT, ID: 21903169

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 09:33PM PDT, ID: 21904998

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Server 2005, MS SQL Server, SQL Server 2008
Tags: SQL, Function, Transact SQL, SQL Server, INTLINE, MULTILINE, RETURNS, EXECUTE AS
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.01.2008 at 07:23AM PDT, ID: 21908101

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_EXPERT_20070906