I am trying to launch Active Directory Client from PSM. While testing the dispatcher on PSM node using AutoIt3 i am getting the error message: PSMGeneric ClientWrapper Error: Failed to call DLL funtion SendPID(1)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I am trying to launch Active Directory Client from PSM. While testing the dispatcher on PSM node using AutoIt3 i am getting the error message: PSMGeneric ClientWrapper Error: Failed to call DLL funtion SendPID(1)

1 accepted solution

Accepted Solutions

i put the applocker in audit, run the PSMConfigureApplocker and also enabled shadow user permission to launch the app.

View solution in original post

14 REPLIES 14

L1 Bithead

@Ashish Shrestha​ Please check the Event Viewer to see what's blocking and make sure you are adding mmc.exe in applocker. And could you paste code of line client executable to check what you are running.

 

L4 Transporter

To me it looks like maybe some issue in your AUTOIT script regarding the location where its trying to send PID? Have you tried to run script outside of CyberArk. Try to run script directly from PSM and see whether that gives you same error

@Rahel Ahmed​ i have been trying to run the script directly on the PSM server and getting this error . I have not tried outside the CyberArk. components. Do you recommend me to run script in a separate machine?

Apologies i mean to say run Manually from PSM. Rather than connecting to PVWA and then connecting to the Connection Component. You can run the script using command line from PSM.

 

Also do you have other AutoIT Scripts in the same PSM machine, and are they able to connect successfully? If that is the case, it might truly be an issue with the script.

@Pramod Ayi​ 

Below are the errors i see in Event Viewers

 

Field_Content_versions_oct20__0682J000007gaPbQAI.pngField_Content_versions_oct20__0682J000007gaPWQAY.png

 

Below is the client executable that i am running.

 

#AutoIt3Wrapper_UseX64=n

Opt("MustDeclareVars", 1)

AutoItSetOption("WinTitleMatchMode", 3) ; EXACT_MATCH!

AutoItSetOption("WinDetectHiddenText",1)

 

;============================================================

;       PSM AutoIt Dispatcher Skeleton

;       ------------------------------

;

; Use this skeleton to create your own

; connection components integrated with the PSM.

; Areas you may want to modify are marked

; with the string "CHANGE_ME".

;

; Created : April 2013

; Cyber-Ark Software Ltd.

;============================================================

#include "PSMGenericClientWrapper.au3"

 

;=======================================

; Consts & Globals

;=======================================

Global Const $DISPATCHER_NAME = "Microsoft ADUC" ; CHANGE_ME

Global Const $CLIENT_EXECUTABLE = 'mmc "C:\PSMApps\dsa.msc"'; CHANGE_ME

Global Const $ERROR_MESSAGE_TITLE  = "PSM " & $DISPATCHER_NAME & " Dispatcher error message"

Global Const $LOG_MESSAGE_PREFIX = $DISPATCHER_NAME & " Dispatcher - "

 

Global $TargetUsername

Global $TargetPassword

Global $TargetAddress

Global $TargetLogonDomain

Global $ConnectionClientPID = 0

 

;=======================================

; Code

;=======================================

Exit Main()

 

;=======================================

; Main

;=======================================

Func Main()

;ConsoleWrite("sending PID to PSM ------------- ")

; Init PSM Dispatcher utils wrapper

ToolTip ("Initializing...")

if (PSMGenericClient_Init() <> $PSM_ERROR_SUCCESS) Then

;Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

ConsoleWrite("successfully initialized Dispatcher Utils Wrapper")

 

; Get the dispatcher parameters

;FetchSessionProperties()

 

;ConsoleWrite("mapping local drives")

;if (PSMGenericClient_MapTSDrives() <> $PSM_ERROR_SUCCESS) Then

;Error(PSMGenericClient_PSMGetLastErrorString())

;EndIf

 

ConsoleWrite("starting client application")

ToolTip ("Starting " & $DISPATCHER_NAME & "...")

 

; ------------------

; Handle login here! ; CHANGE_ME

; ------------------

$TargetUsername = "";i have my username here

$TargetPassword = ""; i have my password here

$TargetAddress=""; i have the ip of psm node here

$TargetLogonDomain = ""; i have the logon domain name here

; Execute RunAs command to run ssms under the PSM Shdaow User's profile, but pass the network credentials of

   ; the target (specified by the "2" logon type)

 

$ConnectionClientPID = RunAs($TargetUsername,$TargetLogonDomain,$TargetPassword,2,$CLIENT_EXECUTABLE)

if ($ConnectionClientPID == 0) Then

Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error))

EndIf

 

; Send PID to PSM so recording/monitoring can begin

; Notice that until we send the PID, PSM blocks all user input.

LogWrite("sending PID to PSM")

if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then

Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

; Terminate PSM Dispatcher utils wrapper

LogWrite("Terminating Dispatcher Utils Wrapper")

PSMGenericClient_Term()

 

Return $PSM_ERROR_SUCCESS

 

EndFunc

 

;==================================

; Functions

;==================================

; #FUNCTION# ====================================================================================================================

; Name...........: Error

; Description ...: An exception handler - displays an error message and terminates the dispatcher

