Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates

Connecting to the Enterprise Manager using the .NET client (& PowerShell script)

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Yossi_Shalom
Employee
Employee

Connecting to the Enterprise Manager using the .NET client (& PowerShell script)

Last Update:

Nov 4, 2020 11:46:08 AM

Updated By:

Yossi_Shalom

Created date:

Nov 4, 2020 11:42:11 AM

Environment

  • Enterprise manager 6.4 and above

The Enterprise Manager supplies 3 types of clients:

  1. REST
  2. Dotnet (using dlls)
  3. Python (using py files)

Client Modules

In this session we use the DotNet client tools to do the connection.
The location the dotnet dll files (py files for Python) is on:
<AEM installation folder>\clients\dotnet

The folder contains two dlls and one cs file:

  1. AemRestClient.dll
  2. Newtonsoft.Json.dll
  3. An example cs project.

Though not obligatory, copy the dll files to the working directory.
To enable PowerShell using these files, use the following command:

Import-Module

*If none is available in your organization the API could be approached directly.
Use the documentation (User guide).

e.g.
Use the following script to import the files:

clear
#Importing modules
$DotNetFolder = Split-Path $script:MyInvocation.MyCommand.Path
$DotNetRESTFile = $DotNetFolder + "\AemRestClient.dll"
$DotNetRESTFileJSON = $DotNetFolder + "\Newtonsoft.Json.dll"
Import-Module     $DotNetRESTFile -ErrorAction Stop
Import-Module     $DotNetRESTFileJSON -ErrorAction Stop

 

Authentication and Authorization

  • The AEM REST API uses the BASIC HTTP authorization scheme to authenticate callers and create a client session.
  • A client session is established using the AemLogin method, which returns the special header “EnterpriseManager.APISessionID” with a value (session token) that needs to be sent as a request header in following requests.
    This token is transparent to the dll users.
  • A session token expires 5 minutes after the last request.
    After the session expires, the caller must re-authenticate to establish a new session.
  • Authorization for performing a specific REST request relies on permission, assigned to the authenticated user either directly or by means of group membership.
  • Each REST request requires a minimum role, which is specified in the section describing the request.

Connecting to an AEM Server – Aem.RestClient

Initiating a connection to AEM is done by creating an object that contains all the methods necessary for working with the API.

The function is:
Attunity.Aem.RestClient.AemRestClien
It accept three parameters:

  1. Credential.
  2. The Enterprise Manager URL.
  3. verifyCertificate ($True/$False)

E.g.
$AEMServerConnection = New-Object Attunity.Aem.RestClient.AemRestClient($Credential, $AemURL, $false)

 

Final

To connect to Enterprise Manager you need to follow these steps:

  1. Load the client modules
  2. Gain credentials
  3. Use the Attunity.Aem.RestClient.AemRestClient module to do the actual connection.
  4. Repeat step 3 whenever you are disconnected.

The following script accepts credentials from the user and connect to an Enterprise Manager machine:

clear
#Importing modules
$DotNetFolder = Split-Path $script:MyInvocation.MyCommand.Path
$DotNetRESTFile = $DotNetFolder + "\AemRestClient.dll"
$DotNetRESTFileJSON = $DotNetFolder + "\Newtonsoft.Json.dll"
Import-Module     $DotNetRESTFile -ErrorAction Stop
Import-Module     $DotNetRESTFileJSON -ErrorAction Stop
#Accept the AEM server name
function Get-AEMServerAndUserName($AEM_Server_Name)
    {
    $script:AemServerName          = $AEM_Server_Name
    }
$AEMServerAndUserName = Invoke-Expression (Show-Command Get-AEMServerAndUserName -PassThru)
#Connecting to the server
$AemUserName = $env:userdomain + '\' + $env:username
$Credential = Get-Credential  -Message $AEMServerName -UserName $AemUserName
$AemURL = "https://" + $AEMServerName + "/attunityenterprisemanager"
$AEMServerConnection = New-Object Attunity.Aem.RestClient.AemRestClient($Credential, $AemURL, $false)


End.

 

Labels (1)
Version history
Last update:
‎2020-11-04 11:46 AM
Updated by: