- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
03-02-2026 05:43 AM
Hi, is it possible to add users from a directory mapping which are domain users using the Add Safe member API reference?
We are looking to automate the onboarding of a personal domain level privileged account into a safe created for an individual and align the persons domain unprivileged account as a safe member all up front before user login using the API?
We have ~700 users to create safes and accounts for and looking to utilise the API to limit the amount of manual onboarding we need to do for these persona priv accounts.
So user x12345 in domain, safe x12345 where we we want add the safe member x12345 from the domain to there personal safe created in the 1st part of the script.
We have another script adding y12345 privileged account to the safe created in 1st script.
We have the script working with CyberArk users just now wanted to add in a reference to a domain account.
We have a requirement to have personal named safes for admins where the personal privileged accounts are stored,
Its is our intention to use RSA/Radius as our auth method of choice and looking to ultimately automate onboarding fully.
The code snippet we have currently is as follows:
# This section will add the first required owner from the csv now that the safes have been created - Should be Administrator2
Import-CSV CreateSafes.csv | Foreach-Object{
$safename = $_.safename
$owner1 = $_.owner1
$member1Data = @{
memberName = "$owner1"
searchIn = "Vault"
membershipExpirationDate = ""
permissions = @{
listAccounts = "true";
retrieveAccounts = "true";
addAccounts = "true";
updateAccountContent = "true";
updateAccountProperties = "true";
renameAccounts = "true";
deleteAccounts = "true";
viewAuditLog = "true";
viewSafeMembers = "true";
useAccounts = "true";
initiateCPMAccountManagementOperations = "true";
specifyNextAccountContent = "true";
createFolders = "true";
deleteFolders = "true";
unlockAccounts = "true";
moveAccountsAndFolders = "true";
manageSafe = "true";
manageSafeMembers = "true";
backupSafe = "true";
accessWithoutConfirmation = "true";
requestsAuthorizationLevel1 = "true"
}
MemberType = "User"}
$member1json = $member1Data | ConvertTo-Json -Depth 99
$members1url = "https://pvwaaddress/PasswordVault/API/Safes/$safename/Members/"
$members1 = Invoke-RestMethod -ContentType "application/json" -Uri $members1url -Method Post -H @{"Authorization" = "$token"} -B $member1json}
What edits would we need to make to the above snippet to reference a domain user from a user mapping?
Documentation suggests refers to the "searchin" parameter?
We have tried to reference a known user mapping and getting the error below:
PS C:\scripts> C:\scripts\CreateSafesstc.ps1
Username: Admin1
Invoke-RestMethod : {"ErrorCode":"SFWS0014","ErrorMessage":"Failed to find user u8****** in ldap mapping Users__****."}
At C:\scripts\CreateSafesstc.ps1:68 char:13
+ $members1 = Invoke-RestMethod -ContentType "application/json" -Uri $m ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Logging Off
Script Finished
We are also unsure where the extra . is appearing at the end of the user mapping name,
Seemed doable on paper but maybe a step to far for full automation of creating a safe, assigning an external user(who hasn't logged on yet) and adding an account. With the "user who hasnt logged in yet" and the vault having no hook for the external user yet to assign as a safe member being the current stumbling block.
Thanks in advance for any responses.
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