; Parameters ....: $ErrorMessage - Error message to display

;   $Code - [Optional] Exit error code

; ===============================================================================================================================

Func Error($ErrorMessage, $Code = -1)

 

; If the dispatcher utils DLL was already initialized, write an error log message and terminate the wrapper

if (PSMGenericClient_IsInitialized()) Then

LogWrite($ErrorMessage, True)

PSMGenericClient_Term()

EndIf

 

Local $MessageFlags = BitOr(0, 16, 262144) ; 0=OK button, 16=Stop-sign icon, 262144=MsgBox has top-most attribute set

 

MsgBox($MessageFlags, $ERROR_MESSAGE_TITLE, $ErrorMessage)

 

; If the connection component was already invoked, terminate it

if ($ConnectionClientPID <> 0) Then

ProcessClose($ConnectionClientPID)

$ConnectionClientPID = 0

EndIf

 

Exit $Code

EndFunc

 

; #FUNCTION# ====================================================================================================================

; Name...........: LogWrite

; Description ...: Write a PSMWinSCPDispatcher log message to standard PSM log file

; Parameters ....: $sMessage - [IN] The message to write

;         $LogLevel - [Optional] [IN] Defined if the message should be handled as an error message or as a trace messge

; Return values .: $PSM_ERROR_SUCCESS - Success, otherwise error - Use PSMGenericClient_PSMGetLastErrorString for details.

; ===============================================================================================================================

Func LogWrite($sMessage, $LogLevel = $LOG_LEVEL_TRACE)

Return PSMGenericClient_LogWrite($LOG_MESSAGE_PREFIX & $sMessage, $LogLevel)

EndFunc

 

; #FUNCTION# ====================================================================================================================

; Name...........: PSMGenericClient_GetSessionProperty

; Description ...: Fetches properties required for the session

; Parameters ....: None

; Return values .: None

; ===============================================================================================================================

Func FetchSessionProperties() ; CHANGE_ME

if (PSMGenericClient_GetSessionProperty("Username", $TargetUsername) <> $PSM_ERROR_SUCCESS) Then

Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

if (PSMGenericClient_GetSessionProperty("Password", $TargetPassword) <> $PSM_ERROR_SUCCESS) Then

Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

;if (PSMGenericClient_GetSessionProperty("Address", $TargetAddress) <> $PSM_ERROR_SUCCESS) Then

; Error(PSMGenericClient_PSMGetLastErrorString())

;EndIf

 

if (PSMGenericClient_GetSessionProperty("LogonDomain", $TargetLogonDomain) <> $PSM_ERROR_SUCCESS) Then ;Added CWA

Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

EndFunc

 

@Ashish Shrestha​ Can you disable applocker and try connecting or add include autoit.exe in applocker.

@Rahel Ahmed​ ya run the script through command line in PSM the same error pops out. I don't have any other AutoIT scripts on this machine.

During this deployment

 

1.The first thing i did is copied and modified the PSMDispatcherskeleton as below: :

 

#AutoIt3Wrapper_UseX64=n

Opt("MustDeclareVars", 1)

AutoItSetOption("WinTitleMatchMode", 3) ; EXACT_MATCH!

AutoItSetOption("WinDetectHiddenText",1)

 

;============================================================

;       PSM AutoIt Dispatcher Skeleton

;       ------------------------------

;

; Use this skeleton to create your own

; connection components integrated with the PSM.

; Areas you may want to modify are marked

; with the string "CHANGE_ME".

;

; Created : April 2013

; Cyber-Ark Software Ltd.

;============================================================

#include "PSMGenericClientWrapper.au3"

 

;=======================================

; Consts & Globals

;=======================================

Global Const $DISPATCHER_NAME = "Microsoft ADUC" ; CHANGE_ME

Global Const $CLIENT_EXECUTABLE = 'mmc "C:\PSMApps\dsa.msc"'; CHANGE_ME

Global Const $ERROR_MESSAGE_TITLE = "PSM " & $DISPATCHER_NAME & " Dispatcher error message"

Global Const $LOG_MESSAGE_PREFIX = $DISPATCHER_NAME & " Dispatcher - "

 

Global $TargetUsername

Global $TargetPassword

Global $TargetAddress

Global $TargetLogonDomain

Global $ConnectionClientPID = 0

 

;=======================================

; Code

;=======================================

Exit Main()

 

;=======================================

; Main

;=======================================

Func Main()

 

;ConsoleWrite("sending PID to PSM ------------- ")

; Init PSM Dispatcher utils wrapper

ToolTip ("Initializing...")

if (PSMGenericClient_Init() <> $PSM_ERROR_SUCCESS) Then

;Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

ConsoleWrite("successfully initialized Dispatcher Utils Wrapper")

 

; Get the dispatcher parameters

;FetchSessionProperties()

 

;ConsoleWrite("mapping local drives")

;if (PSMGenericClient_MapTSDrives() <> $PSM_ERROR_SUCCESS) Then

;Error(PSMGenericClient_PSMGetLastErrorString())

;EndIf

 

ConsoleWrite("starting client application")

ToolTip ("Starting " & $DISPATCHER_NAME & "...")

 

; ------------------

; Handle login here! ; CHANGE_ME

; ------------------

 

$TargetUsername = "";i have my username here

$TargetPassword = ""; i have my password here

$TargetAddress=""; i have the ip of psm node here

$TargetLogonDomain = ""; i have the logon domain name here

 

; Execute RunAs command to run ssms under the PSM Shdaow User's profile, but pass the network credentials of

  ; the target (specified by the "2" logon type)

 

$ConnectionClientPID = RunAs($TargetUsername,$TargetLogonDomain,$TargetPassword,2,$CLIENT_EXECUTABLE)

if ($ConnectionClientPID == 0) Then

Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error))

EndIf

 

; Send PID to PSM so recording/monitoring can begin

; Notice that until we send the PID, PSM blocks all user input.

LogWrite("sending PID to PSM")

if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then

Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

; Terminate PSM Dispatcher utils wrapper

LogWrite("Terminating Dispatcher Utils Wrapper")

PSMGenericClient_Term()

 

Return $PSM_ERROR_SUCCESS

 

 

EndFunc

 

;==================================

; Functions

;==================================

; #FUNCTION# ====================================================================================================================

; Name...........: Error

; Description ...: An exception handler - displays an error message and terminates the dispatcher

; Parameters ....: $ErrorMessage - Error message to display

;  $Code - [Optional] Exit error code

; ===============================================================================================================================

Func Error($ErrorMessage, $Code = -1)

 

; If the dispatcher utils DLL was already initialized, write an error log message and terminate the wrapper

if (PSMGenericClient_IsInitialized()) Then

LogWrite($ErrorMessage, True)

PSMGenericClient_Term()

EndIf

 

Local $MessageFlags = BitOr(0, 16, 262144) ; 0=OK button, 16=Stop-sign icon, 262144=MsgBox has top-most attribute set

 

MsgBox($MessageFlags, $ERROR_MESSAGE_TITLE, $ErrorMessage)

 

; If the connection component was already invoked, terminate it

if ($ConnectionClientPID <> 0) Then

ProcessClose($ConnectionClientPID)

$ConnectionClientPID = 0

EndIf

 

Exit $Code

EndFunc

 

; #FUNCTION# ====================================================================================================================

; Name...........: LogWrite

; Description ...: Write a PSMWinSCPDispatcher log message to standard PSM log file

; Parameters ....: $sMessage - [IN] The message to write

;         $LogLevel - [Optional] [IN] Defined if the message should be handled as an error message or as a trace messge

; Return values .: $PSM_ERROR_SUCCESS - Success, otherwise error - Use PSMGenericClient_PSMGetLastErrorString for details.

; ===============================================================================================================================

Func LogWrite($sMessage, $LogLevel = $LOG_LEVEL_TRACE)

Return PSMGenericClient_LogWrite($LOG_MESSAGE_PREFIX & $sMessage, $LogLevel)

EndFunc

 

; #FUNCTION# ====================================================================================================================

; Name...........: PSMGenericClient_GetSessionProperty

; Description ...: Fetches properties required for the session

; Parameters ....: None

; Return values .: None

; ===============================================================================================================================

Func FetchSessionProperties() ; CHANGE_ME

if (PSMGenericClient_GetSessionProperty("Username", $TargetUsername) <> $PSM_ERROR_SUCCESS) Then

Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

if (PSMGenericClient_GetSessionProperty("Password", $TargetPassword) <> $PSM_ERROR_SUCCESS) Then

Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

;if (PSMGenericClient_GetSessionProperty("Address", $TargetAddress) <> $PSM_ERROR_SUCCESS) Then

; Error(PSMGenericClient_PSMGetLastErrorString())

;EndIf

 

if (PSMGenericClient_GetSessionProperty("LogonDomain", $TargetLogonDomain) <> $PSM_ERROR_SUCCESS) Then ;Added CWA

Error(PSMGenericClient_PSMGetLastErrorString())

EndIf

 

EndFunc

 

2. second thing i did is

 

On PSMConfigureApplocker.xml i have added

 <Application Name="mmc" Type="Exe" Path="C:\Windows\System32\mmc.exe" Method="Publisher" />

 

3. i run the psmhardening script and PSMConfigureApplocker

 

Did i miss any further steps here?

I have not gone throught PVWA target settings yet caz i am getting the above error here while testing the AutoIt scripts.

@Pramod Ayi​ 

 

i included the following line in PSMConfigureApplocker.xml and run the script

 <Application Name="mmc" Type="Exe" Path="C:\Windows\System32\mmc.exe" Method="Publisher" />

@Ashish Shrestha​  Best option is disable applocker and try connection. If there it worked then you can include autoit.exe in applocker.

@Pramod Ayi​  Thank you i was able to fix it

@Rahel Ahmed​ Thank you i was able to fix it

@Ashish Shrestha​ Great! What you did to fix issue?

i put the applocker in audit, run the PSMConfigureApplocker and also enabled shadow user permission to launch the app.

@Ashish Shrestha​ can you tell which all permissions should be granted to shadow users? I am facing the same issue.

  • 1 accepted solution
  • 1236 Views
  • 14 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!