Icon Server Administration

Introduction
Administering a database server involves maintaining global connection settings as well as databases, server-side procedures, users, and scheduled events. All of this information is stored in the configuration file specified via the TDBISAMEngine ServerConfigFileName property. DBISAM offers the ability to administer a database server both locally through the TDBISAMEngine component and remotely through the TDBISAMSession component. Both types of administration are very similar except for some minor differences.

Local Administration
Local administration of a database server involves calling methods of the TDBISAMEngine component directly. The following methods are all for local administrative use:

MethodDescription
GetServerConfigThis method retrieves the global database server settings for maximum allowed connections, connection timeouts, dead session settings, the temporary files directory, and authorized and blocked IP addresses.
ModifyServerConfigThis method modifies the global database server settings.
GetServerLogCountThis method retrieves the total number of log records present in the current log file. Calling this method triggers the TDBISAMEngine OnServerLogCount event. If an event handler is defined for this event, then it is called to retrieve the count from whatever storage medium is being used for the log file.
GetServerLogRecordThis method retrieves the Nth log record from the current log file. Calling this method triggers the TDBISAMEngine OnServerLogRecord event. If an event handler is defined for this event, then it is called to retrieve the specified log record from whatever storage medium is being used for the log file.
StartAdminServerThis method causes the database server to begin listening for administrative connections on the IP address and port specified by the TDBISAMEngine ServerAdminAddress and ServerAdminPort properties.
StopAdminServerThis method causes the database server to stop listening for administrative connections.
StartMainServerThis method causes the database server to begin listening for regular data connections on the IP address and port specified by the TDBISAMEngine ServerMainAddress and ServerMainPort properties. Calling this method triggers the TDBISAMEngine OnServerStart event.
StopMainServerThis method causes the database server to stop listening for regular data connections. Calling this method triggers the TDBISAMEngine OnServerStop event.
GetServerUTCDateTimeThis method retrieves the current date and time from the server in UTC (Coordinated Universal Time).
GetServerUpTimeThis method retrieves the total up time of the database server in seconds.
GetServerMemoryUsageThis method has been deprecated and always returns 0 as of version 4.17 of DBISAM and the introduction of the new memory manager used in the DBISAM database server. Please see the Replacement Memory Manager topic for more information.
GetServerSessionCountThis method retrieves the total number of sessions present on the database server at the time of the method call.

Information This count does not include administrative sessions, only regular sessions.
GetServerConnectedSessionCountThis method retrieves the total number of sessions on the database server that are currently connected at the time of the method call.

Information This count does not include administrative sessions, only regular sessions.
GetServerSessionInfoThis method retrieves information about the specified session such as its unique session ID, when it was created, when it was last connected, the user name, the IP address of the user, and whether the connection is encrypted.

Information This method does not return information about administrative sessions, only regular sessions.
DisconnectServerSessionThis method disconnects the specified session, but does not remove the session from the database server. Once the session is disconnected it is considered to be a dead session.

Information This method cannot be used on administrative sessions, only regular sessions.
RemoveServerSessionThis method removes the specified session completely from the database server.

Information This method cannot be used on administrative sessions, only regular sessions.
GetServerUserNamesThis method will retrieve a list of user names that are currently defined on the database server.
GetServerUserThis method will retrieve information about a specific user, including the user's password, a description of the user, and whether the user is an administrator for this server.
AddServerUserThis method will add a new user.
ModifyServerUserThis method will modify a user's information.
ModifyServerUserPasswordThis method will modify only a user's password.
DeleteServerUserThis method will delete a user.
GetServerDatabaseNamesThis method will retrieve a list of database names that are currently defined on the database server.
GetServerDatabaseThis method will retrieve information about a specific database, including the database's description and the actual physical path to the database tables.

