DelineaSS

Delinea Secret Server and Platform is the fully featured Privileged Account Management (PAM) solution available both on premise and in the cloud. It empowers security and IT ops teams to secure and manage all types of privileged accounts and offers the fastest time to value of any PAM solution.

Authentication & Identity Management · Delinea Secret Server

Details

IDDelineaSS
ProviderDelinea
CategoryAuthentication & Identity Management
From Version6.5.0
Docker Imagedemisto/python3:3.12.13.10116658
Supported ModulesAgentix XSIAM

README

Secret Server and Platform is the fully featured Privileged Account Management (PAM) solution available both on premise and in the cloud. It empowers security and IT ops teams to secure and manage all types of privileged accounts and offers the fastest time to value of any PAM solution.
This integration was integrated and tested with version 5.0 of Delinea

Configure Delinea in Cortex

Parameter Description Required
url Server URL (e.g. https://example.net) True
credentials Username True
insecure Trust any certificate (not secure) False
proxy Use system proxy settings False
isFetchCredentials Fetches credentials False
credentialobjects List secret name for fetch credentials (separated by commas) False

Commands

You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

delinea-secret-password-get


Retrieved password from secret

Base Command

delinea-secret-password-get

Input

Argument Name Description Required
secret_id ID secret Required

Context Output

Path Type Description
Delinea.Secret.Password String Retrieved password from secret

Command Example

!delinea-secret-password-get secret_id=2

Context Example

{
    "Delinea": {
        "Secret": {
            "Password": "1234567890"
        }
    }
}

delinea-secret-username-get


Retrieved username from secret

Base Command

delinea-secret-username-get

Input

Argument Name Description Required
secret_id ID secret Required

Context Output

Path Type Description
Delinea.Secret.Username String Retrieved username from secret.

Command Example

!delinea-secret-username-get secret_id=2

Context Example

{
    "Delinea": {
        "Secret": {
            "Username": "w2\\w2"
        }
    }
}

delinea-secret-search-name


Search ID secret by field name

Base Command

delinea-secret-search-name

Input

Argument Name Description Required
search_name Search name secret. Required

Context Output

Path Type Description
Delinea.Secret.Id String Retrieved list ID for find secret by field secret name

Command Example

!delinea-secret-search-name search_name=xsoarSecret

Context Example

{
    "Delinea": {
        "Secret": {
            "Id": [
                5
            ]
        }
    }
}

delinea-secret-password-update


Update password for secret

Base Command

delinea-secret-password-update

Input

Argument Name Description Required
secret_id ID secret for update password Required
newpassword Value new password for secret Required

Context Output

Path Type Description
Delinea.Secret.Newpassword String New password changed for secret

Command Example

!delinea-secret-password-update secret_id=2 newpassword=12345

Context Example

{
    "Delinea": {
        "Secret": {
            "Newpassword": "12345"
        }
    }
}

delinea-secret-checkout


Check Out a secret

Base Command

delinea-secret-checkout

Input

Argument Name Description Required
secret_id ID secret for check out command Required

Context Output

Path Type Description
Delinea.Secret.Checkout String Return call command Check Out

Command Example

!delinea-secret-checkout secret_id=2

Context Example

{
    "Delinea": {
        "Secret": {
            "Checkout": {
            "responseCodes":null
            }
        }
    }
}

delinea-secret-checkin


Check In a secret

Base Command

delinea-secret-checkin

Input

Argument Name Description Required
secret_id Secret ID. Required

Context Output

Path Type Description
Delinea.Secret.Checkin String Secret object

Command Example

!delinea-secret-checkin secret_id=13

Context Example

{
    "Delinea": {
        "Secret": {
            "Checkin": {
                "active": true,
                "autoChangeEnabled": false,
                "checkOutEnabled": true,
                "checkedOut": false,
                "createDate": "2020-12-15T09:13:49.487",
                "daysUntilExpiration": null,
                "doubleLockEnabled": false,
                "extendedFields": null,
                "folderId": 3,
                "hidePassword": false,
                "id": 13,
                "inheritsPermissions": true,
                "isOutOfSync": false,
                "isRestricted": true,
                "lastAccessed": null,
                "lastHeartBeatStatus": "Pending",
                "lastPasswordChangeAttempt": "0001-01-01T00:00:00",
                "name": "secretT",
                "outOfSyncReason": "",
                "requiresApproval": false,
                "requiresComment": false,
                "responseCodes": null,
                "secretTemplateId": 6003,
                "secretTemplateName": "Windows Account",
                "siteId": 1
            }
        }
    }
}

delinea-folder-create


Create a new secret folder

Base Command

delinea-folder-create

Input

Argument Name Description Required
foldername Folder name Required
foldertypeid Folder type ID(1=< ID =< 3 Required
parentfolderid Parent folder ID Required
inheritPermissions Whether the folder should inherit permissions from its parent (default: true) Optional
inheritSecretPolicy Whether the folder should inherit the secret policy. Defaults to true unless creating a root folder. Optional
secretPolicyId Secret policy ID Optional

Context Output

Path Type Description
Delinea.Folder.Create Unknown New object folder

Command Example

!delinea-folder-create foldername="xsoarFolderTest" foldertypeid="1" parentfolderid="3"

Context Example

{
    "Delinea": {
        "Folder": {
            "Create": {
                "childFolders": null,
                "folderName": "xsoarFolderTest",
                "folderPath": "\\Personal Folders\\XSOAR integration\\xsoarFolderTest",
                "folderTypeId": 1,
                "id": 5,
                "inheritPermissions": false,
                "inheritSecretPolicy": false,
                "parentFolderId": 3,
                "secretPolicyId": -1,
                "secretTemplates": null
            }
        }
    }
}

delinea-folder-search


Search folder by name folder

Base Command

delinea-folder-search

Input

Argument Name Description Required
foldername Search name folder Required

Context Output

Path Type Description
Delinea.Folder.Id String Retrieved folder ID from search query

Command Example

!delinea-folder-search foldername="xsoarFolderTest"

Context Example

{
    "Delinea": {
        "Folder": {
            "Id": [
                5
            ]
        }
    }
}

Command Example

!delinea-folder-delete folder_id="18"

Context Example

{
    "Delinea": {
        "Folder": {
            "Delete": {
                "id": 18,
                "objectType": "Folder",
                "responseCodes": []
            }
        }
    }
}

delinea-secret-get


Get secret object by ID secret

Base Command

delinea-secret-get

Input

Argument Name Description Required
secret_id ID for secret Required

Context Output

Path Type Description
Delinea.Secret String Secret object

Command Example

!delinea-secret-get secret_id=2

Context Example

{
    "Delinea": {
        "Secret": {
            "accessRequestWorkflowMapId": -1,
            "active": true,
            "allowOwnersUnrestrictedSshCommands": false,
            "autoChangeEnabled": false,
            "autoChangeNextPassword": "2$C$7vl8*SN@",
            "checkOutChangePasswordEnabled": false,
            "checkOutEnabled": true,
            "checkOutIntervalMinutes": -1,
            "checkOutMinutesRemaining": 30,
            "checkOutUserDisplayName": "XSOAR integration",
            "checkOutUserId": 3,
            "checkedOut": true,
            "doubleLockId": -1,
            "enableInheritPermissions": true,
            "enableInheritSecretPolicy": true,
            "failedPasswordChangeAttempts": 0,
            "folderId": 3,
            "id": 2,
            "isDoubleLock": false,
            "isOutOfSync": false,
            "isRestricted": true,
            "items": [
                {
                    "fieldDescription": "The Server or Location of the Windows Machine.",
                    "fieldId": 83,
                    "fieldName": "Machine",
                    "fileAttachmentId": null,
                    "filename": null,
                    "isFile": false,
                    "isNotes": false,
                    "isPassword": false,
                    "itemId": 5,
                    "itemValue": "192.168.100.1",
                    "slug": "machine"
                },
                {
                    "fieldDescription": "The Username of the Windows User.",
                    "fieldId": 86,
                    "fieldName": "Username",
                    "fileAttachmentId": null,
                    "filename": null,
                    "isFile": false,
                    "isNotes": false,
                    "isPassword": false,
                    "itemId": 6,
                    "itemValue": "w2\\w2",
                    "slug": "username"
                },
                {
                    "fieldDescription": "The password of the Windows User.",
                    "fieldId": 85,
                    "fieldName": "Password",
                    "fileAttachmentId": null,
                    "filename": null,
                    "isFile": false,
                    "isNotes": false,
                    "isPassword": true,
                    "itemId": 7,
                    "itemValue": "1234567890",
                    "slug": "password"
                },
                {
                    "fieldDescription": "Any additional notes.",
                    "fieldId": 84,
                    "fieldName": "Notes",
                    "fileAttachmentId": null,
                    "filename": null,
                    "isFile": false,
                    "isNotes": true,
                    "isPassword": false,
                    "itemId": 8,
                    "itemValue": "",
                    "slug": "notes"
                }
            ],
            "lastHeartBeatCheck": "0001-01-01T00:00:00",
            "lastHeartBeatStatus": "Pending",
            "lastPasswordChangeAttempt": "0001-01-01T00:00:00",
            "launcherConnectAsSecretId": -1,
            "name": "test-w2",
            "outOfSyncReason": "",
            "passwordTypeWebScriptId": -1,
            "proxyEnabled": false,
            "requiresApprovalForAccess": false,
            "requiresComment": false,
            "responseCodes": [],
            "restrictSshCommands": false,
            "secretPolicyId": -1,
            "secretTemplateId": 6003,
            "secretTemplateName": "Windows Account",
            "sessionRecordingEnabled": false,
            "siteId": 1
        }
    }
}

delinea-secret-search


Search secret ID by multiply params

Base Command

delinea-secret-search

Input

Argument Name Description Required
filter.allowDoubleLocks Whether to allow DoubleLocks as part of the search. True by default Optional
filter.doNotCalculateTotal Whether to return the total number of secrets matching the filters. False by default Optional
filter.doubleLockId Only include Secrets with this DoubleLock ID assigned in the search results Optional
filter.extendedFields Names of Secret Template fields to return. Only exposed fields can be returned. Optional
filter.extendedTypeId Return only secrets matching a certain extended type Optional
filter.folderId Return only secrets within a certain folder Optional
filter.heartbeatStatus Return only secrets with a certain heartbeat status Optional
filter.includeActive Whether to include active secrets in results (when excluded equals true) Optional
filter.includeInactive Whether to include inactive secrets in results Optional
filter.includeRestricted Whether to include restricted secrets in results Optional
filter.isExactMatch Whether to do an exact match of the search text or a partial match Optional
filter.onlyRPCEnabled Whether to only include secrets whose template has Remote Password Changing enabled Optional
filter.onlySharedWithMe When true only Secrets where you are not the owner and the Secret was shared explicitly with your user id will be returned. Optional
filter.passwordTypeIds Return only secrets matching certain password types Optional
filter.permissionRequired Specify whether to filter by List, View, Edit, or Owner permission. Default is List. (List = 1, View = 2, Edit = 3, Owner = 4 Optional
filter.scope Specify whether to search AllSecrets, Recent, or Favorites (All = 1, Recent = 2,Favorites = 3 Optional
filter.searchField Field to search Optional
filter.searchFieldSlug Field-slug to search. This will override SearchField. Optional
filter.searchText Search text Optional
filter.secretTemplateId Return only secrets matching a certain template Optional
filter.siteId Return only secrets within a certain site Optional
skip Number of records to skip before taking results Optional
sortBy[0].direction Sort direction Optional
sortBy[0].name Sort field name Optional
sortBy[0].priority Priority index. Sorts with lower values are executed earlier Optional
take Maximum number of records to include in results Optional
filter.includeSubFolders Whether to include secrets in subfolders of the specified folder Optional

Context Output

Path Type Description
Delinea.Secret.Secret String Search secret object

Command Example

!delinea-secret-search filter_searchfields="username" filter_searchtext="xsoar"

Context Example

{
    "Delinea": {
        "Secret": {
            "Secret": [
                5
            ]
        }
    }
}

delinea-folder-update


Update a single secret folder by ID

Base Command

delinea-folder-update

Input

Argument Name Description Required
folderName Folder name Optional
folderTypeId Folder type ID Optional
id Folder ID. Must match ID in path Required
inheritPermissions Whether the folder inherits permissions from its parent Optional
inheritSecretPolicy Whether the folder inherits the secret policy Optional
parentFolderId ID parent folder Optional
secretPolicyId Secret Policy ID Optional

Context Output

Path Type Description
Delinea.Folder.Update String Retrieved return operation update folder

Command Example

!delinea-folder-update id=4 foldername="SafexsoarTest"

Context Example

{
    "Delinea": {
        "Folder": {
            "Update": {
                "childFolders": null,
                "folderName": "SafexsoarTest",
                "folderPath": "\\Personal Folders\\XSOAR integration\\SafexsoarTest",
                "folderTypeId": 1,
                "id": 4,
                "inheritPermissions": false,
                "inheritSecretPolicy": false,
                "parentFolderId": 3,
                "secretPolicyId": -1,
                "secretTemplates": null
            }
        }
    }
}

delinea-secret-create


Create new object Secret

Base Command

delinea-secret-create

Input

Argument Name Description Required
autoChangeEnabled AutoChangeEnabled options Optional
checkOutChangePasswordEnabled CheckOutChangePasswordEnabled options Optional
checkOutEnabled Whether secret checkout is enabled Optional
checkOutIntervalMinutes Checkout interval, in minutes (integer) Optional
enableInheritPermissions Whether the secret inherits permissions from the containing folder Optional
enableInheritSecretPolicy Whether the secret policy is inherited from the containing folder Optional
folderId Secret folder ID. May be null unless secrets are required to be in folders.(integer) Optional
launcherConnectAsSecretId LauncherConnectAsSecretId(integer) Optional
name Secret name Required
passwordTypeWebScriptId passwordTypeWebScriptId options(integer) Optional
proxyEnabled proxyEnabled options Optional
requiresCommen requiresCommen options Optional
secretPolicyId secretPolicyId options(integer) Optional
secretTemplateId Secret Template ID (integer) Required
sessionRecordingEnabled sessionRecordingEnabled options Optional
siteId siteId options (integer) Required
sshKeyArgs sshKeyArgs options(list args) Optional
domain_item Item Domain for secret. If need to select template. Optional
machine_item Item Machine for secret. If need to select template. Optional
username_item Item Username for secret.If need to select template. Optional
password_item Item Password for secret.If need to select template. Optional
notes_item Item Notes for secret.IF need to select template. Optional

Context Output

Path Type Description
Delinea.Secret.Create String Secret Model

Command Example

!delinea-secret-create name="xsoarSecret" secrettemplateid="6003" siteid="1" checkoutenabled=true folderid=3 machine_item="my-machine" username_item="my-username" password_item="XXXXXX@@@@@####"

Context Example

{
    "Delinea": {
        "Secret": {
            "Create": {
                "accessRequestWorkflowMapId": -1,
                "active": true,
                "allowOwnersUnrestrictedSshCommands": false,
                "autoChangeEnabled": false,
                "autoChangeNextPassword": null,
                "checkOutChangePasswordEnabled": false,
                "checkOutEnabled": true,
                "checkOutIntervalMinutes": -1,
                "checkOutMinutesRemaining": 0,
                "checkOutUserDisplayName": "",
                "checkOutUserId": 0,
                "checkedOut": false,
                "doubleLockId": 0,
                "enableInheritPermissions": true,
                "enableInheritSecretPolicy": false,
                "failedPasswordChangeAttempts": 0,
                "folderId": 3,
                "id": 5,
                "isDoubleLock": false,
                "isOutOfSync": false,
                "isRestricted": true,
                "items": [
                    {
                        "fieldDescription": "The Server or Location of the Windows Machine.",
                        "fieldId": 83,
                        "fieldName": "Machine",
                        "fileAttachmentId": null,
                        "filename": null,
                        "isFile": false,
                        "isNotes": false,
                        "isPassword": false,
                        "itemId": 19,
                        "itemValue": "my-machine",
                        "slug": "machine"
                    },
                    {
                        "fieldDescription": "The Username of the Windows User.",
                        "fieldId": 86,
                        "fieldName": "Username",
                        "fileAttachmentId": null,
                        "filename": null,
                        "isFile": false,
                        "isNotes": false,
                        "isPassword": false,
                        "itemId": 20,
                        "itemValue": "my-username",
                        "slug": "username"
                    },
                    {
                        "fieldDescription": "The password of the Windows User.",
                        "fieldId": 85,
                        "fieldName": "Password",
                        "fileAttachmentId": null,
                        "filename": null,
                        "isFile": false,
                        "isNotes": false,
                        "isPassword": true,
                        "itemId": 21,
                        "itemValue": "XXXXXX@@@@@####",
                        "slug": "password"
                    },
                    {
                        "fieldDescription": "Any additional notes.",
                        "fieldId": 84,
                        "fieldName": "Notes",
                        "fileAttachmentId": null,
                        "filename": null,
                        "isFile": false,
                        "isNotes": true,
                        "isPassword": false,
                        "itemId": 22,
                        "itemValue": "",
                        "slug": "notes"
                    }
                ],
                "lastHeartBeatCheck": "0001-01-01T00:00:00",
                "lastHeartBeatStatus": "Pending",
                "lastPasswordChangeAttempt": "0001-01-01T00:00:00",
                "launcherConnectAsSecretId": -1,
                "name": "xsoarSecret",
                "outOfSyncReason": "",
                "passwordTypeWebScriptId": -1,
                "proxyEnabled": false,
                "requiresApprovalForAccess": false,
                "requiresComment": false,
                "responseCodes": [],
                "restrictSshCommands": false,
                "secretPolicyId": -1,
                "secretTemplateId": 6003,
                "secretTemplateName": "Windows Account",
                "sessionRecordingEnabled": false,
                "siteId": 1
            }
        }
    }
}

delinea-secret-delete


Delete secret

Base Command

delinea-secret-delete

Input

Argument Name Description Required
id ID secret for delete Required

Context Output

Path Type Description
Delinea.Secret.Delete String Information about an object that was deleted

Command Example

!delinea-secret-delete id=2

Context Example

{
    "Delinea": {
        "Secret": {
            "Deleted": {
                "id": 2,
                "objectType": "Secret",
                "responseCodes": []
            }
        }
    }
}

delinea-secret-server-user-create


Create a new Secret Server user

Base Command

delinea-secret-server-user-create

Input

Argument Name Description Required
displayName User display name Required
password Password for new user Required
userName Username Required
adGuid Active Directory unique identifier Optional
domainId Active Directory domain ID Optional
duoTwoFactor Whether Duo two-factor authentication is enabled Optional
emailAddress User email address Optional
enabled Whether the user account is enabled Optional
fido2TwoFactor Whether Duo two-factor authentication is enabled Optional
isApplicationAccount IsApplicationAccount Optional
oathTwoFactor Whether OATH two-factor authentication is enabled Optional
radiusTwoFactor Whether RADIUS two-factor authentication is enabled Optional
radiusUserName RADIUS username Optional
twoFactor Whether two-factor authentication is enabled Optional

Context Output

Path Type Description
Delinea.Secret.Server.User.Create String User Model

Command Example

!delinea-secret-server-user-create displayname="UserOne" password="12345" username="UserOne"

Context Example

{
    "Delinea": {
        "User": {
            "Create": {
                "adAccountExpires":"0001-01-01T00:00:00",
                "adGuid":null,
                "created":"2022-06-01T08:31:15.275Z",
                "dateOptionId":-1,
                "displayName":"UserOne",
                "domainId":-1,
                "duoTwoFactor":false,
                "emailAddress":null,
                "enabled":true,
                "externalUserSource":"None",
                "fido2TwoFactor":false,
                "id":29,
                "ipAddressRestrictions":null,
                "isApplicationAccount":false,
                "isEmailCopiedFromAD":false,
                "isEmailVerified":false,
                "isLockedOut":false,
                "lastLogin":0001-01-01T00:00:00,
                "lastSessionActivity":null,
                "lockOutReason":null,
                "lockOutReasonDescription":null,
                "loginFailures":0,
                "mustVerifyEmail":false,
                "oathTwoFactor":false,
                "oathVerified":false,
                "passwordLastChanged":"0001-01-01T00:00:00",
                "personalGroupId":0,
                "radiusTwoFactor":false,
                "radiusUserName":null,
                "resetSessionStarted":"0001-01-01T00:00:00",
                "slackId":null,
                "timeOptionId":-1,
                "twoFactor":false,
                "unixAuthenticationMethod":Password,
                "userLcid":0,
                "userName":"UserOne",
                "verifyEmailSentDate":"0001-01-01T00:00:00"
            }
        }
    }
}

delinea-secret-server-user-search


Search, filter, sort, and page Secret Server users

Base Command

delinea-secret-server-user-search

Input

Argument Name Description Required
filter.domainId Filter users by Active Directory domain (integer) Optional
filter.includeInactive Whether to include inactive users in the results Optional
filter.searchFields Fields to search Optional
filter.searchText Search text Optional
skip Number of records to skip before taking results Optional
sortBy[0].direction Sort direction Optional
sortBy[0].name Sort field name Optional
sortBy[0].priority Priority index. Sorts with lower values are executed earlier (integer) Optional
take Maximum number of records to include in results(integer) Optional

Context Output

Path Type Description
Delinea.Secret.Server.User.Search String Specify paging and sorting options for querying records and returning results

Command Example

!delinea-secret-server-user-search filter_searchfields="userName" filter_searchtext="xsoarUser"

Context Example

{
    "Delinea": {
        "User": {
            "Search": null
        }
    }
}

delinea-secret-server-user-update


Update a single Secret Server user by ID

Base Command

delinea-secret-server-user-update

Input

Argument Name Description Required
id User ID Required
dateOptionId DateOptionId(integer) Optional
displayName Display name Optional
duoTwoFactor Whether Duo two-factor authentication is enabled Optional
emailAddress E-mail Optional
enabled Whether the user account is enabled Optional
fido2TwoFactor Whether FIDO2 two-factor authentication is enabled Optional
groupOwners GroupOwners(integer) Optional
isApplicationAccount IsApplicationAccount Optional
isGroupOwnerUpdate isGroupOwnerUpdate Optional
isLockedOut Whether the user is locked out Optional
loginFailures Number of login failures Optional
oathTwoFactor Whether OATH two-factor authentication is enabled Optional
password Password Optional
radiusTwoFactor Whether RADIUS two-factor authentication is enabled Optional
radiusUserName RADIUS username Optional
timeOptionId timeOptionId (integer) Optional
twoFactor Whether two-factor authentication is enabled Optional

Context Output

Path Type Description
Delinea.Secret.Server.User.Update String User Model

Command Example

!delinea-secret-server-user-update id=28 displayname="myTestUser"

Context Example

{
    "Delinea": {
        "User": {
            "Update": {
                "unixAuthenticationMethod":"Password",
                "enabled":true,
                "passwordLastChanged":"0001-01-01T00:00:00",
                "isEmailCopiedFromAD":false,
                "isApplicationAccount":false,
                "lockOutReason":null,
                "created":"2022-06-01T08:09:39",
                "radiusUserName":"UserOne",
                "radiusTwoFactor":false,
                "verifyEmailSentDate":"0001-01-01T00:00:00",
                "adAccountExpires":"0001-01-01T00:00:00",
                "slackId":null,
                "adGuid":null,
                "displayName":"myTestUser",
                "oathVerified":false,
                "lastSessionActivity":null,
                "externalUserSource":"None",
                "loginFailures":0,
                "lastLogin":"0001-01-01T00:00:00",
                "ipAddressRestrictions":null,
                "oathTwoFactor":false,
                "lockOutReasonDescription":null,
                "userName":"UserOne",
                "fido2TwoFactor":false,
                "emailAddress":null,
                "resetSessionStarted":"0001-01-01T00:00:00",
                "mustVerifyEmail":false,
                "isEmailVerified":false,
                "personalGroupId":0,
                "isLockedOut":false,
                "id":28,
                "twoFactor":false,
                "duoTwoFactor":false,
                "timeOptionId":-1,
                "userLcid":0,
                "dateOptionId":-1,
                "domainId":-1
            }
        }
    }
}

delinea-secret-server-user-delete


Delete a Secret Server user by ID

Base Command

delinea-secret-server-user-delete

Input

Argument Name Description Required
id User ID Required

Context Output

Path Type Description
Delinea.Secret.Server.User.Delete String Information about an object that was deleted

Command Example

!delinea-secret-server-user-delete id=5

Context Example

{
    "Delinea": {
        "User": {
            "Delete": {
                "id": 5,
                "objectType": "User",
                "responseCodes": null
            }
        }
    }
}

delinea-secret-server-user-get


Get Secret Server users list

Base Command

delinea-secret-server-user-get

Input

This command has no input arguments.

Context Output

Path Type Description
Delinea.Secret.Server.User String User object

Command Example


#### Context Example

```json
{
    "Delinea": {
        "Secret": {
            "Server": {
                "User": [
                    {
                        "id": 1,
                        "userName": "admin",
                        "displayName": "Administrator",
                        "enabled": true
                    }
                ]
            }
        }
    }
}

delinea-secret-rpc-changepassword


Change a secret’s password

Base Command

delinea-secret-rpc-changepassword

Input

Argument Name Description Required
secret_id Secret ID Required
newPassword New secret password Required

Context Output

Path Type Description
Delinea.Secret.ChangePassword String Secret summary object

Command Example

!delinea-secret-rpc-changepassword secret_id=4 newPassword="Test000"

Context Example

{
    "Delinea": {
        "Secret": {
            "ChangePassword": {
                "active": true,
                "autoChangeEnabled": false,
                "checkOutEnabled": false,
                "checkedOut": false,
                "createDate": "2020-11-02T18:06:07.357",
                "daysUntilExpiration": null,
                "doubleLockEnabled": false,
                "extendedFields": null,
                "folderId": -1,
                "hidePassword": false,
                "id": 4,
                "inheritsPermissions": false,
                "isOutOfSync": false,
                "isRestricted": false,
                "lastAccessed": null,
                "lastHeartBeatStatus": "Success",
                "lastPasswordChangeAttempt": "0001-01-01T00:00:00",
                "name": "g1-machine",
                "outOfSyncReason": "",
                "requiresApproval": false,
                "requiresComment": false,
                "responseCodes": null,
                "secretTemplateId": 6007,
                "secretTemplateName": "Unix Account (SSH)",
                "siteId": 1
            }
        }
    }
}

delinea-fetch-users


Fetch credentials from secret

Base Command

delinea-fetch-users

Input

NO input argumets

Context Output

Path Type Description
Delinea.User.Credentials String Secret credential objects

Command Example


#### Context Example

```json
[
    {
        "name": "4219",
        "password": "test3",
        "user": "test3"
    },
    {
        "name": "4217",
        "password": "dhPQhf1d@!E",
        "user": "secret2"
    }
]

delinea-platform-user-create


Create a new user in Platform

Base Command

delinea-platform-user-create

Input

Argument Name Description Required
MobileNumber The user mobile number. Optional
ID The UUID of the cloud user to change. Optional
InEverybodyRole The user is in the Everybody role? Optional
CmaRedirectedUserUuid The MFA redirected user UUID. Optional
OfficeNumber The user office number. Optional
ReportsTo The user reports to this user UUID. Optional
PreferredCulture The user preferred culture. Optional
DisplayName The user display. Optional
Password Password for new user. The password used to log in. Required
Name The user name. Required
AccountExp Account expires date/time. Optional
PasswordNeverExpire Does user’s password expire? Optional
Mail The User email. Optional
ServiceUser Whether this is a service account. Service accounts are used for automation, cannot log in using the UI, and do not consume a user license. Optional
Description The User description. Optional
HomeNumber The user home number. Optional

Context Output

Path Type Description
Delinea.Platform.User.Create String Result

Command Example

!delinea-platform-user-create Password="Test@123" Name="uniquexsoar1" ServiceUser="true"

Context Example

{
    "Delinea": {
      "Platform" : {
          "User": {
              "Create": {
                  "Result": "a09eb441-f0a0-4894-a129-af4e0b3559d6",
                  "success": true,
                  "Message": null,
                  "MessageID": null,
                  "Exception": null,
                  "ErrorID": null,
                  "ErrorCode": null,
                  "IsSoftError": false,
                  "InnerExceptions": null
            }
          }
        }
      }
    }

delinea-platform-user-get


Get single Platform user by uuid

Base Command

delinea-platform-user-get

Input

Argument Name Description Required
userUuidOrUpn Fetches a Platform user by uuid or upn Required

Context Output

Path Type Description
Delinea.Platform.User.Get String User Model

Command Example

!delinea-platform-user-get userUuidOrUpn="09b9a9b0-6ce8-465f-ab03-65766d33b05e"

Context Example

{
    "Delinea": {
        "Platform": {
          "User": {
            "Get": {
                "directoryServiceUuid": "09b9a9b0-6ce8-465f-ab03-65766d33b05e",
                "directoryServiceName": "Delinea",
                "directoryInstanceName": "Delinea",
                "uuid": "c2c7bcc6-9560-44e0-8dff-5be221cd37ee",
                "name": "admin@loud",
                "displayName": "admin",
                "state": "Active",
                "lastLogin": "2025-09-29T13:37:19.4639582Z",
                "lastInvite": "2025-04-16T17:38:47.0519372Z",
                "platformMembershipType": "Employee",
                "_drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428440b8a:identity:platformuser/platform/09b9a9b0-6ce8-465f-ab03-65766d33b05e/c2c7bcc6-9560-44e0-8dff-5be221cd37we",
                "_links": {
                  "self": {
                    "href": "/api/users/c2c7bcc6-9560-44e0-8dff-5be221cd37ee",
                    "method": "GET",
                    "drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428440b8a:identity:platformuser/platform/09b9a9b0-6ce8-465f-ab03-65766d33b05e/c2c7bcc6-9560-44e0-8dff-5be221cd37we",
                    "title": "PlatformUser(Platform): admin"
                  },
                  "directory-users": [
                    {
                      "href": "/api/directory-services/09B9A9B0-6CE8-465F-AB03-65766D33B05R/users/c2c7bcc6-9560-44e0-8dff-5be221cd37e",
                      "method": "GET",
                      "drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:user/delinea/09b9a9b0-6ce8-465f-ab03-65766d33b05e/c2c7bcc6-9560-44e0-8dff-5be221cd37we",
                      "title": "User(Delinea): admin"
                    }
                  ]
                }
            }
          }
        }
    }
}

delinea-platform-user-update


Update a single Platform user by ID

Base Command

delinea-platform-user-update

Input

Argument Name Description Required
MobileNumber The user mobile number. Optional
ID The UUID of the cloud user to change. Required
InEverybodyRole The user is in the Everybody role? Optional
CmaRedirectedUserUuid The MFA redirected user uuid. Optional
OfficeNumber The user office number. Optional
ReportsTo The user reports to this user UUID. Optional
PreferredCulture The user preferred culture. Optional
DisplayName The user display. Optional
Password Password for new user. The password used to log in. Optional
Name The user name. Optional
AccountExp Account expires date/time. Optional
PasswordNeverExpire Does user’s password expire? Optional
Mail The User email. Optional
ServiceUser Whether this is a service account. Service accounts are used for automation, cannot log in using the UI, and do not consume a user license. Optional
Description The User description. Optional
HomeNumber The user home number. Optional

Context Output

Path Type Description
Delinea.Platform.User.Update String User is successfully updated then returning success: true in result

Command Example

!delinea-platform-user-update ID="b02319fc-b26a-4352-8e4e-d8ea1188f160" Name="xsoarUserTest1"

Context Example

{
    "Delinea": {
        "Platform": {
            "User": {
                "Update": {
                  "success": true,
                  "Result": null,
                  "Message": null,
                  "MessageID": null,
                  "Exception": null,
                  "ErrorID": null,
                  "ErrorCode": null,
                  "IsSoftError": false,
                  "InnerExceptions": null
               }
            }
        }
    }
}

delinea-platform-user-delete


Delete a Platform user by UUID or Name

Base Command

delinea-platform-user-delete

Input

Argument Name Description Required
id User UUID Required

Context Output

Path Type Description
Delinea.Platform.User.Delete String Information about an object that was deleted and returning success: true in result

Command Example

!delinea-platform-user-delete id="a09eb441-f0a0-4894-a129-af4e0b3559d6"

Context Example

{
    "Delinea": {
        "Platform": {
            "User": {
                "Delete": {
                  "success": true,
                  "Result": null,
                  "Message": null,
                  "MessageID": null,
                  "Exception": null,
                  "ErrorID": null,
                  "ErrorCode": null,
                  "IsSoftError": false,
                  "InnerExceptions": null
               }
            }
        }
    }
}

delinea-platform-get-all-users


Get single Platform user by uuid

Base Command

delinea-platform-get-all-users

Input

Argument Name Description Required
filter_displayName Display name to filter users. Optional
pageSize Page size. Default 1000. Optional

Context Output

Path Type Description
Delinea.Platform.Users String Returning users based on pageSize and default page size is 1000

Command Example

!delinea-platform-get-all-users pageSize="1"

Context Example

{
    "Delinea": {
        "Platform": {
            "Get" : {
                "All" : {
                    "Users": {
                        "users": [
                          {
                            "directoryServiceUuid": "09b9a9b0-6ce8-465f-ab03-65766d33b05e",
                            "directoryServiceName": "Delinea",
                            "directoryInstanceName": "Delinea",
                            "uuid": "c2c7bcc6-9560-44e0-8dff-5be221cd37ee",
                            "name": "cloudadmin@cloud",
                            "displayName": "cloudadmin",
                            "state": "Active",
                            "lastLogin": "2025-09-29T13:37:19.4639582Z",
                            "lastInvite": "2025-04-16T17:38:47.0519372Z",
                            "platformMembershipType": "Employee",
                            "_drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:platformuser/platform/09b9a9b0-6ce8-465f-ab03-65766d33b05e/c2c7bcc6-9560-44e0-8dff-5be221cd37ee",
                            "_links": {
                              "self": {
                                "href": "/api/users/c2c7bcc6-9560-44e0-8dff-5be221cd37ee",
                                "method": "GET",
                                "drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:platformuser/platform/09b9a9b0-6ce8-465f-ab03-65766d33b05e/c2c7bcc6-9560-44e0-8dff-5be221cd37ee",
                                "title": "PlatformUser(Platform): cloudadmin"
                              },
                              "directory-users": [
                                {
                                  "href": "/api/directory-services/09B9A9B0-6CE8-465F-AB03-65766D33B05E/users/c2c7bcc6-9560-44e0-8dff-5be221cd37ee",
                                  "method": "GET",
                                  "drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:user/delinea/09b9a9b0-6ce8-465f-ab03-65766d33b05e/c2c7bcc6-9560-44e0-8dff-5be221cd37ee",
                                  "title": "User(Delinea): cloudadmin"
                                }
                              ]
                            }
                          }
                        ]
                    }
                }
            }
        }
    }
}

delinea-platform-get-user-search-by-text


Get Platform users search by Text

Base Command

delinea-platform-get-user-search-by-text

Input

Argument Name Description Required
filter.searchText Search Text is looked for in multiple fields Required

Context Output

Path Type Description
Delinea.Platform.UserSearchResults String SearchText is looked for in multiple fields and returning results

Command Example

!delinea-platform-get-user-search-by-text filter.searchText="sail"

Context Example

{
    "Delinea": {
        "Platform": {
            "Get" : {
                "User" : {
                    "Searchbytext": {
                        "users": [
                          {
                            "directoryServiceUuid": "09b9a9b0-6ce8-465f-ab03-65766d33b05e",
                            "directoryServiceName": "Delinea",
                            "directoryInstanceName": "Delinea",
                            "uuid": "3f4b80c0-c853-473f-9534-66e4a8331843",
                            "name": "ren@cloud",
                            "displayName": "sailpoint+user.service",
                            "state": "Created",
                            "platformMembershipType": "Employee",
                            "_drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:platformuser/platform/09b9a9b0-6ce8-465f-ab03-65766d33b05e/3f4b80c0-c853-473f-9534-66e4a8331843",
                            "_links": {
                              "self": {
                                "href": "/api/users/3f4b80c0-c853-473f-9534-66e4a8331843",
                                "method": "GET",
                                "drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:platformuser/platform/09b9a9b0-6ce8-465f-ab03-65766d33b05e/3f4b80c0-c853-473f-9534-66e4a8331843",
                                "title": "PlatformUser(Platform): sailpoint+user.service"
                              },
                              "directory-users": [
                                {
                                  "href": "/api/directory-services/09B9A9B0-6CE8-465F-AB03-65766D33B05E/users/3f4b80c0-c853-473f-9534-66e4a8331843",
                                  "method": "GET",
                                  "drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:user/delinea/09b9a9b0-6ce8-465f-ab03-65766d33b05e/3f4b80c0-c853-473f-9534-66e4a8331843",
                                  "title": "User(Delinea): sailpoint+user.service"
                                }
                              ]
                            }
                          },
                          {
                            "directoryServiceUuid": "09b9a9b0-6ce8-465f-ab03-65766d33b05e",
                            "directoryServiceName": "Delinea",
                            "directoryInstanceName": "Delinea",
                            "uuid": "b977dd7d-b771-40b6-83f3-f04154a733c5",
                            "name": "roderick@cloud",
                            "displayName": "roderick",
                            "state": "Active",
                            "lastLogin": "2025-08-28T17:52:02.0344759Z",
                            "platformMembershipType": "Employee",
                            "_drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:platformuser/platform/09b9a9b0-6ce8-465f-ab03-65766d33b05e/b977dd7d-b771-40b6-83f3-f04154a733c5",
                            "_links": {
                              "self": {
                                "href": "/api/users/b977dd7d-b771-40b6-83f3-f04154a733c5",
                                "method": "GET",
                                "drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:platformuser/platform/09b9a9b0-6ce8-465f-ab03-65766d33b05e/b977dd7d-b771-40b6-83f3-f04154a733c5",
                                "title": "PlatformUser(Platform): roderick"
                              },
                              "directory-users": [
                                {
                                  "href": "/api/directory-services/09B9A9B0-6CE8-465F-AB03-65766D33B05E/users/b977dd7d-b771-40b6-83f3-f04154a733c5",
                                  "method": "GET",
                                  "drn": "drn:dws:76a86745-ca2c-4ff2-ac98-463428343b8a:identity:user/delinea/09b9a9b0-6ce8-465f-ab03-65766d33b05e/b977dd7d-b771-40b6-83f3-f04154a733c5",
                                  "title": "User(Delinea): roderick"
                                }
                              ]
                            }
                          }
                        ]
                    }
                }
            }
        }
    }
}

Configuration parameters

  • url — Server URL (e.g. https://example.net) (required)
  • credentials — Username (required)
  • insecure — Trust any certificate (not secure)
  • proxy — Use system proxy settings
  • isFetchCredentials — Fetches Credentials
  • secrets — Secret IDs (Provide multiple Id's by using ',' example- 1,2,3)

Commands (26)

  • delinea-folder-create

    Create a new folder.

  • delinea-folder-delete

    Delete a folder by folder ID.

  • delinea-folder-search

    Search a specific folder by name.

  • delinea-folder-update

    Update a single secret folder by ID.

  • delinea-platform-get-all-users

    Fetch all users from the platform.

  • delinea-platform-get-user-search-by-text

    List of platform users matching search text.

  • delinea-platform-user-create

    Create a new user in Platform.

  • delinea-platform-user-delete

    Delete Platform user by ID.

  • delinea-platform-user-get

    Fetch a Platform user by uuid or upn.

  • delinea-platform-user-update

    Update a Platform user by ID.

  • delinea-secret-checkin

    Check in a secret.

  • delinea-secret-checkout

    Check out a secret.

  • delinea-secret-create

    Create a new secret.

  • delinea-secret-delete

    Delete secret by id.

  • delinea-secret-get

    Get secret object by secret ID.

  • delinea-secret-password-get

    Extracting the password field from the required secret.

  • delinea-secret-password-update

    Update password for a secret by ID.

  • delinea-secret-rpc-changepassword

    Remote password changing.

  • delinea-secret-search

    Search secret by multiply parameters.

  • delinea-secret-search-name

    Search for a secret using secret name.

  • delinea-secret-server-user-create

    Create a new user in Secret Server.

  • delinea-secret-server-user-delete

    Delete Secret Server user by ID.

  • delinea-secret-server-user-get

    Get Secret Server users list.

  • delinea-secret-server-user-search

    User search, filter and sort in Secret Server.

  • delinea-secret-server-user-update

    Update a single user by ID in Secret Server.

  • delinea-secret-username-get

    Extracting the username field from the required secret.

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401
import requests
import urllib3

# Disable insecure warnings
urllib3.disable_warnings()

""" CONSTANTS """
DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"


class AuthenticationModel:
    def __init__(
        self,
        username="",
        password="",
        server_url="",
        error=None,
        platform_login=False,
        token=None,
        token_expiration=None,
        vault_url=None,
        vault_type=None,
        verify=True,
        proxy=False,
    ):
        self.user_name = username
        self.password = password
        self.server_url = server_url
        self.error = error
        self.platform_login = platform_login
        self.token = token
        self.token_expiration = token_expiration
        self.vault_url = vault_url
        self.vault_type = vault_type
        self.verify = verify
        self.proxy = proxy

    def set_platform_login(self, platform_login: bool):
        self.platform_login = platform_login

    def set_error(self, error: str):
        self.error = error

    def set_token(self, token: str):
        self.token = token

    def set_token_expiration(self, token_expiration):
        self.token_expiration = token_expiration

    def set_vault_url(self, vault_url: str):
        self.vault_url = vault_url

    def set_vault_type(self, vault_type: str):
        self.vault_type = vault_type


class AuthenticationService:
    def authenticate_async(self, auth_model: AuthenticationModel):
        try:
            base = auth_model.server_url.rstrip("/")
            ss_url = f"{base}/api/v1/healthcheck"
            pf_url = f"{base}/health"

            if self.check_json_response_async(ss_url, auth_model):
                auth_model.set_platform_login(False)
                return auth_model
            if self.check_json_response_async(pf_url, auth_model):
                auth_model.set_platform_login(True)
                return PlatformLogin().platform_authentication(auth_model)
            error_model = AuthenticationModel()
            error_model.set_error(f"Invalid Server URL {auth_model.server_url}")
            return error_model

        except Exception as e:
            raise RuntimeError(f"Authentication failed: {str(e)}")

    def check_json_response_async(self, url, auth_model: AuthenticationModel):
        try:
            response = requests.get(
                url, timeout=3, verify=auth_model.verify, proxies=handle_proxy() if auth_model.proxy else None
            )

            if not response.text:
                return False

            body = response.text
            try:
                json_data = response.json()
                if isinstance(json_data, dict) and json_data.get("healthy") is True:
                    return True
            except Exception:
                pass
            return "Healthy" in body or "healthy" in body
        except Exception:
            return False


class PlatformLogin:
    def __init__(self):
        pass

    def platform_authentication(self, auth_model: AuthenticationModel):
        try:
            response = self.get_access_token(auth_model)
            if response.status_code != 200:
                return self.handle_error_response(response.text)

            auth_data = response.json()
            auth_model.set_token(auth_data.get("access_token"))
            auth_model.set_token_expiration(auth_data.get("expires_in"))

            response = self.get_vaults(auth_model, auth_model.token)
            if response.status_code != 200:
                return self.handle_error_response(response.text)

            vaults = response.json().get("vaults", [])
            vault = next((v for v in vaults if v["isDefault"] and v["isActive"]), None)

            if not vault:
                return self.handle_error_response("No active default vault found")

            auth_model.set_vault_url(vault["connection"]["url"])
            auth_model.set_vault_type(vault["type"])
            return auth_model

        except Exception as e:
            raise Exception(f"Platform authentication error: {e}")

    def handle_error_response(self, msg):
        return AuthenticationModel(error=msg, platform_login=True)

    def get_access_token(self, auth_model: AuthenticationModel):
        url = auth_model.server_url.rstrip("/") + "/identity/api/oauth2/token/xpmplatform"
        data = {
            "grant_type": "client_credentials",
            "client_id": auth_model.user_name,
            "client_secret": auth_model.password,
            "scope": "xpmheadless",
        }
        return requests.post(
            url,
            headers={"Content-Type": "application/x-www-form-urlencoded"},
            data=data,
            verify=auth_model.verify,
            proxies=handle_proxy() if auth_model.proxy else None,
        )

    def get_vaults(self, auth_model: AuthenticationModel, token):
        url = auth_model.server_url.rstrip("/") + "/vaultbroker/api/vaults"
        headers = {"Authorization": f"Bearer {token}"}
        return requests.get(url, headers=headers, verify=auth_model.verify, proxies=handle_proxy() if auth_model.proxy else None)


def is_platform_or_ss(url, username, password, verify, proxy):
    model = AuthenticationModel(username=username, password=password, server_url=url, verify=verify, proxy=proxy)
    service = AuthenticationService()
    return service.authenticate_async(model)


class Client(BaseClient):
    """
    Client will implement the service API, and should not contain any Demisto logic.
    Should only do requests and return data.
    """

    def __init__(self, server_url: str, username: str, password: str, proxy: bool, verify: bool):
        super().__init__(base_url=server_url, proxy=proxy, verify=verify)
        self._username = username
        self._password = password
        self._proxy_param = proxy
        self._verify_param = verify
        self._platform_url = None
        self._headers = {}
        self._token = self.authenticate()

    def authenticate(self):
        authentication_model = is_platform_or_ss(
            self._base_url, self._username, self._password, self._verify_param, self._proxy_param
        )
        if authentication_model.platform_login:
            if authentication_model.error:
                raise Exception(authentication_model.error)
            self._platform_url = self._base_url
            self._token = authentication_model.token
            self._base_url = authentication_model.vault_url
            self._headers = {"Authorization": f"Bearer {self._token}", "Content-Type": "application/json"}
            return self._token
        else:
            self._token = self._generate_token()
            self._headers = {"Authorization": self._token, "Content-Type": "application/json"}
            return self._token

    def _generate_token(self) -> str:
        """Generate an Access token using the user name and password
        :return: valid token
        """
        body = {"username": self._username, "password": self._password, "grant_type": "password"}

        headers = {"Content-Type": "application/x-www-form-urlencoded"}

        return "Bearer " + (self._http_request("POST", "/oauth2/token", headers=headers, data=body)).get("access_token")

    def getPasswordById(self, secret_id: str, autoComment: str) -> str:
        url_suffix = "/api/v1/secrets/" + str(secret_id) + "/fields/password"
        params = {"autoComment": autoComment}
        return self._http_request("GET", url_suffix, params=params)

    def getUsernameById(self, secret_id: str) -> str:
        url_suffix = "/api/v1/secrets/" + str(secret_id) + "/fields/username"
        return self._http_request("GET", url_suffix)

    def getSecret(self, secret_id: str, autocommit: str = "") -> str:
        params = {"autocomment": autocommit}
        url_suffix = "/api/v1/secrets/" + str(secret_id)
        retries = 3
        return self._http_request("GET", url_suffix, params=params, retries=retries)

    def searchSecretIdByName(self, search_name: str) -> list:
        url_suffix = "/api/v1/secrets/lookup?filter.searchText=" + search_name
        response = self._http_request("GET", url_suffix).get("records")
        idSecret = argToList(response)
        search_id = []

        if idSecret:
            for element in idSecret:
                getID = element.get("id")
                search_id.append(getID)

        return search_id

    def searchSecret(self, **kwargs) -> list:
        params = {}
        for key, value in kwargs.items():
            key = key.replace("_", ".")
            key = key.replace("sortBy_", "sortBy[0]_")
            params[key] = value

        response = self._http_request("GET", url_suffix="/api/v1/secrets", params=params).get("records", [])

        return [item.get("id") for item in response]

    def updateSecretPassword(self, secret_id: str, new_password: str, auto_comment: str) -> str:
        url_suffix = "/api/v1/secrets/" + str(secret_id) + "/fields/password"
        body = {"id": secret_id, "value": new_password}
        params = {"autoComment": auto_comment}
        return self._http_request("PUT", url_suffix, params=params, json_data=body)

    def secret_checkout(self, secret_id: str) -> str:
        url_suffix = "/api/v1/secrets/" + str(secret_id) + "/check-out"
        return self._http_request("POST", url_suffix)

    def secret_checkin(self, secret_id: str) -> str:
        url_suffix = "/api/v1/secrets/" + str(secret_id) + "/check-in"

        return self._http_request("POST", url_suffix)

    def secretChangePassword(self, secret_id: str, newPassword: str, autoComment: str) -> str:
        body = {"newPassword": newPassword}
        params = {"autoComment": autoComment}

        return self._http_request(
            "POST", url_suffix="/api/v1/secrets/" + str(secret_id) + "/change-password", params=params, json_data=body
        )

    def secretCreate(self, name: str, secret_template_id: str, **kwargs) -> str:
        secretjson = {"name": name, "secretTemplateId": secret_template_id, "items": []}  # type: Dict[str, Any]

        for key, value in kwargs.items():
            JSON = {}
            if key == "domain_item":
                JSON["fieldName"] = "Domain"
                JSON["itemValue"] = value
                JSON["slug"] = "domain"
                secretjson["items"].append(JSON)

            elif key == "machine_item":
                JSON["fieldName"] = "Machine"
                JSON["itemValue"] = value
                JSON["slug"] = "machine"
                secretjson["items"].append(JSON)

            elif key == "username_item":
                JSON["fieldName"] = "Username"
                JSON["itemValue"] = value
                JSON["slug"] = "username"
                secretjson["items"].append(JSON)

            elif key == "password_item":
                JSON["fieldName"] = "Password"
                JSON["itemValue"] = value
                JSON["slug"] = "password"
                JSON["isPassword"] = "true"
                secretjson["items"].append(JSON)

            elif key == "notes_item":
                JSON["fieldName"] = "Notes"
                JSON["itemValue"] = value
                JSON["slug"] = "notes"
                JSON["isNotes"] = "true"
                secretjson["items"].append(JSON)

            else:
                secretjson[key] = value

        return self._http_request("POST", url_suffix="/api/v1/secrets", json_data=secretjson)

    def secretDelete(self, id: int, auto_comment: str) -> str:
        params = {"autoComment": auto_comment}

        return self._http_request("DELETE", url_suffix="/api/v1/secrets/" + str(id), params=params)

    def folderCreate(self, name: str, type: int, parent: int, **kwargs) -> str:
        url_suffix = "/api/v1/folders"

        body = {
            "folderName": name,
            "folderTypeId": type,
            "parentFolderId": parent,
        }

        for key, value in kwargs.items():
            body[key] = value
        return self._http_request("POST", url_suffix, json_data=body)

    def searchFolder(self, search_folder: str) -> list:
        url_suffix = f"/api/v1/folders/lookup?filter.searchText={search_folder}"

        response_records = self._http_request("GET", url_suffix).get("records", [])

        return [item.get("id") for item in response_records]

    def folderDelete(self, folder_id: str) -> str:
        url_suffix = "/api/v1/folders/" + folder_id

        return self._http_request("DELETE", url_suffix)

    def folderUpdate(self, id: str, **kwargs) -> str:
        # Get exist folder
        response = self._http_request("GET", url_suffix="/api/v1/folders/" + str(id))

        for key, value in kwargs.items():
            response[key] = value
        return self._http_request("PUT", url_suffix="/api/v1/folders/" + str(id), json_data=response)

    def userCreate(self, **kwargs) -> str:
        if self._platform_url:
            raise DemistoException(
                "Secret Server commands cannot run against a Delinea Platform tenant URL. "
                "Please configure a Secret Server instance URL (cloud or on-prem) to use Secret Server operations"
            )
        bodyJSON = {}

        for key, value in kwargs.items():
            bodyJSON[key] = value

        return self._http_request("POST", url_suffix="/api/v1/users", json_data=bodyJSON)

    def userSearch(self, **kwargs) -> str:
        if self._platform_url:
            raise DemistoException(
                "Secret Server commands cannot run against a Delinea Platform tenant URL. "
                "Please configure a Secret Server instance URL (cloud or on-prem) to use Secret Server operations"
            )
        params = {}
        count_params = len(kwargs)
        if count_params > 0:
            for key, value in kwargs.items():
                key = key.replace("_", ".")
                key = key.replace("sortBy_", "sortBy[0]_")
                params[key] = value

        return (self._http_request("GET", url_suffix="/api/v1/users", params=params)).get("records")

    def userUpdate(self, id: str, **kwargs) -> str:
        if self._platform_url:
            raise DemistoException(
                "Secret Server commands cannot run against a Delinea Platform tenant URL. "
                "Please configure a Secret Server instance URL (cloud or on-prem) to use Secret Server operations"
            )
        # 2 method
        response = self._http_request("GET", url_suffix="/api/v1/users/" + str(id))

        for key, value in kwargs.items():
            response[key] = value

        return self._http_request("PUT", url_suffix="/api/v1/users/" + str(id), json_data=response)

    def userDelete(self, id: str) -> str:
        if self._platform_url:
            raise DemistoException(
                "Secret Server commands cannot run against a Delinea Platform tenant URL. "
                "Please configure a Secret Server instance URL (cloud or on-prem) to use Secret Server operations"
            )
        return self._http_request("DELETE", url_suffix="/api/v1/users/" + str(id))

    def getuser(self) -> str:
        if self._platform_url:
            raise DemistoException(
                "Secret Server commands cannot run against a Delinea Platform tenant URL. "
                "Please configure a Secret Server instance URL (cloud or on-prem) to use Secret Server operations"
            )
        url_suffix = "/api/v1/users"
        return self._http_request("GET", url_suffix)

    def platform_user_create(self, **kwargs) -> str:
        if not self._platform_url:
            raise DemistoException(
                "Platform commands cannot run against a Secret Server URL. "
                "Please configure a valid Delinea Platform tenant URL to use Platform operations"
            )
        bodyJSON = {}

        for key, value in kwargs.items():
            bodyJSON[key] = value
        return self._http_request(
            "POST", json_data=bodyJSON, full_url=f"{self._platform_url}/identity/api/CDirectoryService/CreateUser"
        )

    def platform_user_update(self, **kwargs) -> str:
        if not self._platform_url:
            raise DemistoException(
                "Platform commands cannot run against a Secret Server URL. "
                "Please configure a valid Delinea Platform tenant URL to use Platform operations"
            )
        bodyJSON = {}

        for key, value in kwargs.items():
            bodyJSON[key] = value
        return self._http_request(
            "POST", json_data=bodyJSON, full_url=f"{self._platform_url}/identity/api/CDirectoryService/ChangeUser"
        )

    def platform_user_delete(self, id: str) -> str:
        if not self._platform_url:
            raise DemistoException(
                "Platform commands cannot run against a Secret Server URL. "
                "Please configure a valid Delinea Platform tenant URL to use Platform operations"
            )
        return self._http_request(
            "POST", full_url=f"{self._platform_url}/identity/api/UserMgmt/RemoveUser", params={"id": str(id)}
        )

    def get_platform_user(self, user_id: str) -> dict:
        if not self._platform_url:
            raise DemistoException(
                "Platform commands cannot run against a Secret Server URL. "
                "Please configure a valid Delinea Platform tenant URL to use Platform operations"
            )
        full_url = f"{self._platform_url}/identity/api/users/{user_id}"
        return self._http_request("GET", full_url=full_url, params={"api-version": "3.0"})

    def get_all_platform_users(self, **kwargs) -> dict:
        if not self._platform_url:
            raise DemistoException(
                "Platform commands cannot run against a Secret Server URL. "
                "Please configure a valid Delinea Platform tenant URL to use Platform operations"
            )
        params = {}
        params["pageSize"] = kwargs.get("pageSize", 1000)
        for key, value in kwargs.items():
            if value is None or key == "pageSize":
                continue
            formatted_key = key.replace("_", ".")
            params[formatted_key] = value
        params["api-version"] = "3.0"
        return self._http_request("GET", full_url=f"{self._platform_url}/identity/api/users", params=params)

    def get_platform_user_searchbytext(self, **kwargs) -> dict:
        if not self._platform_url:
            raise DemistoException(
                "Platform commands cannot run against a Secret Server URL. "
                "Please configure a valid Delinea Platform tenant URL to use Platform operations"
            )
        params = {}
        params["pageSize"] = kwargs.get("pageSize", 1000)
        for key, value in kwargs.items():
            if value is None or key == "pageSize":
                continue
            formatted_key = key.replace("_", ".")
            params[formatted_key] = value
        params["api-version"] = "3.0"
        return self._http_request("GET", full_url=f"{self._platform_url}/identity/api/users", params=params)


def test_module(client) -> str:
    # Test for get authority
    if client._token == "":
        return "Failed to get authorization token. Check you credential and access to Secret Server.'"

    return "ok"


def secret_password_get_command(client, secret_id: str = "", autoComment: str = ""):
    secret_password = client.getPasswordById(secret_id, autoComment)
    markdown = tableToMarkdown("Password for secret", {"Secret ID": secret_id, "Password": secret_password})

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Password",
        outputs_key_field="secret_password",
        raw_response=secret_password,
        outputs=secret_password,
    )


def secret_username_get_command(client, secret_id: str = ""):
    secret_username = client.getUsernameById(secret_id)
    markdown = tableToMarkdown("Username for secret", {"Secret ID": secret_id, "Password": secret_username})

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Username",
        outputs_key_field="secret_username",
        raw_response=secret_username,
        outputs=secret_username,
    )


def secret_get_command(client, secret_id: str = "", autoComment: str = ""):
    secret = client.getSecret(secret_id, autoComment)
    markdown = tableToMarkdown("Full secret object", secret)
    markdown += tableToMarkdown("Items for secret", secret["items"])

    return CommandResults(
        readable_output=markdown, outputs_prefix="Delinea.Secret", outputs_key_field="secret", raw_response=secret, outputs=secret
    )


def secret_server_user_get_command(client):
    user = client.getuser()
    markdown = tableToMarkdown("All user list", user)
    markdown += tableToMarkdown("Records for user", user["records"])

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Server.User",
        outputs_key_field="user",
        raw_response=user,
        outputs=user,
    )


def secret_search_name_command(client, search_name: str = ""):
    search_id = client.searchSecretIdByName(search_name)
    markdown = tableToMarkdown("Retrieves IDs for secret name", search_id, headers=["Secret id"])

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Id",
        outputs_key_field="search_id",
        raw_response=search_id,
        outputs=search_id,
    )


def secret_search_command(client, **kwargs):
    search_result = client.searchSecret(**kwargs)
    if not search_result:
        markdown = "No secrets found matching the provided search criteria."
    else:
        markdown = tableToMarkdown("Secret Search Results", search_result, headers=["id", "name"])

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Secret",
        outputs_key_field="search_secret",
        raw_response=search_result,
        outputs=search_result,
    )


def secret_password_update_command(client, secret_id: str = "", newpassword: str = "", autoComment: str = ""):
    secret_newpassword = client.updateSecretPassword(secret_id, newpassword, autoComment)
    markdown = tableToMarkdown("New password is set for secret", {"Secret ID": secret_id, "New password": newpassword})

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Newpassword",
        outputs_key_field="secret_newpassword",
        raw_response=secret_newpassword,
        outputs=secret_newpassword,
    )


