company logo

Initiate login process

Usually, no login is required when opening a database. In order to protect database access against unauthorized use, database access can be protected by requesting user login.

User login may be requested via console prompt or GUI dialog. Typically, console prompt login is requested for console applications, i.e. when the system recognizes a console application. When running an application within the ODABA GUI framework (ode), usually login is requested via login dialog.

In order to request login, DatabaseContext ::login() function has to be called while opening the database. For console applications, there is a default login function implemented ( DatabaseContext ::executeLogin() ), which prompts user to enter user name and user password. DatabaseContext ::login() may be overloaded.

Notes:

Default DatabaseContext ::login() function only runs, when either CONSOLE_APPLICATION is set or when running a console (non ODABA GUI framework) application.

Invoke login

In order to check user name and password, the login() function may be be called in the database context while opening the database ( doBeforeOpen() handler). The login function receives a property handle, which refers to the ADM_User extent or to an application specific user collection containing login information.

In order to pass the login request to the application context, the DatabaseContext ::login() function calls the ProjectContext ::executeLogin() function when running in an GUI application context. When running a console application, the database context function DatabaseContext ::executeLogin() will be called.

There are default implementations in the GUI project context class ( ProjectContext ) and in the DatabaseContext class. T he default implementation pops up with default console prompts or login dialog requesting user name and password. In order to run default login functions, users in the collection passed to login() function have to be ordered by login name. Moreover, an attribute with the name password is required, which contains the user's login password. When the password is empty, it will be set to the first value entered by the user after it has been confirmed.

After login, the login user is selected in the user property handle passed to the function.

  if ( dbhandle.IsClient() ) { // do not run login on the server

    PropertyHandle     user(dbhandle,"ADM_User",PI_Read);

    if ( login(&user) )           // calls executeLogin

      return(YES);                // error logging in

//  ... further login processing. Login user is selected in user

  }

Related topics