Information All database server physical path information for databases defined on the server are interpreted relative to the drives, directories, etc. available to the database server.
AddServerDatabaseThis method will add a new database.
ModifyServerDatabaseThis method will modify a database's information.
DeleteServerDatabaseThis method will delete a database.
GetServerDatabaseUserNamesThis method will retrieve a list of users that are assigned rights to a specific database.
GetServerDatabaseUserThis method will retrieve the user rights of a user for a specific database.
AddServerDatabaseUserThis method will add user rights for a specific user to a specific database.
ModifyServerDatabaseUserThis method will modify the user rights of a user for a specific database.
DeleteServerDatabaseUserThis method will delete the user rights of a user for a specific database.
GetServerProcedureNamesThis method will retrieve a list of server-side procedure names that are currently defined on the database server.
GetServerProcedureThis method will retrieve information about a specific server-side procedure, specifically the server-side procedure's description.
AddServerProcedureThis method will add a new server-side procedure.
ModifyServerProcedureThis method will modify a server-side procedure's information.
DeleteServerProcedureThis method will delete a server-side procedure.
GetServerProcedureUserNamesThis method will retrieve a list of users that are assigned rights to a specific server-side procedure.
GetServerProcedureUserThis method will retrieve the user rights of a user for a specific server-side procedure.
AddServerProcedureUserThis method will add user rights for a specific user to a specific server-side procedure.
ModifyServerProcedureUserThis method will modify the user rights of a user for a specific server-side procedure.
DeleteServerProcedureUserThis method will delete the user rights of a user for a specific server-side procedure.
GetServerEventNamesThis method will retrieve a list of scheduled event names that are currently defined on the database server.
GetServerEventThis method will retrieve information about a specific scheduled event, specifically the scheduled event's description and scheduling parameters.
AddServerEventThis method will add a new scheduled event.
ModifyServerEventThis method will modify a scheduled event's information.
DeleteServerEventThis method will delete a scheduled event.

Remote Administration
Remotely administering a database server involves connecting to the server's administration port using a TDBISAMSession component that has the following properties set properly:

PropertySetting
SessionTypeThis property must be set to stRemote.
RemoteEncryptionThis property must be set to True.
RemoteEncryptionPasswordThis property must be set to the same password as the ServerEncryptionPassword property of the TDBISAMEngine component that the session is connecting to.
RemoteAddressThis property must be set to the IP address of the database server as it appears to remote machines. You may optionally use the RemoteHost property if there is DNS information available for the database server that you are connecting to.
RemotePortThis property must be set to the administrative port as it appears to remote machines. You may optionally use the RemoteService property if there is service information available for the database server administrative port that you are connecting to.

Information There is an important distinction to make here. The IP address and port specified for a remote session is not always the same as the IP address and port specified in the ServerAdminAddress and ServerAdminPort properties of the TDBISAMEngine component that the session is connecting to. This is because network routers can use port forwarding and other techniques to forward network traffic destined for a specific public IP address and port to a private, internal LAN IP address and port.
RemoteUserThis property must be set to the name of a valid administrator user for the database server that you are connecting to.
RemotePasswordThis property must be set to the proper password for the user name specified by the RemoteUser property.

Once you have set up the TDBISAMSession properties properly for administrative access you can proceed to call the TDBISAMSession Open method or set the TDBISAMSession Active property to True. This will cause the remote session to attempt to connect to the database server on the administrative port. Provided that you have set up everything properly, you will connect to the database server on the administrative port and can then proceed to use the remote administrative methods of the TDBISAMSession component to administer the database server.

The remote administration methods of the TDBISAMSession component are identical to the local methods of the TDBISAMEngine component except that the TDBISAMSession methods are named *Remote* instead of *Server*. Also, there are no StartAdminServer or StopAdminServer methods, and the StartMainServer and StopMainServer methods are called StartRemoteServer and StopRemoteServer, respectively. For a complete list of the remote administration methods please see the TDBISAMSession component.

The following example shows how to set up the TDBISAMSession properties for remotely administering a database server, connect to the database server, add a new user (not an administrator), and then add user rights to the "AccountingDB" database for this user:

begin
   with MyDBISAMSession do
      begin
      SessionType:=stRemote;
      RemoteEncryption:=True;
      { Assume the default encryption password in use }
      RemoteAddress:='192.168.0.1';
      RemotePort:=12006;
      RemoteUser:='Admin';
      RemotePassword:='DBAdmin';
      Open;
      try
         AddRemoteUser('Test','Test123456','Test User',False);
         AddRemoteDatabaseUser('AccountingDB','Test',
                               [drRead,drInsert,drUpdate,drDelete]);
      finally
         Close;
      end;
      end;
end;

Information The Server Administration Utility that can be found in the additional software download (DBISAM-ADD) on the Elevate Software web site also comes complete with source code and demonstrates how to use all of the remote administration functionality described above.
Image