def secret_checkout_command(client, secret_id: str = ""):
    secret_checkout = client.secret_checkout(secret_id)
    if len(secret_checkout.get("responseCodes")) == 0:
        markdown = "Checkout Success\n"
    else:
        markdown = tableToMarkdown("Check out secret", secret_checkout)
    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Checkout",
        outputs_key_field="secret_checkout",
        raw_response=secret_checkout,
        outputs=secret_checkout,
    )


def secret_checkin_command(client, secret_id: str = ""):
    secret_checkin = client.secret_checkin(secret_id)
    markdown = tableToMarkdown("Check in secret detail", secret_checkin)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Checkin",
        outputs_key_field="secret_checkin",
        raw_response=secret_checkin,
        outputs=secret_checkin,
    )


def secret_create_command(client, name: str = "", secretTemplateId: int = 0, **kwargs):
    secret = client.secretCreate(name, secretTemplateId, **kwargs)
    markdown = tableToMarkdown("New secret created", secret)
    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Create",
        outputs_key_field="secret",
        raw_response=secret,
        outputs=secret,
    )


def secret_delete_command(client, id: int = 0, autoComment: str = ""):
    delete = client.secretDelete(id, autoComment)
    markdown = tableToMarkdown("Secret deleted", delete)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Deleted",
        outputs_key_field="delete",
        raw_response=delete,
        outputs=delete,
    )


