Data.DB.TCustomConnection.LoginPrompt
Delphi
property LoginPrompt: Boolean read FLoginPrompt write FLoginPrompt default False;
C++
__property bool LoginPrompt = {read=FLoginPrompt, write=FLoginPrompt, default=0};
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
property | public | Data.DB.pas Data.DB.hpp |
Data.DB | TCustomConnection |
Description
Specifies whether a login dialog appears immediately before opening a new connection.
Set LoginPrompt to true to provide login support when establishing a connection. LoginPrompt controls two things: the occurrence of the OnLogin event, and the appearance of a default login dialog that prompts users for a name and password. To link a login dialog:
- For non-FireDAC applications: Include DBLogDlg.hpp in your unit (C++) or add DBLogDlg to your uses clause (Delphi).
- For FireDAC applications: Use the TFDGUIxLoginDialog component.
The time when the OnLogin event occurs and the time when the default login dialog appears are dependent on the type of connection component:
- For TIBDatabase, TSQLConnection, and TFDConnection, the dialog appears after the BeforeConnect event and before the AfterConnect event, unless you supply an OnLogin event handler.
- If there is an OnLogin event handler, that event occurs in place of the login dialog, and there is no need to link login dialog.
- If correct values for the user name and password are not supplied in the dialog or by the OnLogin event handler, the connection fails. The OnLogin event does not fire unless LoginPrompt is set to true.
- For TADOConnection components, the dialog appears after the OnWillConnect event and before the BeforeConnect event.
- If there is an OnLogin event handler, that event occurs after the login dialog.
- If you do not include DBLogDlg.hpp in your unit (C++) or add DBLogDlg to your uses clause (Delphi), the OnLogin event occurs but there is no default login dialog.
- If correct values for the user name and password are not supplied in the dialog or by the OnLogin event handler, the connection fails. The OnLogin event does not fire unless LoginPrompt is set to true.
- For DataSnap SOAP connection components, the dialog appears after the OnGetUsername event and before the BeforeConnect, AfterConnect, and OnLogin events. If the user cancels from the login dialog, no attempt is made to open a connection.
When LoginPrompt is false, the application must supply user name and password values programmatically:
- For TADOConnection, the user name and password can be supplied as the ConnectionString property.
- For TSQLConnection, the user name, password, and database can be supplied as UserName, Password, and Database parameters in the Params property, or provided as connection parameters associated with the connection name.
- For DataSnap SOAP connection components, there is no built-in use for the user name and password supplied by the login dialog. (The UserName and Password properties of TWebConnection are unrelated).
- For TFDConnection, the user name and password can be supplied as User_Name and Password parameters in the Params property, or provided as parameters associated with the connection definition.
Warning: Storing hard-coded user name and password entries as property values or in code for an OnLogin event handler can compromise server security.