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 to True (the default). Your application displays the standard Login dialog box when the server requests a user name and password.
  • Set the LoginPrompt to False, and include hard-coded USER_NAME and PASSWORD parameters in the Params 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.
  • Write an OnLogin event for the database component, and use it to set login parameters at runtime. OnLogin gets a copy of the Params property of the database component, which you can modify. The name of the copy in OnLogin is LoginParams. Use the Values 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.

Advance To: