Controlling Server Login
From InterBase
Go Up to Controlling Connections
InterBase servers include security features to prohibit unauthorized access. The server requires a user name and password login before permitting database access.
At design time, a standard Login dialog box prompts for a user name and password when you first attempt to connect to the database.
At runtime, there are three ways you can handle a request of a server for a login:
- Set the
LoginPrompt
property of a database component toTrue
(the default). Your application displays the standard Login dialog box when the server requests a user name and password. - Set the
LoginPrompt
toFalse
, and include hard-codedUSER_NAME
andPASSWORD
parameters in theParams
property for the database component. For example:
USER_NAME=SYSDBA PASSWORD=masterkey
Important:
Note that because the Params property is easy to view, this method compromises server security, so it is not recommended.
Note that because the Params property is easy to view, this method compromises server security, so it is not recommended.
- Write an
OnLogin
event for the database component, and use it to set login parameters at runtime.OnLogin
gets a copy of theParams
property of the database component, which you can modify. The name of the copy inOnLogin
isLoginParams
. Use theValues
property to set or change login parameters as follows:
LoginParams.Values['USER_NAME'] := UserName; LoginParams.Values['PASSWORD'] := PasswordSearch(UserName);
On exit, OnLogin
passes its LoginParams
values back to Params
, which is used to establish a connection.