delphiauthenticationdatasnapmulti-tier

Datasnap server authentication problem with remote database of users credentials


The situation is: Datasnap client connecting to Datasnap server with his credentials. Authentication procedure starts with server makes a request to remote database which holds users credentials. If credentials matches - all good, authentication is done. But what if remote database is unavailable at this moment? How can i push to client something like "Server is not available at the moment, try again later" while authenticating? Or second case: the user is blocked (to realize this we need to access database too) and i want to tell him a reason why he can't access to service? I was googling this issue, but i still don't understand the right way to do it.

Any tip can be helpful, thanks in advance and have a nice day!


Solution

  • The DSAuthenticationManager.OnUserAuthenticate event can only return True or False, and if it returns False, the exception that is raised at the client is predetermined.

    One solution to this is to have your OnUserAuthenticate always return a True value, then in your client, call a servermethod of your own design, that returns a message that you have coded as appropriate for the situation it found. I return my message as a var parameter to the servermethod.