def folder_create_command(client, foldername: str = "", foldertypeid: int = 1, parentfolderid: int = 1, **kwargs):
    folder = client.folderCreate(foldername, foldertypeid, parentfolderid, **kwargs)
    markdown = tableToMarkdown("New folder created", folder)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Folder.Create",
        outputs_key_field="folder",
        raw_response=folder,
        outputs=folder,
    )


def folder_search_command(client, foldername: str = ""):
    folder_id = client.searchFolder(foldername)
    markdown = tableToMarkdown("Folder Search Results", folder_id, headers=["id"])

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Folder.Id",
        outputs_key_field="folder_id",
        raw_response=folder_id,
        outputs=folder_id,
    )


def folder_update_command(client, id: str = "", **kwargs):
    folder = client.folderUpdate(id, **kwargs)
    markdown = tableToMarkdown("Folder Updated", folder)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Folder.Update",
        outputs_key_field="folder",
        raw_response=folder,
        outputs=folder,
    )


def folder_delete_command(client, folder_id: str = ""):
    folder = client.folderDelete(folder_id)
    markdown = tableToMarkdown("Folder deleted", folder)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Folder.Delete",
        outputs_key_field="folder",
        raw_response=folder,
        outputs=folder,
    )


def secret_server_user_create_command(client, **kwargs):
    user = client.userCreate(**kwargs)
    markdown = tableToMarkdown("New user created in Secret Server", user)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Server.User.Create",
        outputs_key_field="user",
        raw_response=user,
        outputs=user,
    )


def secret_server_user_search_command(client, **kwargs):
    user = client.userSearch(**kwargs)
    markdown = tableToMarkdown("Search Secret Server user", user)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Server.User.Search",
        outputs_key_field="user",
        raw_response=user,
        outputs=user,
    )


def secret_server_user_update_command(client, id: str = "", **kwargs):
    user = client.userUpdate(id, **kwargs)
    markdown = tableToMarkdown("Updated Secret Server user", user)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Server.User.Update",
        outputs_key_field="user",
        raw_response=user,
        outputs=user,
    )


def platform_user_create_command(client, **kwargs):
    user = client.platform_user_create(**kwargs)
    success = user.get("success", False)
    if success:
        markdown = tableToMarkdown("New user created in Platform", user)
    else:
        error_message = user.get("Message") or "Unknown error occurred."
        markdown = f"user creation failed.\n**Reason:** {error_message}"

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Platform.User.Create",
        outputs_key_field="user",
        raw_response=user,
        outputs=user,
    )


def platform_user_get_command(client, userUuidOrUpn: str = ""):
    user = client.get_platform_user(userUuidOrUpn)
    markdown = tableToMarkdown("User details", user)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Platform.User.Get",
        outputs_key_field="uuid",
        raw_response=user,
        outputs=user,
    )


def platform_get_all_users_command(client, **kwargs):
    users = client.get_all_platform_users(**kwargs)
    user_list = users.get("_embedded", {}).get("users", [])
    markdown = tableToMarkdown("Platform User Search Results", user_list)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Platform.Users",
        outputs_key_field="uuid",
        raw_response=users,
        outputs=user_list,
    )


def platform_get_user_searchbytext_command(client, **kwargs):
    users = client.get_platform_user_searchbytext(**kwargs)
    user_list = users.get("_embedded", {}).get("users", [])

    markdown = tableToMarkdown("Platform User Search by Text Results", user_list)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Platform.UserSearchResults",
        outputs_key_field="uuid",
        raw_response=users,
        outputs=user_list,
    )


def platform_user_delete_command(client, id: str = ""):
    user = client.platform_user_delete(id)
    success = user.get("success", False)
    if success:
        markdown = tableToMarkdown("Deleted user from Platform", user)
    else:
        error_message = user.get("Message") or "Unknown error occurred."
        markdown = f"Failed to delete platform user.\n**Reason:** {error_message}"

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Platform.User.Delete",
        outputs_key_field="user",
        raw_response=user,
        outputs=user,
    )


def platform_user_update_command(client, **kwargs):
    user = client.platform_user_update(**kwargs)
    success = user.get("success", False)
    if success:
        markdown = tableToMarkdown("Updated Platform user", user)
    else:
        error_message = user.get("Message") or "Unknown error occurred."
        markdown = f"Failed to update platform user.\n**Reason:** {error_message}"

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Platform.User.Update",
        outputs_key_field="user",
        raw_response=user,
        outputs=user,
    )


