Symantec Privileged Access Management

  • 1.  How to extract specific parameter from CLI output XML string

    Posted Feb 21, 2018 06:37 AM

    Hi All,

    I am using CLI API's to integrate CAPAM in my application.

    I am working on viewAccountPassword command to view the password of account.

    I am bleto run this CLI through my windows system and able to get the output in xml String.

    But the output contains lot of parameters related to TargetAccount inclusing password value and I want to fetch exact parameter(password) from the output XML string.

    In documentation I am unable to find the way to extract specific parameter from xml OR how we can get output only the required param as a string instead of entire XML string.

     

    Could you please help me to resolve this?

     

    Below is the command I am using : 

    capam_command capam=capam_ipaddress adminUserID=1234 adminPassword=password cmdName=viewAccountPassword TargetAccount.ID=1164 reason="Power outage reason" reasonDetails="Recover Tuesday am" > viewPwd.xml
     



  • 2.  Re: How to extract specific parameter from CLI output XML string

    Posted Feb 23, 2018 03:12 PM

    This ended up in CA PPM instead of CA PAM by mistake - hopefully this move takes it to a better place to raise this question.  Thanks.



  • 3.  Re: How to extract specific parameter from CLI output XML string

    Posted Feb 26, 2018 12:58 AM

    Thank you Nick for showing interest in my question.

     

    But this doesn't resolve my query. I am using CA-PAM CLI API.

    With CLI is it possible to apply filter to get specific parameter value?



  • 4.  Re: How to extract specific parameter from CLI output XML string

    Posted Feb 26, 2018 07:47 AM

    Hi Nick,

     

    Coincidentally, I'm trying to do this with Target Group, to create and add filter.

     

    We are using PowerShell to do that, I think it will work for you too.

     

    I'm searching for the ID of the Target Group created and after that adding a filter.

     

    $search = "<ID>(.*?)</ID>"

     

    #$return= 'capam_command cspmHostName=***.***.***.*** adminUserID=user cmdName=addGroup Group.name='Test '"Group.description='Test descript'" Group.type=target'

     

    $id_group = [regex]::Match($return,$search).Groups[1].Value

        capam_command cspmHostName=***.***.***.*** adminUserID=user cmdName=addFilter Group.ID=$id_group Filter.objectClassId=c.cw.m.ts Filter.attribute=hostName Filter.type=equals Filter.expression=myHost

     

    Regards,

     

    Gustavo Viggiano



  • 5.  Re: How to extract specific parameter from CLI output XML string

    Posted Feb 26, 2018 08:08 AM

    Hi Viggiano ,

    How you are able to execute CAPAM CLI with powershell? is there any module available for that? Tell me the procedure.

    Also even I have applied filter to extract parameter by using powershell as well as batch commands, but on XML output file and not with the CAPAM CLI.

     

    I want that filter to work on CLI directly and not by manipulating the output string with the help of external commands.

     



  • 6.  Re: How to extract specific parameter from CLI output XML string

    Broadcom Employee
    Posted Feb 26, 2018 09:37 AM

    Hello, Currently the format of the CLI command output is fixed. If this doesn't work for you and you would like to have different output formats, please raise an idea (==enhancement request) in this community. If you are retrieving the password for use with an application, consider use of the A2A client.



  • 7.  Re: How to extract specific parameter from CLI output XML string

    Posted Feb 27, 2018 01:01 AM

    Thank you for the confirmation.



  • 8.  Re: How to extract specific parameter from CLI output XML string
    Best Answer

    Posted Feb 28, 2018 03:40 PM

    Hi Nick,

     

    You just need to open the powershell on your Windows machine, goes to the path of your CLI and execute the following code (you just need to change what is in bold)

     

    This code search for the, for example, account "root" and return the ID of this account and after that the CLI search for this ID and return the password. I'm using regex to get the attribute that I want on the XML return.

     

    $hostName='[changeToYourHost]'
    $user='[changeToYourUser]'
    $pass='[changeToThePassOfYourUser]'
    $accountToSearch='[ChangeToTheUserThatYouWantThePassword]'

     

    $command = '.\capam_command'
    $command_credential = @("cspmHostName=$($hostName)", "adminUserID=$($user)", "adminPassword=$($pass)")
    $command_operation_search = @('cmdName=searchTargetAccount', "TargetAccount.userName=$($accountToSearch)")

     

    $result = & $command $command_credential $command_operation_search
    $search = "<ID>(.*?)</ID>"
    $id_account = [regex]::Match($result,$search).Groups[1].Value
    Write-Host = $id_account

     

    $command_operation_getpwd = @('cmdName=viewAccountPassword', "TargetAccount.ID=$($id_account)")

     

    $result = & $command $command_credential $command_operation_getpwd
    $search = "<password>(.*?)</password>"
    $password = [regex]::Match($result,$search).Groups[1].Value
    Write-Host = $password

     

     

    Hope this helps

     

    Make sure that you can execute PowerShell scripts in your machine:

     

    about_Execution_Policies | Microsoft Docs