We have a server written in Delphi that uses RemObjects DataAbstract/SDK. We would like to use Windows authentication to authenticate users to allow them access to our server.
Currently we do the following:
1) Client application sends the Windows username and password in clear text to the server. 2) The server checks the credentials using the following function:
function ValidateUserLogonAPI(const UserName: string; const Domain: string;
const PassWord: string) : boolean;
var
Retvar: boolean;
LHandle: THandle;
begin
Retvar := LogonUser(PWideChar(UserName),
PWideChar(Domain),
PWideChar(PassWord),
LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT,
LHandle);
if Retvar then
CloseHandle(LHandle);
Result := Retvar;
end;
Of course, this method has the disadvantage that the user credentials are passed over the network in clear text. We could encrypt them, but the encryption/decryption keys would have to be shipped within the application.
I'm sure there must be a better way of achieving our goal. I've read a bit about tokens, but don't really understand how they would work in this situation.
Note that she solution must work for both a Delphi Windows client and a Delphi Prism ASP.NET client.
Thanks for any help you can give.