Solved

SQL Server Application Role Activation from within Delphi

Posted on 2004-08-26
3
286 Views
Last Modified: 2010-04-05
Hi all,

PLEASE HELP!

I am currently developing an app that connects to a SQL Server 2000 database. I would very much like to make use of the SQL Server Application Role functionality, but I cannot seem to get it working. I have tried using a ADOStoredProc, ADOQuery, ADOCommand and even the ADOConnection directly to execute the stored procedure to activate using the Application Role.

What I could understand from all the documentation is that I must switch the current open connection from the user login password (in my case using Windows Authentication) by using a stored procedure called master.dbo.sp_SetAppRole with parameters @rolename and @password.

I have successfully tested this in SQL Query Analyzer, but cannot get this working from within Delphi.

Regards,
Johan Swart
0
Comment
Question by:johan777
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
bpana earned 500 total points
ID: 11906822
hi,

I made a test and it is working as expected.

Drop a TADOConnection on the form. Set it's ConnectionString property the the database containing the role.
On the Form's create method:
procedure TForm1.FormCreate(Sender: TObject);
begin
  ADOConnection1.Execute('EXEC sp_setapprole ''Role_Inventory'', ''role''');
end;

drop a TADOTable on the form. Set it's connection to the ADOConnection1. Leave the Active property set to False

procedure TForm1.Button1Click(Sender: TObject);
begin
  ADOTable1.TableName := 'Inventory';
  ADOTable1.Open;
end;

Bogdan
0
 
LVL 6

Expert Comment

by:bpana
ID: 11906930
btw, i'm using SQL Authentication.
0
 

Author Comment

by:johan777
ID: 11908839
Hi Bogdan,

Thanx very much!!! It works.

I appreciate the help!

Regards,
Johan Swart
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question