Easily Integrate PingOne Data in Lazarus Pascal IDE



Learn how to easily integrate live PingOne data in Lazarus Pascal IDE using the CData ODBC Driver for real-time insights.

Lazarus Pascal IDE is a powerful, free, open-source development environment for building cross-platform applications. With the CData ODBC Driver for PingOne, you can seamlessly integrate and query live PingOne data, bringing real-time insights within your Lazarus Pascal IDE applications to enhance reporting, dashboards, and workflows.

This guide provides a comprehensive walkthrough, from setting up the connection to leveraging live PingOne in Lazarus Pascal IDE. Whether you're building reports, dashboards, or complex workflows, you'll gain the tools to unlock real-time insights and functionality within your applications.

Overview

Here is an overview of the steps:

  1. Configure the DSN for PingOne data in the CData ODBC Driver for PingOne with the necessary connection properties.
  2. Set up the ODBC connection in Lazarus by configuring the TSQLConnector, TSQLQuery, TDataSource, and TDBGrid components with the required details.
  3. Test the connection to PingOne data by writing sample code on the Main form.
  4. Compile and run the application to verify the successful integration and display of live PingOne data.

Prerequisites

Before starting, ensure you have the following:

  • Lazarus IDE (version 3.4 recommended). Download from here.
  • CData ODBC Driver for PingOne. Download and try the latest version from here.


Configure the PingOne DSN Using the CData ODBC Driver

To start, configure the DSN (Data Source Name) for PingOne data in your system using the CData ODBC Driver for PingOne. Download and install a 30-day free trial with all the features from here.

Once installed, launch the ODBC Data Source Administrator:

  • On Windows: Search for ODBC Data Source Administrator in the Start menu and open the application.
  • On Mac: Open Applications, go to Utilities, and select ODBC Manager.
  • On Linux: Use the command line to launch ODBC Data Source Administrator or use unixODBC if installed.

Once launched, double-click on the CData PingOne data Source and enter the required values to establish a connection:

To connect to PingOne, configure these properties:

  • Region: The region where the data for your PingOne organization is being hosted.
  • AuthScheme: The type of authentication to use when connecting to PingOne.
  • Either WorkerAppEnvironmentId (required when using the default PingOne domain) or AuthorizationServerURL, configured as described below.

Configuring WorkerAppEnvironmentId

WorkerAppEnvironmentId is the ID of the PingOne environment in which your Worker application resides. This parameter is used only when the environment is using the default PingOne domain (auth.pingone). It is configured after you have created the custom OAuth application you will use to authenticate to PingOne, as described in Creating a Custom OAuth Application in the Help documentation.

First, find the value for this property:

  1. From the home page of your PingOne organization, move to the navigation sidebar and click Environments.
  2. Find the environment in which you have created your custom OAuth/Worker application (usually Administrators), and click Manage Environment. The environment's home page displays.
  3. In the environment's home page navigation sidebar, click Applications.
  4. Find your OAuth or Worker application details in the list.
  5. Copy the value in the Environment ID field. It should look similar to:
    WorkerAppEnvironmentId='11e96fc7-aa4d-4a60-8196-9acf91424eca'

Now set WorkerAppEnvironmentId to the value of the Environment ID field.

Configuring AuthorizationServerURL

AuthorizationServerURL is the base URL of the PingOne authorization server for the environment where your application is located. This property is only used when you have set up a custom domain for the environment, as described in the PingOne platform API documentation. See Custom Domains.

Authenticating to PingOne with OAuth

PingOne supports both OAuth and OAuthClient authentication. In addition to performing the configuration steps described above, there are two more steps to complete to support OAuth or OAuthCliet authentication:

  • Create and configure a custom OAuth application, as described in Creating a Custom OAuth Application in the Help documentation.
  • To ensure that the driver can access the entities in Data Model, confirm that you have configured the correct roles for the admin user/worker application you will be using, as described in Administrator Roles in the Help documentation.
  • Set the appropriate properties for the authscheme and authflow of your choice, as described in the following subsections.

OAuth (Authorization Code grant)

Set AuthScheme to OAuth.

Desktop Applications

Get and Refresh the OAuth Access Token

After setting the following, you are ready to connect:

  • InitiateOAuth: GETANDREFRESH. To avoid the need to repeat the OAuth exchange and manually setting the OAuthAccessToken each time you connect, use InitiateOAuth.
  • OAuthClientId: The Client ID you obtained when you created your custom OAuth application.
  • OAuthClientSecret: The Client Secret you obtained when you created your custom OAuth application.
  • CallbackURL: The redirect URI you defined when you registered your custom OAuth application. For example: https://localhost:3333

When you connect, the driver opens PingOne's OAuth endpoint in your default browser. Log in and grant permissions to the application. The driver then completes the OAuth process:

  1. The driver obtains an access token from PingOne and uses it to request data.
  2. The OAuth values are saved in the location specified in OAuthSettingsLocation, to be persisted across connections.

The driver refreshes the access token automatically when it expires.

For other OAuth methods, including Web Applications, Headless Machines, or Client Credentials Grant, refer to the Help documentation.

Create a New GUI Project

  1. Launch the Lazarus IDE.
  2. Navigate to File > New > Application to create a new GUI project with a Main form.

