Using events in Relativity Server to change ConnectionName

Hi there

Totally newbie using Javascript (actually ExtJS) to develop simple client for a web based app. Firebird 2.5 database is connected to the client app through DA and Relativity Server, using (for now) a single schema in domain. Everything works fine when using only one connection to the schema. Because this app should work in multi-tenancy model, with separate database per tenant, I try to figure out a solution to dinamically change connection for each user, when it login in.
According to the documentation, in the schema I have not specified any connection, nor “use default” option for tables, commands, etc.
So far I have tried:

  • from Javascript client, using MultiDbLoginService Login, to send user, pass and ConnectionName;
  • from Javascript client, using loginEx both with MultiDbLoginService and MultiDbLoginServiceV5, to send loginString, with user, pass, domain, schema and ConnectionName;
  • in Relativity Server, to use events like AfterLogin and BeforeLogin, in order to parse the available connections and set as current connection the appropriate connection for that user.
    I have read the posts regarding security issues for using loginEx to change the ConnectionName, and I hoped that at least, in Relativity Server I cant use the events like beforeLogin, but it didn’t work. Reading documentation about custom Delphi server I ended up in other events, like onBeforeAcquireConnection event.
    Any thoughts? How can I achieve this change of connection, other then writing custom server in Delphi or .Net? Can I use some event (beforeLogin) in Relativity? Can I create new events in Relativity (like onBeforeAcquireConnection);
    Best regards,

Daniel

P.S.
As mentioned, I already read posts regarding this issue. Some of them:

Of course, some posts are not related to Javascript, nevertheless I read them in order to understand how Relativity server works.

It seems you are trying to use Relativity Server is a way it was never supposed to.

In short words, there is no API to override the code paths used by Relativity to determine the connection to use. Simple custom Data Abstract server would be the best solution here.

Thanks for the quick reply, Antonk

Somehow, I was expecting this answer and I sincerely hope that this features, of dynamic change of connections, will make it on the wish-list one day. I think that Relativity Server is such a versatile tool and it deserve a chance in this respect, since multi-tenancy model is more and more often implemented in web-based app.
Only two more questions on this topic:

  • there are any login events in Relativity (such as beforeLogin)?
  • can you point me some example for the custom server, preferably in Delphi?

Thanks again,

Daniel

The thing is that we have to keep balance between versatility and how easy it is to use RS. Too much versatility is a bad thing too - after all to create complex and custom servers one can use full Data Abstract. Stretching the feature set of a precompiled server app can eventually turn this app into a bloated monster.

There are afterLogin / beforeLogout scrip events. Also we have plans to provide a way to attach custom login providers as plugins to a RS instance.

For .NET the simplest custom server that can be used as a sample is the one that is created using the New Project Wizard (just create a new project in VS and select the Data Abstract app template - the wizard will create both server and client apps for you)

Delphi:
You can easily create it with our DA wizard.
by other hand, you can review the DAServer sample.

OK, Thank you guys, for your time!