How to integrate PowerServer 2022 R2 ?

Estimated reading: 4 minutes 135 views


  • PowerBuilder 2022 R2
  • PowerServer 2022 R2
  • Visual-Guard Identity server 2020.3
  • .NET Core 6.0

Steps to Configure Visual Guard for PowerServer

Create and configure the PowerServer project as described in the PowerServer documentation.

  • Make sure “Use external auth service” and “I have read and agree to the license…” options are selected, as shown in the figure below.
  • Build and deploy the PowerServer project and make sure the application is deployed and PowerServer C# solution is generated successfully.

Go to the PowerServer C# solution > ServerAPIs project, add a reference to “Novalys.VisualGuard.Security.PowerServer.dll”. (You can get this DLL file from the Visual Guard Setup or the NuGet website).

In the PowerServer C# solution > UserExtensions project > UserStartup.cs file, modify the scripts as below (pay attention to the changes in the highlighted lines).

 public void ConfigureServices(IServiceCollection services)
            // Configures the services of the PowerServer AppConfig module
            services.AddPowerServerAppConfig(this.Configuration, this.HostingEnvironment);

            // Configures the services of the PowerServer Authentication module 

            //Adds Visual Guard Identity Server authentication/authorization to Power Server.

            // Configures the services of the PowerServer HealthCheck module 

            // Configures the services of the PowerServer Logging module 

            // Configures the services of the PowerServer OpenAPI module

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)

            if (this.HostingEnvironment.IsDevelopment())
                // Enables the exception page during development. It will list all exceptions for debugging

                // Configures the HTTP request pipeline for the PowerServer OpenAPI module

            // Adds middleware for redirecting HTTP Requests to HTTPS.

            // Configures the HTTP request pipeline for the PowerServer Logging module


            // Enables the compression of responses

            //Adds Visual Guard Middleware            

            // Enables authentication

            // Enables authorization

            // Enables the welcome page

            // Configures the HTTP request pipeline for the PowerServer HealthCheck module

            app.UseEndpoints(endpoints =>
                // Adds the controller to the HTTP request pipeline

Configure Visual Guard PowerServer configuration in the C# solution > UserExtensions project > AppConfig folder > AppConfig.json file. Here you can add all actions to be excluded, points to Visual Guard Identity Server, enables trace and much more.

  // Sets the environment type when starting PowerServer
  // The value can be overwritten by commandline argument, environment variable or other imported configuration under the identical name
  // see

  // For example, in the project folder, execute: dotnet run -- --POWERSERVER_ENVIRONMENTTYPE=Development
  // see

  // Or, in the output directory, execute: dotnet ServerAPIs.dll --POWERSERVER_ENVIRONMENTTYPE=Development

  "ConnectionStrings": {
    // Saves the  connection string of the db that saves the configuration data. Will be referenced in AppConfigExtensions.AddPowerServerAppConfig 
    "AppConfig": "<appconfig connection string>"
  "VGPSConfiguration": {
    "ExcludeActions": [
    "IdentityServerUrl": "",
    "TraceLevel": "Verbose",
    "VGRACMode": "Silence",
    "PolicyName": "ServerAPIs",
    "PowerServerVersion": "V2022"

Now in Visual Guard Console, add your Power Server application in the repository and create the desired permissions with Power Server security.

Click on Power Server Security and assign the CRUD operation accordingly to each data window or table and save it.

You can also map each PB component to new or added table. Right click on the VG application and click “Map PB Components”. Click on Save and Close.

In case new PB components are added to the application, you can refresh the same by right clicking on VG application and selecting “Reload all components for PB application”.

Assign the permission to role and to user or group accordingly.

Now, in PowerBuilder application login form, authenticate the user via Visual Guard Identity Server. Call the Visual Guard Identity Server and on success, sets the Bearer Token.

Now on each request to PowerServer, Visual Guard Token will be passed as Bearer as Authorization Request Header and will permit the user as per the rights assigned.