Where Cybersecurity Meets Career Success – SecApps Learning

CyberArk CPM Plugins: Complete Guide (When to Create, C# Code, DLL Build, Testing & Deployment)

  • Home
  • Blog
  • CyberArk CPM Plugins: Complete Guide (When to Create, C# Code, DLL Build, Testing & Deployment)
Image
  • April 29 2026

CyberArk CPM Plugins: Complete Guide (When to Create, C# Code, DLL Build, Testing & Deployment)

In CyberArk Privileged Access Management (PAM), the Central Policy Manager (CPM) is responsible for:

  • Password Rotation

  • Password Verification

  • Reconciliation

But what if your target system is not supported out-of-the-box?

πŸ‘‰ That’s where CPM Plugins come into play.


🧠 What is a CPM Plugin?

A CPM Plugin is a custom-developed integration that allows CyberArk to:

  • Connect to unsupported systems

  • Verify passwords

  • Change passwords

  • Reset credentials (Reconcile)

πŸ‘‰ Built using:

  • C# (.NET SDK) (Recommended)

  • PowerShell / Python (limited cases)


⚠️ MOST IMPORTANT: When Do You Need CPM Plugin?

This is the #1 interview + real-world question πŸ”₯


βœ… You NEED CPM Plugin when:

  • Managing Local Website Accounts

  • Managing Custom Applications

  • Managing Unsupported OS / Systems

  • No plugin available in Marketplace


❌ You DO NOT NEED CPM Plugin when:

Example:

πŸ‘‰ You are accessing AWS / Web App using Domain Account

βœ” Use:

  • Windows Domain Platform

  • PSM Web Connector

πŸ‘‰ No CPM plugin needed ❌


πŸ”₯ Golden Rule

Scenario CPM Plugin Required?
Domain account → website ❌ No
Local website account βœ… Yes
Custom application βœ… Yes
No API / No automation ❌ Impossible

⚠️ Critical Limitation (Must Understand)

Before coding, ask:

πŸ‘‰ Can password be changed programmatically?

❌ OTP required → FAIL
❌ No API / UI automation → FAIL

If system cannot be automated, CPM plugin will NOT work.


πŸ—οΈ CPM Plugin Workflow

CyberArk Vault → CPM → Plugin DLL → Target System
                   ↓
           Verify / Change / Reconcile
                   ↓
              Return Status

πŸ› οΈ Prerequisites

πŸ”Ή Install Visual Studio

Download:
πŸ‘‰ https://visualstudio.microsoft.com/downloads/

βœ” Select:

  • .NET Desktop Development


πŸ”Ή Required DLLs (from CPM Server)

C:\Program Files (x86)\CyberArk\Password Manager\bin

Add references:

  • CyberArk.Extensions.Utilties.dll

  • CyberArk.Extensions.Plugins.Models.dll


πŸ—οΈ Step-by-Step CPM Plugin Development


πŸ“ Step 1: Create Project

  1. Open Visual Studio

  2. Create New Project

  3. Select:
    πŸ‘‰ Class Library (.NET Framework)

  4. Name:

    SecAppsCPMPlugin
    

🧩 Step 2: BaseAction Class

using System.Collections.Generic;
using CyberArk.Extensions.Plugins.Models;
using CyberArk.Extensions.Utilties;

namespace SecAppsCPMPlugin
{
    public abstract class BaseAction : AbsAction
    {
        public BaseAction(List accountList, ILogger logger)
            : base(accountList, logger)
        {
        }

        protected string GetPassword(System.Security.SecureString secStr)
        {
            return new System.Net.NetworkCredential("", secStr).Password;
        }
    }
}

πŸ” Step 3: VERIFY Action

using System;
using System.Collections.Generic;
using CyberArk.Extensions.Plugins.Models;

namespace SecAppsCPMPlugin
{
    public class VerifyAction : BaseAction
    {
        public VerifyAction(List accountList, ILogger logger)
            : base(accountList, logger)
        {
        }

        public override CPMAction ActionName
        {
            get { return CPMAction.verifypass; }
        }

        public override int run(ref PlatformOutput platformOutput)
        {
            try
            {
                string username = TargetAccount.AccountProp["username"];
                string address = TargetAccount.AccountProp["address"];
                string password = GetPassword(TargetAccount.CurrentPassword);

                Logger.Info($"Verifying {username} at {address}");

                if (!string.IsNullOrEmpty(password))
                {
                    platformOutput.Message = "Verify successful";
                    return 0;
                }

                platformOutput.Message = "Invalid password";
                return 8801;
            }
            catch (Exception ex)
            {
                platformOutput.Message = "Verify failed: " + ex.Message;
                return 8800;
            }
        }
    }
}

πŸ”„ Step 4: CHANGE Action

using System;
using System.Collections.Generic;
using CyberArk.Extensions.Plugins.Models;

namespace SecAppsCPMPlugin
{
    public class ChangeAction : BaseAction
    {
        public ChangeAction(List accountList, ILogger logger)
            : base(accountList, logger)
        {
        }

        public override CPMAction ActionName
        {
            get { return CPMAction.changepass; }
        }

        public override int run(ref PlatformOutput platformOutput)
        {
            try
            {
                string username = TargetAccount.AccountProp["username"];
                string address = TargetAccount.AccountProp["address"];

                string oldPassword = GetPassword(TargetAccount.CurrentPassword);
                string newPassword = GetPassword(TargetAccount.NewPassword);

                Logger.Info($"Changing password for {username}");

                bool success = true;

                if (success)
                {
                    platformOutput.Message = "Password changed successfully";
                    return 0;
                }

                platformOutput.Message = "Password change failed";
                return 8802;
            }
            catch (Exception ex)
            {
                platformOutput.Message = "Change failed: " + ex.Message;
                return 8800;
            }
        }
    }
}

πŸ” Step 5: LOGON Action

public class LogonAction : BaseAction
{
    public LogonAction(List accountList, ILogger logger)
        : base(accountList, logger)
    {
    }

    public override CPMAction ActionName
    {
        get { return CPMAction.logon; }
    }

    public override int run(ref PlatformOutput platformOutput)
    {
        platformOutput.Message = "Logon successful";
        return 0;
    }
}

πŸ—οΈ Step 6: Build DLL

πŸ‘‰ Build Solution

Output:

bin\Debug\SecAppsCPMPlugin.dll

πŸ§ͺ Step 7: Manual Testing (Before CyberArk)

πŸ“ Required Files

  • Plugin DLL

  • CANetPluginInvoker.exe

  • Required DLLs


πŸ“ user.ini File

[targetaccount]
username=admin1
password=OldPass123
newpassword=NewPass123
address=secappslearning.com
safename=TestSafe
objectname=admin1
PolicyID=TestPlatform

▢️ Run Commands

CANetPluginInvoker.exe user.ini verifypass SecAppsCPMPlugin.dll true
CANetPluginInvoker.exe user.ini changepass SecAppsCPMPlugin.dll true

πŸš€ Step 8: Deploy in CyberArk

πŸ“Œ Copy DLL

C:\Program Files (x86)\CyberArk\Password Manager\bin


πŸ“Œ Update Platform

  • Add plugin DLL name


πŸ“Œ Restart Service

CyberArk Password Manager

πŸ§ͺ Step 9: Test in PVWA

βœ” Verify Password
βœ” Change Password

Check:

  • CPM Logs

  • PVWA Audit


πŸ” Best Practices

βœ” Never hardcode passwords
βœ” Always use ILogger
βœ” Use proper return codes
βœ” Test manually first


⚠️ Common Mistakes

❌ Wrong platform
❌ No API support
❌ Ignoring workflow
❌ OTP-based systems


πŸ† Interview Questions

  • When do you create CPM plugin?

  • Difference between Change & Reconcile?

  • What if OTP required?

  • How to test plugin manually?

  • What is BaseAction?


πŸ“Œ Conclusion

πŸ‘‰ Coding is easy
πŸ‘‰ Understanding the system is everything

“If target system cannot be automated, CPM plugin will fail.”

Comments ()

Leave a reply

Your email address will not be published. Required fields are marked*

Recent Post

Copyright 2022 SecApps Learning. All Right Reserved