将SQL登录凭证传递给Delphi Datasnap服务器最有效的方式? [英] Most efficient way to pass SQL Login credentials to Delphi Datasnap servers?

查看:163
本文介绍了将SQL登录凭证传递给Delphi Datasnap服务器最有效的方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



由于我的应用程序中的一些安全性在数据库级别处理,所以我需要传递一个用户的从我的客户端应用程序到我的Datasnap服务器的SQL凭据。



(如果可能,我试图使Datasnap服务器无状态,因此请确认每次调用都必须执行此操作。)



我在客户端使用ClientDatasets(CDS),所以我可以使用OnBeforeGetRecords将OwnerData OleVariant中的数据从客户端上的CDS传递到服务器上的相应TDataSetProvider。但这意味着每个数据模块上的每个CDS必须有一个这样做的事件,这似乎是凌乱而笨重的。我不禁要感觉到有一种方式可以将邮件传递到服务器上方。



我真正喜欢的是这样的服务器端的DSServerClass级别:

 过程TMyServerContainer.MyServerClassCreateInstance(DSCreateInstanceEventObject:TDSCreateInstanceEventObject); 
begin
//服务器检测客户端应用程序的数据请求
fUsername:= GetUsernameFromClientSomehow;
fPassword:= GetPasswordFromClientSomehow;

//创建数据模块和初始化
MyDataModule:= TMyDataModule.Create(nil);
MyDataModule.InitialiseWithSQLCredentials(fUsername,fPassword);
DSCreateInstanceEventObject.ServerClassInstance:= MyDataModule;
结束;

验证管理器组件可以帮助我吗?任何其他想法?或者我坚持使用OnBeforeGetRecords?



非常感谢。

解决方案

您可以使用SQL凭据作为UserName和Password连接到DataSnap服务器。这些值可以在验证管理器中验证,和/或简单地转发到基础的SQLConnection组件以连接到SQL服务器。


Using Delphi XE to build a relatively straightforward database app using Datasnap.

Since some security in my application is handled at the database level, I need to pass a user's SQL credentials from my client app to my Datasnap server.

(I'm trying to make the Datasnap server stateless if possible, so recognise that I will have to do this for every call.)

I'm using ClientDatasets (CDS) on the client side so I could use OnBeforeGetRecords to pass the data in the OwnerData OleVariant from the CDS on the client to the corresponding TDataSetProvider on the server. But that means every single CDS on every data module has to have an event that does this, which seems messy and unwieldy. I can't help feeling there must be a way to pass messages to the server at a higher level than that.

What I'd really like is something like this at the DSServerClass level on the server side:

Procedure TMyServerContainer.MyServerClassCreateInstance(DSCreateInstanceEventObject: TDSCreateInstanceEventObject); 
begin 
// Server detects request for data from client app 
fUsername := GetUsernameFromClientSomehow; 
fPassword := GetPasswordFromClientSomehow;

// create data modules and initialise
MyDataModule := TMyDataModule.Create(nil); 
MyDataModule.InitialiseWithSQLCredentials(fUsername, fPassword); 
DSCreateInstanceEventObject.ServerClassInstance := MyDataModule; 
End;

Could the Authentication Manager component help me here? Any other ideas? Or am I stuck with OnBeforeGetRecords?

Many thanks.

解决方案

You can use the SQL credentials as UserName and Password for connecting to the DataSnap server. These values can be verified in the Authentication Manager and/or simply forwarded to the underlying SQLConnection component for connecting to the SQL server.

这篇关于将SQL登录凭证传递给Delphi Datasnap服务器最有效的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