Skip to content

Commit bcc6225

Browse files
authored
Merge pull request #174762 from ArvindHarinder1/patch-214
Add randomString function
2 parents 6613dbc + ed80476 commit bcc6225

File tree

1 file changed

+58
-29
lines changed

1 file changed

+58
-29
lines changed

articles/active-directory/app-provisioning/functions-for-customizing-application-data.md

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.reviewer: arvinh
1515

1616
# Reference for writing expressions for attribute mappings in Azure Active Directory
1717

18-
When you configure provisioning to a SaaS application, one of the types of attribute mappings that you can specify is an expression mapping. For these, you must write a script-like expression that allows you to transform your users' data into formats that are more acceptable for the SaaS application.
18+
When you configure provisioning to a SaaS application, one of the types of attribute mappings that you can specify is an expression mapping. For these mappings, you must write a script-like expression that allows you to transform your users' data into formats that are more acceptable for the SaaS application.
1919

2020
## Syntax overview
2121

@@ -34,7 +34,7 @@ The syntax for Expressions for Attribute Mappings is reminiscent of Visual Basic
3434

3535
## List of Functions
3636

37-
[Append](#append)      [AppRoleAssignmentsComplex](#approleassignmentscomplex)      [BitAnd](#bitand)      [CBool](#cbool)      [CDate](#cdate)      [Coalesce](#coalesce)      [ConvertToBase64](#converttobase64)      [ConvertToUTF8Hex](#converttoutf8hex)      [Count](#count)      [CStr](#cstr)      [DateAdd](#dateadd)      [DateDiff](#datediff)      [DateFromNum](#datefromnum)  [FormatDateTime](#formatdatetime)      [Guid](#guid)      [IgnoreFlowIfNullOrEmpty](#ignoreflowifnullorempty)     [IIF](#iif)     [InStr](#instr)      [IsNull](#isnull)      [IsNullOrEmpty](#isnullorempty)      [IsPresent](#ispresent)      [IsString](#isstring)      [Item](#item)      [Join](#join)      [Left](#left)      [Mid](#mid)      [NormalizeDiacritics](#normalizediacritics)       [Not](#not)      [Now](#now)      [NumFromDate](#numfromdate)      [PCase](#pcase)      [RemoveDuplicates](#removeduplicates)      [Replace](#replace)      [SelectUniqueValue](#selectuniquevalue)     [SingleAppRoleAssignment](#singleapproleassignment)     [Split](#split)    [StripSpaces](#stripspaces)      [Switch](#switch)     [ToLower](#tolower)     [ToUpper](#toupper)     [Word](#word)
37+
[Append](#append)      [AppRoleAssignmentsComplex](#approleassignmentscomplex)      [BitAnd](#bitand)      [CBool](#cbool)      [CDate](#cdate)      [Coalesce](#coalesce)      [ConvertToBase64](#converttobase64)      [ConvertToUTF8Hex](#converttoutf8hex)      [Count](#count)      [CStr](#cstr)      [DateAdd](#dateadd)      [DateDiff](#datediff)      [DateFromNum](#datefromnum)  [FormatDateTime](#formatdatetime)      [Guid](#guid)      [IgnoreFlowIfNullOrEmpty](#ignoreflowifnullorempty)     [IIF](#iif)     [InStr](#instr)      [IsNull](#isnull)      [IsNullOrEmpty](#isnullorempty)      [IsPresent](#ispresent)      [IsString](#isstring)      [Item](#item)      [Join](#join)      [Left](#left)      [Mid](#mid)      [NormalizeDiacritics](#normalizediacritics)       [Not](#not)      [Now](#now)      [NumFromDate](#numfromdate)      [PCase](#pcase)      [RandomString](#randomstring)      [RemoveDuplicates](#removeduplicates)      [Replace](#replace)      [SelectUniqueValue](#selectuniquevalue)     [SingleAppRoleAssignment](#singleapproleassignment)     [Split](#split)    [StripSpaces](#stripspaces)      [Switch](#switch)     [ToLower](#tolower)     [ToUpper](#toupper)     [Word](#word)
3838

3939
---
4040
### Append
@@ -54,7 +54,7 @@ Takes a source string value and appends the suffix to the end of it.
5454

5555

5656
#### Append constant suffix to user name
57-
Example: If you are using a Salesforce Sandbox, you might need to append an additional suffix to all your user names before synchronizing them.
57+
Example: If you are using a Salesforce Sandbox, you might need to append another suffix to all your user names before synchronizing them.
5858

5959
**Expression:**
6060
`Append([userPrincipalName], ".test")`
@@ -96,8 +96,8 @@ In other words, it returns 0 in all cases except when the corresponding bits of
9696

9797
| Name | Required/ Repeating | Type | Notes |
9898
| --- | --- | --- | --- |
99-
| **value1** |Required |num |Numeric value that should be AND'ed with value2|
100-
| **value2** |Required |num |Numeric value that should be AND'ed with value1|
99+
| **value1** |Required |Num |Numeric value that should be AND'ed with value2|
100+
| **value2** |Required |Num |Numeric value that should be AND'ed with value1|
101101

102102
**Example:**
103103
`BitAnd(&HF, &HF7)`
@@ -116,7 +116,7 @@ In other words, it returns 0 in all cases except when the corresponding bits of
116116

117117
| Name | Required/ Repeating | Type | Notes |
118118
| --- | --- | --- | --- |
119-
| **expression** |Required | expression | Any valid expression |
119+
| **Expression** |Required | expression | Any valid expression |
120120

121121
**Example:**
122122
`CBool([attribute1] = [attribute2])`
@@ -134,7 +134,7 @@ The CDate function returns a UTC DateTime from a string. DateTime is not a nativ
134134

135135
| Name | Required/ Repeating | Type | Notes |
136136
| --- | --- | --- | --- |
137-
| **expression** |Required | expression | Any valid string that represents a date/time. For supported formats, refer to [.NET custom date and time format strings](/dotnet/standard/base-types/custom-date-and-time-format-strings). |
137+
| **Expression** |Required | Expression | Any valid string that represents a date/time. For supported formats, refer to [.NET custom date and time format strings](/dotnet/standard/base-types/custom-date-and-time-format-strings). |
138138

139139
**Remarks:**
140140
The returned string is always in UTC and follows the format **M/d/yyyy h:mm:ss tt**.
@@ -289,22 +289,22 @@ The **interval** string must have one of the following values:
289289
* **INPUT** (StatusHireDate): 2012-03-16-07:00
290290
* **OUTPUT**: 3/23/2012 7:00:00 AM
291291

292-
**Example 2: Get a date 10 days prior to hire date**
292+
**Example 2: Get a date ten days prior to hire date**
293293
`DateAdd("d", -10, CDate([StatusHireDate]))`
294294
* **INPUT** (StatusHireDate): 2012-03-16-07:00
295295
* **OUTPUT**: 3/6/2012 7:00:00 AM
296296

297-
**Example 3: Add 2 weeks to hire date**
297+
**Example 3: Add two weeks to hire date**
298298
`DateAdd("ww", 2, CDate([StatusHireDate]))`
299299
* **INPUT** (StatusHireDate): 2012-03-16-07:00
300300
* **OUTPUT**: 3/30/2012 7:00:00 AM
301301

302-
**Example 4: Add 10 months to hire date**
302+
**Example 4: Add ten months to hire date**
303303
`DateAdd("m", 10, CDate([StatusHireDate]))`
304304
* **INPUT** (StatusHireDate): 2012-03-16-07:00
305305
* **OUTPUT**: 1/16/2013 7:00:00 AM
306306

307-
**Example 5: Add 2 years to hire date**
307+
**Example 5: Add two years to hire date**
308308
`DateAdd("yyyy", 2, CDate([StatusHireDate]))`
309309
* **INPUT** (StatusHireDate): 2012-03-16-07:00
310310
* **OUTPUT**: 3/16/2014 7:00:00 AM
@@ -352,7 +352,7 @@ The **interval** string must have one of the following values:
352352
| Difference in seconds between two dates | s | 2021-08-24 | 2021-08-25 | 86400 |
353353

354354
**Example 2: Combine DateDiff with IIF function to set attribute value** <br>
355-
If an account is Active in Workday, set the *accountEnabled* attribute of the user to True only if hire date is within the next 5 days.
355+
If an account is Active in Workday, set the *accountEnabled* attribute of the user to True only if hire date is within the next five days.
356356

357357
```
358358
Switch([Active], ,
@@ -438,7 +438,7 @@ The IgnoreFlowIfNullOrEmpty function instructs the provisioning service to ignor
438438

439439
| Name | Required/ Repeating | Type | Notes |
440440
| --- | --- | --- | --- |
441-
| **expression** | Required | expression | Expression to be evaluated |
441+
| **Expression** | Required | Expression | Expression to be evaluated |
442442

443443
**Example 1: Don't flow an attribute if it is null** <br>
444444
`IgnoreFlowIfNullOrEmpty([department])` <br>
@@ -506,7 +506,7 @@ If the expression evaluates to Null, then the IsNull function returns true. For
506506

507507
| Name | Required/ Repeating | Type | Notes |
508508
| --- | --- | --- | --- |
509-
| **expression** |Required |expression |Expression to be evaluated |
509+
| **Expression** |Required |Expression |Expression to be evaluated |
510510

511511
**Example:**
512512
`IsNull([displayName])`
@@ -526,7 +526,7 @@ The inverse of this function is named IsPresent.
526526

527527
| Name | Required/ Repeating | Type | Notes |
528528
| --- | --- | --- | --- |
529-
| **expression** |Required |expression |Expression to be evaluated |
529+
| **Expression** |Required |Expression |Expression to be evaluated |
530530

531531
**Example:**
532532
`IsNullOrEmpty([displayName])`
@@ -545,7 +545,7 @@ If the expression evaluates to a string that is not Null and is not empty, then
545545

546546
| Name | Required/ Repeating | Type | Notes |
547547
| --- | --- | --- | --- |
548-
| **expression** |Required |expression |Expression to be evaluated |
548+
| **Expression** |Required |Expression |Expression to be evaluated |
549549

550550
**Example:**
551551
`Switch(IsPresent([directManager]),[directManager], IsPresent([skiplevelManager]),[skiplevelManager], IsPresent([director]),[director])`
@@ -562,7 +562,7 @@ If the expression can be evaluated to a string type, then the IsString function
562562

563563
| Name | Required/ Repeating | Type | Notes |
564564
| --- | --- | --- | --- |
565-
| **expression** |Required |expression |Expression to be evaluated |
565+
| **Expression** |Required |Expression |Expression to be evaluated |
566566

567567
---
568568
### Item
@@ -602,7 +602,7 @@ If one of the source values is a multi-value attribute, then every value in that
602602
---
603603
### Left
604604
**Function:**
605-
Left(String,NumChars)
605+
Left(String, NumChars)
606606

607607
**Description:**
608608
The Left function returns a specified number of characters from the left of a string.
@@ -636,8 +636,8 @@ Returns a substring of the source value. A substring is a string that contains o
636636
| Name | Required/ Repeating | Type | Notes |
637637
| --- | --- | --- | --- |
638638
| **source** |Required |String |Usually name of the attribute. |
639-
| **start** |Required |integer |Index in the **source** string where substring should start. First character in the string will have index of 1, second character will have index 2, and so on. |
640-
| **length** |Required |integer |Length of the substring. If length ends outside the **source** string, function will return substring from **start** index till end of **source** string. |
639+
| **start** |Required |Integer |Index in the **source** string where substring should start. First character in the string will have index of 1, second character will have index 2, and so on. |
640+
| **length** |Required |Integer |Length of the substring. If length ends outside the **source** string, function will return substring from **start** index untill end of **source** string. |
641641

642642
---
643643
### NormalizeDiacritics
@@ -677,7 +677,7 @@ Requires one string argument. Returns the string, but with any diacritical chara
677677

678678

679679
#### Remove diacritics from a string
680-
Example: You need to replace characters containing accent marks with equivalent characters that don't contain accent marks.
680+
Example: Replace characters containing accent marks with equivalent characters that don't contain accent marks.
681681

682682
**Expression:**
683683
NormalizeDiacritics([givenName])
@@ -730,11 +730,11 @@ The NumFromDate function converts a DateTime value to Active Directory format th
730730

731731
**Example:**
732732
* Workday example
733-
Assuming you want to map the attribute *ContractEndDate* from Workday which is in the format *2020-12-31-08:00* to *accountExpires* field in AD, here is how you can use this function and change the timezone offset to match your locale.
733+
Assuming you want to map the attribute *ContractEndDate* from Workday, which is in the format *2020-12-31-08:00* to *accountExpires* field in AD, here is how you can use this function and change the timezone offset to match your locale.
734734
`NumFromDate(Join("", FormatDateTime([ContractEndDate], ,"yyyy-MM-ddzzz", "yyyy-MM-dd"), " 23:59:59-08:00"))`
735735

736736
* SuccessFactors example
737-
Assuming you want to map the attribute *endDate* from SuccessFactors which is in the format *M/d/yyyy hh:mm:ss tt* to *accountExpires* field in AD, here is how you can use this function and change the time zone offset to match your locale.
737+
Assuming you want to map the attribute *endDate* from SuccessFactors, which is in the format *M/d/yyyy hh:mm:ss tt* to *accountExpires* field in AD, here is how you can use this function and change the time zone offset to match your locale.
738738
`NumFromDate(Join("",FormatDateTime([endDate], ,"M/d/yyyy hh:mm:ss tt","yyyy-MM-dd")," 23:59:59-08:00"))`
739739

740740

@@ -782,6 +782,35 @@ Let's say you are sourcing the attributes *firstName* and *lastName* from SAP Su
782782
| `PCase(Join(" ",[firstName],[lastName]))` | *firstName* = GREGORY, *lastName* = "JAMES" | "Gregory James" | You can nest the Join function within PCase. As the *wordSeparators* parameter is not specified, the *PCase* function uses the default word separators character set. |
783783

784784

785+
---
786+
787+
### RandomString
788+
**Function:**
789+
RandomString(Length, MinimumNumbers, MinimumSpecialCharacters , MinimumCapital, MinimumLowerCase, CharactersToAvoid)
790+
791+
**Description:**
792+
The RandomString function generates a random string based on the conditions specified. Characters allowed can be identified [here](https://docs.microsoft.com/windows/security/threat-protection/security-policy-settings/password-must-meet-complexity-requirements#reference).
793+
794+
**Parameters:**
795+
796+
| Name | Required/ Repeating | Type | Notes |
797+
| --- | --- | --- | --- |
798+
| **Length** |Required |Number |Total length of the random string. This should be greater than or equal to the sum of MinimumNumbers, MinimumSpecialCharacters, and MinimumCapital. 256 characters max.|
799+
| **MinimumNumbers** |Required |Number |Minimum numbers in the random string.|
800+
| **MinimumSpecialCharacters** |Required |Number |Minimum number of special characters.|
801+
| **MinimumCapital** |Required |Number |Minimum number of capital letters in the random string.|
802+
| **MinimumLowerCase** |Required |Number |Minimum number of lower case letters in the random string.|
803+
| **CharactersToAvoid** |Optional |String |Characters to be excluded when generating the random string.|
804+
805+
806+
**Example 1:** - Generate a random string without special character restrictions:
807+
`RandomString(6,3,0,0,3)`
808+
Generates a random string with 6 characters. The string contains 3 numbers and 3 lower case characters (1a73qt).
809+
810+
**Example 2:** - Generate a random string with special character restrictions:
811+
`RandomString(10,2,2,2,1,"?,")`
812+
Generates a random string with 10 characters. The string contains at least 2 numbers, 2 special characters, 2 capital letters, 1 lower case letter and excludes the characters "?" and "," (1@!2BaRg53).
813+
785814
---
786815

787816
### RemoveDuplicates
@@ -860,7 +889,7 @@ SelectUniqueValue(uniqueValueRule1, uniqueValueRule2, uniqueValueRule3, …)
860889
Requires a minimum of two arguments, which are unique value generation rules defined using expressions. The function evaluates each rule and then checks the value generated for uniqueness in the target app/directory. The first unique value found will be the one returned. If all of the values already exist in the target, the entry will get escrowed and the reason gets logged in the audit logs. There is no upper bound to the number of arguments that can be provided.
861890

862891

863-
- This is a top-level function, it cannot be nested.
892+
- This function must be at the top-level and cannot be nested.
864893
- This function cannot be applied to attributes that have a matching precedence.
865894
- This function is only meant to be used for entry creations. When using it with an attribute, set the **Apply Mapping** property to **Only during object creation**.
866895
- This function is currently only supported for "Workday to Active Directory User Provisioning" and "SuccessFactors to Active Directory User Provisioning". It cannot be used with other provisioning applications.
@@ -902,7 +931,7 @@ Example: Based on the user's first name, middle name and last name, you need to
902931
SingleAppRoleAssignment([appRoleAssignments])
903932

904933
**Description:**
905-
Returns a single appRoleAssignment from the list of all appRoleAssignments assigned to a user for a given application. This function is required to convert the appRoleAssignments object into a single role name string. Note that the best practice is to ensure only one appRoleAssignment is assigned to one user at a time, and if multiple roles are assigned the role string returned may not be predictable.
934+
Returns a single appRoleAssignment from the list of all appRoleAssignments assigned to a user for a given application. This function is required to convert the appRoleAssignments object into a single role name string. The best practice is to ensure only one appRoleAssignment is assigned to one user at a time, and if multiple roles are assigned the role string returned may not be predictable.
906935

907936
**Parameters:**
908937

@@ -969,7 +998,7 @@ When **source** value matches a **key**, returns **value** for that **key**. If
969998
| **value** |Required |String |Replacement value for the **source** matching the key. |
970999

9711000
#### Replace a value based on predefined set of options
972-
Example: You need to define the time zone of the user based on the state code stored in Azure AD.
1001+
Example: Define the time zone of the user based on the state code stored in Azure AD.
9731002
If the state code doesn't match any of the predefined options, use default value of "Australia/Sydney".
9741003

9751004
**Expression:**
@@ -1018,7 +1047,7 @@ ToUpper(source, culture)
10181047
**Description:**
10191048
Takes a *source* string value and converts it to upper case using the culture rules that are specified. If there is no *culture* info specified, then it will use Invariant culture.
10201049

1021-
If you would like to set existing values in the target system to upper case, please [update the schema for your target application](./customize-application-attributes.md#editing-the-list-of-supported-attributes) and set the property caseExact to 'true' for the attribute that you are interested in.
1050+
If you would like to set existing values in the target system to upper case, [update the schema for your target application](./customize-application-attributes.md#editing-the-list-of-supported-attributes) and set the property caseExact to 'true' for the attribute that you are interested in.
10221051

10231052
**Parameters:**
10241053

@@ -1062,7 +1091,7 @@ Returns "has".
10621091
This section provides more expression function usage examples.
10631092

10641093
### Strip known domain name
1065-
You need to strip a known domain name from a user's email to obtain a user name.
1094+
Strip a known domain name from a user's email to obtain a user name.
10661095
For example, if the domain is "contoso.com", then you could use the following expression:
10671096

10681097
**Expression:**
@@ -1075,7 +1104,7 @@ For example, if the domain is "contoso.com", then you could use the following ex
10751104

10761105

10771106
### Generate user alias by concatenating parts of first and last name
1078-
You need to generate a user alias by taking first 3 letters of user's first name and first 5 letters of user's last name.
1107+
Generate a user alias by taking first three letters of user's first name and first five letters of user's last name.
10791108

10801109
**Expression:**
10811110
`Append(Mid([givenName], 1, 3), Mid([surname], 1, 5))`

0 commit comments

Comments
 (0)