Add Required Connection Components to the Form

  1. Go to View > Component > Palette and check the Keep open at the bottom-left to keep the Components window persistently open.
  2. Search for the following components and add them to the Main form Form1 by clicking on Use at the bottom right.
    1. TSQLConnector
    2. TSQLTransaction
    3. TSQLQuery
    4. TDataSource
    5. TDBGrid


Configure the TSQLConnector Component

The TSQLConnector component in Lazarus Pascal IDE facilitates connections between your application and various databases or database APIs. Here's how to configure it:

  1. Select the TSQLConnector component on the Main form.
  2. Open the Object Inspector if it's not already open by going to View > Object Inspector
  3. In the Object Inspector on the left, set the following properties under the Properties section:
    Property Value
    Connected True
    Driver ODBC
    DatabaseName Your DSN name (e.g., CData PingOne Source)
    UserName Your database username
    Password Your database password
    HostName PingOne URL or localhost for local databases
    LoginPrompt False
    Transaction Select your TSQLTransaction component

If your credentials require a security token, follow these steps:

  1. Double-click the Main Form in the Lazarus Pascal IDE to open the code editor.
  2. Locate the procedure TForm1.FormCreate(Sender: TObject); section.
  3. Paste the following code below the begin keyword. Replace 'your_security_token' with your actual security token: SQLConnector1.Params.Values ['Password'] := SQLConnector1.Params.Values ['Password'] + 'your_security_token';



Configure the TSQLQuery Component

The TSQLQuery component in Lazarus Pascal IDE receives SQL code for queries and retrieves data from a database, simplifying data manipulation. Configure using the following info:

  1. Select the TSQLQuery component in the Main form.
  2. Set the following properties in the Object Inspector under the Properties section:
    Property Value
    Active True
    DataBase Select the name of your TSQLConnector component
    SQL (Click 3 dots) Your query (e.g., SELECT * FROM [CData].[Administrators].Users)
    Transaction Your TSQLTransaction component




Configure the TDataSource, TDBGrid, TSQLTransaction Components

The TDataSource component in Lazarus Pascal IDE bridges a dataset (e.g., TSQLQuery) with data-aware controls like TDBGrid, allowing data to be displayed and manipulated. The TDBGrid presents the data in a tabular format, while the TSQLTransaction ensures database operations maintain data integrity by executing within a transaction. Here's how to configure all three components:

  1. Select the TDataSource component and set its DataSet property to the name of your TSQLQuery component.
  2. Select the TDBGrid component and set its DataSource property to your TDataSource component.
  3. Select the TSQLTransaction component. Set the following properties:
    1. Active: True
    2. Database: The name of your TSQLConnector component


Add Code to Test the Connection

To successfully test the connection, use the following code:

  1. Double-click on the Main Form to open up the Source Editor.
  2. Add the following code under the begin keyword and before the end. keyword.
procedure TForm1.FormCreate(Sender: TObject); begin // Code for your Security Token SQLConnector1.Params.Values ['Password'] := SQLConnector1.Params.Values ['Password'] + 'your_security_token'; try SQLConnector1.Open; ShowMessage('Connection successful!'); except on E: Exception do ShowMessage('Error: ' + E.Message); end; try SQLQuery1.Open; if SQLQuery1.IsEmpty then ShowMessage('No data found.') else ShowMessage('Data loaded successfully.'); except on E: Exception do ShowMessage('Error: ' + E.Message); end; end; end.

Compile and Run the Application

Save your project. Go to Run > Compile, then Run, or use the shortcut F9 to execute your application.



Next Steps: Play with the Data

Now that your data is successfully imported into Lazarus, here are some ideas to explore its full potential:

  • Enhance Your TDBGrid: Customize your TDBGrid to enable sorting, editing, or highlighting specific rows.
  • Visualize Your Data: Use components like TChart to create graphs and charts for intuitive data representation.
  • Filter and Search: Use components like TDBFilter or implement custom filtering logic to allow users to quickly focus on relevant data. Add a TEdit component for user input and link it to your filtering functionality.
  • Export Your Data: Utilize TSVExport or TFileStream components to save your data in formats like CSV or Excel for sharing or integration into other systems.
  • Perform Calculations: Use TFPCustomDataSet or your dataset's built-in features to calculate totals, averages, or other metrics. Display results in a TLabel or add them to your TDBGrid.
  • Create Forms and Reports: Design interactive forms using TForm and TDBEdit for user interaction. For reports, integrate components like RLReport or FastReport to generate and print professional-quality reports.

Take your data-driven application to the next level with these enhancements!



Simplify Data Connectivity in Lazarus with CData

Unlock the full potential of live PingOne data directly within Lazarus Pascal. Streamline your workflows, enhance productivity, and experience seamless integration like never before.

Start your free trial today and transform the way you connect and work with your data!

Ready to get started?

Download a free trial of the PingOne ODBC Driver to get started:

 Download Now

Learn more:

PingOne Icon PingOne ODBC Driver

The PingOne ODBC Driver is a powerful tool that allows you to connect with live data from PingOne, directly from any applications that support ODBC connectivity.

Access PingOne data like you would a database - read, write, and update PingOne 0, etc. through a standard ODBC Driver interface.