def secret_server_user_delete_command(client, id: str = ""):
    user = client.userDelete(id)
    markdown = tableToMarkdown("Deleted user from Secret Server", user)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Server.User.Delete",
        outputs_key_field="user",
        raw_response=user,
        outputs=user,
    )


def secret_rpc_changepassword_command(client, secret_id: str = "", newpassword: str = "", autoComment: str = ""):
    secret = client.secretChangePassword(secret_id, newpassword, autoComment)
    markdown = tableToMarkdown("Change password for remote machine", secret)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.ChangePassword",
        outputs_key_field="secret",
        raw_response=secret,
        outputs=secret,
    )


def get_credentials(client, secret_id):
    obj = {}
    secret = client.getSecret(secret_id, "XSOAR Fetch Credential")
    items = secret.get("items")
    username = None
    password = None
    for item in items:
        if item.get("fieldName") == "Username":
            username = item.get("itemValue")
        if item.get("fieldName") == "Password":
            password = item.get("itemValue")
        obj = {"user": username, "password": password, "name": str(secret.get("id"))}
    return obj


def fetch_credentials_command(client, secretids):
    credentials: List[Any] = []
    args: dict = demisto.args()
    credentials_name: Any = args.get("identifier")

    try:
        secretsid = argToList(secretids)
    except Exception as e:
        demisto.debug(f"Could not fetch credentials: Provide valid secret id.{e}")
        credentials = []

    for id in secretsid:
        if id not in secretsid:
            secretsid.append(id)

    if len(secretsid) == 0:
        demisto.credentials(credentials)
        demisto.debug(
            "Could not fetch credentials: Enter valid secret ID to fetch credentials.\n For multiple ID use ,(e.g. 1,2)"
        )
        credentials = []
    else:
        if credentials_name:
            try:
                credentials = [get_credentials(client, credentials_name)]
            except Exception as e:
                demisto.debug(f"Could not fetch credentials: {credentials_name}. Error: {e}")
                credentials = []
        else:
            for secret_id in secretsid:
                obj = get_credentials(client, secret_id)
                credentials.append(obj)

    demisto.credentials(credentials)
    markdown = tableToMarkdown("Fetched Credentials", credentials)

    return CommandResults(
        readable_output=markdown,
        outputs_prefix="Delinea.Secret.Fetch.Credentials",
        outputs_key_field="credentials",
        raw_response=credentials,
        outputs=credentials,
    )


