Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for identity/GetMembers #87

Merged
merged 3 commits into from
Feb 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 55 additions & 10 deletions VenafiPS/Public/Get-TppIdentity.ps1
Original file line number Diff line number Diff line change
@@ -11,6 +11,9 @@ The individual identity, group identity, or distribution group prefixed universa
.PARAMETER IncludeAssociated
Include all associated identity groups and folders
.PARAMETER IncludeMembers
Include all individual members if the ID is a group
.PARAMETER Me
Returns the identity of the authenticated user
@@ -26,11 +29,16 @@ PSCustomObject with the following properties:
ID
Path
Associated (if -IncludeAssociated provided)
Members (if -IncludeMembers provided)
.EXAMPLE
Get-TppIdentity -ID 'AD+myprov:asdfgadsf9g87df98g7d9f8g7'
Get identity details from an id
.EXAMPLE
Get-TppIdentity -ID 'AD+myprov:asdfgadsf9g87df98g7d9f8g7' -IncludeMembers
Get identity details and if the identity is a group it will also return the members
.EXAMPLE
Get-TppIdentity -ID 'AD+myprov:asdfgadsf9g87df98g7d9f8g7' -IncludeAssociated
@@ -56,6 +64,10 @@ https://docs.venafi.com/Docs/current/TopNav/Content/SDK/WebSDK/r-SDK-GET-Identit
.LINK
https://docs.venafi.com/Docs/current/TopNav/Content/SDK/WebSDK/r-SDK-POST-Identity-GetAssociatedEntries.php
.LINK
https://docs.venafi.com/Docs/current/TopNav/Content/SDK/WebSDK/r-SDK-POST-Identity-GetMembers.php
#>
function Get-TppIdentity {

@@ -70,13 +82,19 @@ function Get-TppIdentity {
[Parameter(ParameterSetName = 'Id')]
[Switch] $IncludeAssociated,

[Parameter(ParameterSetName = 'Id')]
[Switch] $IncludeMembers,


[Parameter(Mandatory, ParameterSetName = 'Me')]
[Switch] $Me,

[Parameter()]
[VenafiSession] $VenafiSession = $script:VenafiSession
)



begin {
$VenafiSession.Validate('TPP')

@@ -118,7 +136,19 @@ function Get-TppIdentity {
$assocParams = $params.Clone()
$assocParams.UriLeaf = 'Identity/GetAssociatedEntries'
$associated = Invoke-VenafiRestMethod @assocParams
$response | Add-Member @{ 'Associated' = $associated.Identities }
$response | Add-Member @{ 'Associated' = $null }
$response.Associated = $associated.Identities | script:Format-Output
}

if ( $IncludeMembers ) {
$response | Add-Member @{ 'Members' = $null }
if ( $response.IsGroup ) {
$assocParams = $params.Clone()
$assocParams.UriLeaf = 'Identity/GetMembers'
$assocParams.Body.ResolveNested = "1"
$members = Invoke-VenafiRestMethod @assocParams
$response.Members = $members.Identities | script:Format-Output
}
}

$response
@@ -133,15 +163,30 @@ function Get-TppIdentity {
}

if ( $idOut ) {
$idOut | Select-Object `
@{
n = 'ID'
e = { $_.PrefixedUniversal }
},
@{
n = 'Path'
e = { $_.FullName }
}, * -ExcludeProperty PrefixedUniversal, FullName, Prefix, PrefixedName, Type, Universal
$idOut | script:Format-Output
}
}

}
filter script:Format-Output {
$_ | Select-Object `
@{
n = 'ID'
e = { $_.PrefixedUniversal }
},
@{
n = 'Path'
e = { $_.FullName }
},
@{
n = 'IsGroup'
e = {
if ( $_.IsGroup) {
$_.IsGroup
}
else {
$false
}
}
}, * -ExcludeProperty PrefixedUniversal, FullName, Prefix, PrefixedName, Type, Universal, IsGroup
}