Skip to content

Commit c80959f

Browse files
author
Theo Dumitrescu (from Dev Box)
committed
added certificate param
1 parent 600dd30 commit c80959f

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/Get-MsIdCBACertificateUserIdFromCertificate.ps1

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# ------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
# ------------------------------------------------------------------------------
4+
15
<#
26
.SYNOPSIS
37
Generates an object representing all the values contained in a certificate file that can be used in Entra ID for configuring CertificateUserIDs in Certificate-Based Authentication.
@@ -8,6 +12,9 @@
812
.PARAMETER Path
913
The path to the certificate file. The file can be in .cer or .pem format.
1014
15+
.PARAMETER Certificate
16+
An X509Certificate2 object
17+
1118
.PARAMETER CertificateMapping
1219
The certificate mapping property to retrieve. Valid values are PrincipalName, RFC822Name, IssuerAndSubject, Subject, SKI, SHA1PublicKey, and IssuerAndSerialNumber.
1320
@@ -16,6 +23,11 @@
1623
1724
This command retrieves all the possible certificate mappings and returns an object to represent them.
1825
26+
.EXAMPLE
27+
PS > Get-MsIdCBACertificateUserIdFromCertificate -Certificate $cert
28+
29+
This command retrieves all the possible certificate mappings and returns an object to represent them.
30+
1931
.EXAMPLE
2032
PS > Get-MsIdCBACertificateUserIdFromCertificate -Path "C:\path\to\certificate.cer" -CertificateMapping Subject
2133
@@ -37,11 +49,12 @@
3749
#>
3850

3951
function Get-MsIdCBACertificateUserIdFromCertificate {
40-
[CmdletBinding(HelpUri = 'https://azuread.github.io/MSIdentityTools/commands/Get-MsIdCBACertificateUserIdFromCertificate')]
4152
param (
42-
[Parameter(Mandatory = $true)]
53+
[Parameter(Mandatory = $false)]
4354
[string]$Path,
4455
[Parameter(Mandatory = $false)]
56+
[System.Security.Cryptography.X509Certificates.X509Certificate2]$Certificate,
57+
[Parameter(Mandatory = $false)]
4558
[ValidateSet("PrincipalName", "RFC822Name", "IssuerAndSubject", "Subject", "SKI", "SHA1PublicKey", "IssuerAndSerialNumber")]
4659
[string]$CertificateMapping
4760
)
@@ -191,7 +204,12 @@ function Get-MsIdCBACertificateUserIdFromCertificate {
191204

192205
function Main
193206
{
194-
$cert = Get-Certificate -filePath $Path
207+
$cert = $Certificate
208+
if ($null -eq $cert)
209+
{
210+
$cert = Get-Certificate -filePath $Path
211+
}
212+
195213
$mappings = Get-CertificateUserIds -cert $cert
196214

197215
if ($CertificateMapping -eq "")

website/docs/commands/Get-MsIdCBACertificateUserIdFromCertificate.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ X509:<S>DC=com,DC=contoso,OU=UserAccounts,CN=mfatest
6060

6161
Path to the certificate file, it can be either a cer or pem file.
6262

63+
### -Certificate
64+
Certificate from which the certificateUserIDs mappings will be extracted
65+
6366
### -CertificateMapping
6467
One of the values `PrincipalName`, `RFC822Name`, `IssuerAndSubject`, `Subject`, `SKI`, `SHA1PublicKey`, and `IssuerAndSerialNumber`
6568
To filer

0 commit comments

Comments
 (0)