Can I make PSM plugin to prompt for user input?

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

Welcome Idira to LIVEcommunity!

Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.

Meet Idira

Can I make PSM plugin to prompt for user input?

L2 Linker

Hi folks,

 

I am developing a custom PSM plugin, and I am facing a road blocker. There is a website in which three elements are there UserName, Passwd, and a drop down to select server instance. I need to develop something to prompt the user to select the server instance instead me hardcoding it. Is there any way I can do this? Thanks in advance.

 

Note: I have already referred the dropdown list article in CyberArk but did not find any solution.

 

1 accepted solution

Accepted Solutions

L1 Bithead

Hi @Azeem Mahammed​  To create a custom PSM (Privileged Session Manager) plugin that prompts the user to select a server instance from a dropdown instead of hardcoding it, you can follow these general steps:

 

Steps to Implement a Dynamic Dropdown in a Custom PSM Plugin

1. Define the Dropdown in Your Plugin Configuration

You need to define the dropdown in your plugin's configuration file. This typically involves specifying the dropdown options dynamically based on the available server instances.

 

2. Use JavaScript for Dynamic Dropdown Population

If your PSM plugin allows for JavaScript execution, you can use it to populate the dropdown dynamically. Here’s a basic example of how you might implement this:

 

// Example JavaScript to populate dropdown

function populateDropdown() {

  const dropdown = document.getElementById('serverInstanceDropdown');

  const serverInstances = getServerInstances(); // Function to fetch server instances

 

  serverInstances.forEach(instance => {

    const option = document.createElement('option');

    option.value = instance.value;

    option.text = instance.name;

    dropdown.add(option);

  });

}

// Call this function on page load

window.onload = populateDropdown;

 

3. Fetch Server Instances from an API or Configuration

You need a method to fetch the available server instances. This could be from an API endpoint or a configuration file. Ensure that this method returns the data in a format that can be easily used to populate the dropdown.

 

function getServerInstances() {

  // Example API call to fetch server instances

  return fetch('/api/server-instances')

    .then(response => response.json())

    .then(data => {

      return data.instances; // Assuming the API returns an object with an 'instances' array

    });

}

 

4. Integrate with the PSM Plugin Logic

Make sure that the selected value from the dropdown is correctly integrated into the authentication process. You may need to modify the form submission logic to include the selected server instance.

5. Testing and Validation

After implementing the above steps, thoroughly test the plugin to ensure that the dropdown is populated correctly and that the selected server instance is used in the authentication process.

6. Refer to CyberArk Documentation

Since you mentioned that you referred to the dropdown list article in CyberArk, ensure you check for any specific APIs or methods they provide for dynamic dropdowns. Sometimes, there are specific hooks or events that you need to listen to for the dropdown to work correctly.

 

Example of a Basic HTML Structure

Here’s a simple HTML structure that you might use in your plugin:

 

<form id="loginForm">

  <label for="username">UserName:</label>

  <input type="text" id="username" name="username" required>

   

  <label for="password">Password:</label>

  <input type="password" id="password" name="password" required>

   

  <label for="serverInstanceDropdown">Select Server Instance:</label>

  <select id="serverInstanceDropdown" name="serverInstance" required>

    <option value="">Select...</option>

  </select>

   

  <button type="submit">Login</button>

</form>

 

By following these steps, you should be able to create a dynamic dropdown for server instance selection in your custom PSM plugin. If you encounter specific issues during implementation, feel free to ask for more detailed assistance!

View solution in original post

5 REPLIES 5

L4 Transporter

Hi @Azeem Mahammed​  You can add a custom parameter or PSMRemoteMachine parameter to store the instance name list.

Based on the selection, you can select the instance name from the website drop down menu.

L4 Transporter

Hi @Azeem Mahammed​  You can add a custom parameter or PSMRemoteMachine parameter to store the instance name list.

Based on the selection, you can select the instance name from the website drop down menu.

L1 Bithead

Hi @Azeem Mahammed​  To create a custom PSM (Privileged Session Manager) plugin that prompts the user to select a server instance from a dropdown instead of hardcoding it, you can follow these general steps:

 

Steps to Implement a Dynamic Dropdown in a Custom PSM Plugin

1. Define the Dropdown in Your Plugin Configuration

You need to define the dropdown in your plugin's configuration file. This typically involves specifying the dropdown options dynamically based on the available server instances.

 

2. Use JavaScript for Dynamic Dropdown Population

If your PSM plugin allows for JavaScript execution, you can use it to populate the dropdown dynamically. Here’s a basic example of how you might implement this:

 

// Example JavaScript to populate dropdown

function populateDropdown() {

  const dropdown = document.getElementById('serverInstanceDropdown');

  const serverInstances = getServerInstances(); // Function to fetch server instances

 

  serverInstances.forEach(instance => {

    const option = document.createElement('option');

    option.value = instance.value;

    option.text = instance.name;

    dropdown.add(option);

  });

}

// Call this function on page load

window.onload = populateDropdown;

 

3. Fetch Server Instances from an API or Configuration

You need a method to fetch the available server instances. This could be from an API endpoint or a configuration file. Ensure that this method returns the data in a format that can be easily used to populate the dropdown.

 

function getServerInstances() {

  // Example API call to fetch server instances

  return fetch('/api/server-instances')

    .then(response => response.json())

    .then(data => {

      return data.instances; // Assuming the API returns an object with an 'instances' array

    });

}

 

4. Integrate with the PSM Plugin Logic

Make sure that the selected value from the dropdown is correctly integrated into the authentication process. You may need to modify the form submission logic to include the selected server instance.

5. Testing and Validation

After implementing the above steps, thoroughly test the plugin to ensure that the dropdown is populated correctly and that the selected server instance is used in the authentication process.

6. Refer to CyberArk Documentation

Since you mentioned that you referred to the dropdown list article in CyberArk, ensure you check for any specific APIs or methods they provide for dynamic dropdowns. Sometimes, there are specific hooks or events that you need to listen to for the dropdown to work correctly.

 

Example of a Basic HTML Structure

Here’s a simple HTML structure that you might use in your plugin:

 

<form id="loginForm">

  <label for="username">UserName:</label>

  <input type="text" id="username" name="username" required>

   

  <label for="password">Password:</label>

  <input type="password" id="password" name="password" required>

   

  <label for="serverInstanceDropdown">Select Server Instance:</label>

  <select id="serverInstanceDropdown" name="serverInstance" required>

    <option value="">Select...</option>

  </select>

   

  <button type="submit">Login</button>

</form>

 

By following these steps, you should be able to create a dynamic dropdown for server instance selection in your custom PSM plugin. If you encounter specific issues during implementation, feel free to ask for more detailed assistance!

Hi @Imran Shaik​ , thank you for your input. I really appreciate it.

Hi @Sumit Kumar​ , sure I will give it a try. Thank you.

  • 1 accepted solution
  • 164 Views
  • 5 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!