def main():
    params = demisto.params()

    username = params.get("credentials").get("identifier")
    password = params.get("credentials").get("password")
    # get the service API url
    url = params.get("url")
    proxy = params.get("proxy", False)
    verify = not params.get("insecure", False)
    secretids = params.get("secrets")

    demisto.info(f"Command being called is {demisto.command()}")

    delinea_commands = {
        "delinea-secret-password-get": secret_password_get_command,
        "delinea-secret-username-get": secret_username_get_command,
        "delinea-secret-get": secret_get_command,
        "delinea-secret-search-name": secret_search_name_command,
        "delinea-secret-search": secret_search_command,
        "delinea-secret-password-update": secret_password_update_command,
        "delinea-secret-checkout": secret_checkout_command,
        "delinea-secret-checkin": secret_checkin_command,
        "delinea-secret-create": secret_create_command,
        "delinea-secret-delete": secret_delete_command,
        "delinea-secret-rpc-changepassword": secret_rpc_changepassword_command,
        "delinea-folder-create": folder_create_command,
        "delinea-folder-search": folder_search_command,
        "delinea-folder-update": folder_update_command,
        "delinea-folder-delete": folder_delete_command,
        "delinea-secret-server-user-create": secret_server_user_create_command,
        "delinea-secret-server-user-search": secret_server_user_search_command,
        "delinea-secret-server-user-update": secret_server_user_update_command,
        "delinea-secret-server-user-delete": secret_server_user_delete_command,
        "delinea-secret-server-user-get": secret_server_user_get_command,
        "delinea-platform-user-create": platform_user_create_command,
        "delinea-platform-user-update": platform_user_update_command,
        "delinea-platform-user-delete": platform_user_delete_command,
        "delinea-platform-user-get": platform_user_get_command,
        "delinea-platform-get-all-users": platform_get_all_users_command,
        "delinea-platform-get-user-search-by-text": platform_get_user_searchbytext_command,
    }
    command = demisto.command()
    try:
        client = Client(server_url=url, username=username, password=password, proxy=proxy, verify=verify)
        if command in delinea_commands:
            return_results(
                delinea_commands[command](client, **demisto.args())  # type: ignore[operator]
            )
        if command == "fetch-credentials":
            return_results(fetch_credentials_command(client, secretids))
        elif command == "test-module":
            result = test_module(client)
            demisto.results(result)
    except Exception as e:
        return_error(f"Failed to execute {command} command. Error: {str(e)}")


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()