Samples
Use these sample expressions to build attribute mappings with the PingOne expression builder.
Sample user model
The examples in this section use the following model:
{
"user": {
"name": {
"given": "John",
"family": "Doe"
},
"role": "SA",
"memberOfGroupNames": ["Admin", "User"],
"groupDNs": [
"CN=Devs,CN=Users,DC=malibu,DC=gl,DC=lab",
"CN=Admins,CN=Users,DC=malibu,DC=gl,DC=lab"
]
}
}
Expression | Result |
---|---|
|
FirstName |
|
User |
|
1 |
|
true |
|
['USER'] |
|
|
Expression | Result |
---|---|
|
FirstName, LastName |
|
John, Doe |
Expression | Result |
---|---|
|
JDoe |
Expression | Result |
---|---|
|
[test] |
Expression | Result |
---|---|
|
Friday, 01 January; 10:15 AM |
Expression | Result |
---|---|
|
John Doe, Software Architect |
Expression | Result |
---|---|
|
[ "ADMIN", "USER" ] |
Expression | Result |
---|---|
|
[ "CN=Admin,DC=example,DC=com", "CN=User,DC=example,DC=com" ] |
Expression | Result |
---|---|
|
[ "Devs", "Admins" ] |
Accessing property names with non-alphanumeric characters
If a property name contains any characters other than alpha-numeric characters and underscores (_
), use the map access format instead of dot notation.
The examples in this section use the following model:
{
"providerAttributes": {
"full-name": "John Doe",
"http://www.schema.com/samples/userId": "jdoe00",
"Email Address": "johndoe00@test.com"
},
"custom-attributes": {
"email": "johndoe00@test.com"
}
}
Expression | Result |
---|---|
|
John Doe |
Expression | Result |
---|---|
|
jdoe00 |
Expression | Result |
---|---|
|
johndoe00@test.com |
Expression | Result |
---|---|
|
johndoe00@test.com |
Virtual server IDs for SAML applications
When using virtual server IDs for SAML applications to connect to multiple environments in one connection, you can protect against unauthorized access by adding an attribute mapping using the expression builder to compare the virtual server ID invoked by the request against an attribute and populate a required attribute accordingly.
For example, for two populations accessing the same SAML application, you can make sure only authorized users can access the application by configuring a different virtual server ID for each population and adding an expression to the application, such as:
( (context.requestData.virtualServerId eq 'IdP1' and user.population.id eq '<populationID1>') or (context.requestData.virtualServerId eq 'IdP2' and user.population.id eq '<populationID2>') )? user.username : null
where IdP1
and IdP2
are the respective virtual server IDs, and populationID1
and populationID2
are example population IDs from Directory > Populations in the PingOne admin console.
If a user from the intended population (populationID1
) accesses the application using an identity provider (IdP)-initiated single sign-on (SSO) URL for the virtual server ID configured for that population (IdP1
), PingOne populates the saml_subject
attribute with the username and redirects the browser with a SAML assertion to the application’s ACS endpoint. If a user uses an IdP-initiated SSO URL for the virtual server ID configured for a population to which they don’t belong, PingOne populates the saml_subject
attribute with null
and returns an error message. Learn more about using virtual server IDs in Editing an application - SAML.