Azure AD Connect 同步:函数引用Azure AD Connect sync: Functions Reference

在 Azure AD Connect 中,函数用于在同步期间操作属性值。In Azure AD Connect, functions are used to manipulate an attribute value during synchronization.
函数的语法使用以下格式表示:The Syntax of the functions is expressed using the following format:
<output type> FunctionName(<input type> <position name>, ..)

如果函数被重载并接受多个语法,则会列出所有的有效语法。If a function is overloaded and accepts multiple syntaxes, all valid syntaxes are listed.
该函数为强类型函数,并会验证传递的类型是否匹配记录的类型。The functions are strongly typed and they verify that the type passed in matches the documented type.
如果类型不匹配,将引发错误。If the type does not match, an error is thrown.

类型使用以下语法表示:The types are expressed with the following syntax:

  • bin — 二进制bin - Binary
  • bool — 布尔值bool - Boolean
  • dt — UTC 日期/时间dt - UTC Date/Time
  • enum — 已知常量的枚举enum - Enumeration of known constants
  • exp — 表达式,计算结果预计为布尔值exp - Expression, which is expected to evaluate to a Boolean
  • mvbin — 多值二进制mvbin - Multi-Valued Binary
  • mvstr — 多值字符串mvstr - Multi-Valued String
  • mvref — 多值引用mvref - Multi-Valued Reference
  • num — 数值num - Numeric
  • ref — 引用ref - Reference
  • str — 字符串str - String
  • var –(几乎)任何其他类型的变体var - A variant of (almost) any other type
  • void — 不返回值void - doesn’t return a value

mvbin、mvstr 和 mvref 类型的函数只适用于多值属性。The functions with the types mvbin, mvstr, and mvref can only work on multi-valued attributes. bin、str 和 ref 类型的函数适用于单值和多值属性。Functions with bin, str, and ref work on both single-valued and multi-valued attributes.

函数引用Functions Reference

函数列表List of functions
证书Certificate
CertExtensionOidsCertExtensionOids CertFormatCertFormat CertFriendlyNameCertFriendlyName CertHashStringCertHashString
CertIssuerCertIssuer CertIssuerDNCertIssuerDN CertIssuerOidCertIssuerOid CertKeyAlgorithmCertKeyAlgorithm
CertKeyAlgorithmParamsCertKeyAlgorithmParams CertNameInfoCertNameInfo CertNotAfterCertNotAfter CertNotBeforeCertNotBefore
CertPublicKeyOidCertPublicKeyOid CertPublicKeyParametersOidCertPublicKeyParametersOid CertSerialNumberCertSerialNumber CertSignatureAlgorithmOidCertSignatureAlgorithmOid
CertSubjectCertSubject CertSubjectNameDNCertSubjectNameDN CertSubjectNameOidCertSubjectNameOid CertThumbprintCertThumbprint
CertVersionCertVersion IsCertIsCert
转换Conversion
CBoolCBool CDateCDate CGuidCGuid ConvertFromBase64ConvertFromBase64
ConvertToBase64ConvertToBase64 ConvertFromUTF8HexConvertFromUTF8Hex ConvertToUTF8HexConvertToUTF8Hex CNumCNum
CRefCRef CStrCStr StringFromGuidStringFromGuid StringFromSidStringFromSid
日期/时间Date / Time
DateAddDateAdd DateFromNumDateFromNum FormatDateTimeFormatDateTime NowNow
NumFromDateNumFromDate
DirectoryDirectory
DNComponentDNComponent DNComponentRevDNComponentRev EscapeDNComponentEscapeDNComponent
计算Evaluation
IsBitSetIsBitSet IsDateIsDate IsEmptyIsEmpty IsGuidIsGuid
IsNullIsNull IsNullOrEmptyIsNullOrEmpty IsNumericIsNumeric IsPresentIsPresent
IsStringIsString
数学Math
BitAndBitAnd BitOrBitOr RandomNumRandomNum
多值Multi-valued
ContainsContains CountCount ItemItem ItemOrNullItemOrNull
JoinJoin RemoveDuplicatesRemoveDuplicates 拆分Split
程序流Program Flow
ErrorError IIFIIF SelectSelect SwitchSwitch
WhereWhere WithWith
文本Text
GUIDGUID InStrInStr InStrRevInStrRev LCaseLCase
LeftLeft LenLen LTrimLTrim MidMid
PadLeftPadLeft PadRightPadRight PCasePCase ReplaceReplace
ReplaceCharsReplaceChars RightRight RTrimRTrim TrimTrim
UCaseUCase WordWord

BitAndBitAnd

说明:Description:
BitAnd 函数设置值的指定位。The BitAnd function sets specified bits on a value.

语法:Syntax:
num BitAnd(num value1, num value2)

  • value1、value2:应该使用 AND 联接在一起的数字值value1, value2: numeric values that should be AND’ed together

备注:Remarks:
此函数将两个参数转换为二进制表示形式,并将位设置为:This function converts both parameters to the binary representation and sets a bit to:

  • 0 - 如果掩码和标志中相应位的其中一个或两个均为 00 - if one or both of the corresponding bits in mask and flag are 0
  • 1 - 如果两个相应位均为 1。1 - if both of the corresponding bits are 1.

换而言之,除了当两个参数的相应位均为 1 时之外,所有情况下均返回 0。In other words, it returns 0 in all cases except when the corresponding bits of both parameters are 1.

示例:Example:
BitAnd(&HF, &HF7)
返回 7,因为十六进制 "F" AND "F7" 的计算结果为此值。Returns 7 because hexadecimal "F" AND "F7" evaluate to this value.


BitOrBitOr

说明:Description:
BitOr 函数设置值的指定位。The BitOr function sets specified bits on a value.

语法:Syntax:
num BitOr(num value1, num value2)

  • value1、value2:应该使用 OR 联接在一起的数字值value1, value2: numeric values that should be OR’ed together

备注:Remarks:
此函数将两个参数转换为二进制表示形式,当掩码和标志中相应位的其中一个或两个均为 1 时,将位设置为 1,当两个相应位均为 0 时,设置为 0。This function converts both parameters to the binary representation and sets a bit to 1 if one or both of the corresponding bits in mask and flag are 1, and to 0 if both of the corresponding bits are 0. 换而言之,除了当两个参数的相应位均为 0 时之外,所有情况下均返回 1。In other words, it returns 1 in all cases except where the corresponding bits of both parameters are 0.


CBoolCBool

说明:Description:
CBool 函数基于计算的表达式返回布尔值The CBool function returns a Boolean based on the evaluated expression

语法:Syntax:
bool CBool(exp Expression)

备注:Remarks:
如果表达式的计算结果为非零值,则 CBool 返回 True,否则返回 False。If the expression evaluates to a nonzero value, then CBool returns True, else it returns False.

示例:Example:
CBool([attrib1] = [attrib2])

如果两个属性具有相同的值,则返回 True。Returns True if both attributes have the same value.


CDateCDate

说明:Description:
CDate 函数通过字符串返回 UTC DateTime。The CDate function returns a UTC DateTime from a string. DateTime 不是 Sync 中的原生属性类型,但被某些函数使用。DateTime is not a native attribute type in Sync but is used by some functions.

语法:Syntax:
dt CDate(str value)

  • 值:具有日期、时间和可选时区的字符串Value: A string with a date, time, and optionally time zone

备注:Remarks:
返回的字符串始终采用 UTC 格式。The returned string is always in UTC.

示例:Example:
CDate([employeeStartTime])
基于员工的开始时间返回 DateTimeReturns a DateTime based on the employee’s start time

CDate("2013-01-10 4:00 PM -8")
返回表示 "2013-01-11 12:00 AM" 的 DateTimeReturns a DateTime representing "2013-01-11 12:00 AM"


CertExtensionOids CertExtensionOids

说明:Description:
返回证书对象所有关键扩展的 Oid 值。Returns the Oid values of all the critical extensions of a certificate object.

语法:Syntax:
mvstr CertExtensionOids(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertFormat CertFormat

说明:Description:
返回此 X.509v3 证书的格式名称。Returns the name of the format of this X.509v3 certificate.

语法:Syntax:
str CertFormat(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertFriendlyName CertFriendlyName

说明:Description:
返回证书的关联别名。Returns the associated alias for a certificate.

语法:Syntax:
str CertFriendlyName(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertHashString CertHashString

说明:Description:
以十六进制字符串的形式返回 X.509v3 证书的 SHA1 哈希值。Returns the SHA1 hash value for the X.509v3 certificate as a hexadecimal string.

语法:Syntax:
str CertHashString(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertIssuer CertIssuer

说明:Description:
返回颁发此 X.509v3 证书的证书颁发机构名称。Returns the name of the certificate authority that issued the X.509v3 certificate.

语法:Syntax:
str CertIssuer(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertIssuerDN CertIssuerDN

说明:Description:
返回证书颁发者的可分辨名称。Returns the distinguished name of the certificate issuer.

语法:Syntax:
str CertIssuerDN(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertIssuerOid CertIssuerOid

说明:Description:
返回证书颁发者的 Oid。Returns the Oid of the certificate issuer.

语法:Syntax:
str CertIssuerOid(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertKeyAlgorithm CertKeyAlgorithm

说明:Description:
以字符串形式返回此 X.509v3 证书的密钥算法信息。Returns the key algorithm information for this X.509v3 certificate as a string.

语法:Syntax:
str CertKeyAlgorithm(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertKeyAlgorithmParams CertKeyAlgorithmParams

说明:Description:
以十六进制字符串的形式返回此 X.509v3 证书的密钥算法参数。Returns the key algorithm parameters for the X.509v3 certificate as a hexadecimal string.

语法:Syntax:
str CertKeyAlgorithm(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertNameInfo CertNameInfo

说明:Description:
返回证书中的使用者和颁发者名称。Returns the subject and issuer names from a certificate.

语法:Syntax:
str CertNameInfo(binary certificateRawData, str x509NameType, bool includesIssuerName)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.
  • X509NameType:针对使用者的 X509NameType 值。X509NameType: The X509NameType value for the subject.
  • includesIssuerName:包含颁发者名称则为 true;否则为 false。includesIssuerName: true to include the issuer name; otherwise, false.

CertNotAfter CertNotAfter

说明:Description:
返回证书不再有效后的本地时间日期。Returns the date in local time after which a certificate is no longer valid.

语法:Syntax:
dt CertNotAfter(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertNotBefore CertNotBefore

说明:Description:
返回证书开始生效的本地时间日期。Returns the date in local time on which a certificate becomes valid.

语法:Syntax:
dt CertNotBefore(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertPublicKeyOid CertPublicKeyOid

说明:Description:
返回此 X.509v3 证书的公钥 Oid。Returns the Oid of the public key for the X.509v3 certificate.

语法:Syntax:
str CertKeyAlgorithm(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertPublicKeyParametersOid CertPublicKeyParametersOid

说明:Description:
返回此 X.509v3 证书的公钥参数 Oid。Returns the Oid of the public key parameters for the X.509v3 certificate.

语法:Syntax:
str CertPublicKeyParametersOid(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertSerialNumber CertSerialNumber

说明:Description:
返回 X.509v3 证书的序列号。Returns the serial number of the X.509v3 certificate.

语法:Syntax:
str CertSerialNumber(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertSignatureAlgorithmOid CertSignatureAlgorithmOid

说明:Description:
返回用于创建证书签名的算法 Oid。Returns the Oid of the algorithm used to create the signature of a certificate.

语法:Syntax:
str CertSignatureAlgorithmOid(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertSubject CertSubject

说明:Description:
获取证书中使用者的可分辨名称。Gets the subject distinguished name from a certificate.

语法:Syntax:
str CertSubject(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertSubjectNameDN CertSubjectNameDN

说明:Description:
返回证书中使用者的可分辨名称。Returns the subject distinguished name from a certificate.

语法:Syntax:
str CertSubjectNameDN(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertSubjectNameOid CertSubjectNameOid

说明:Description:
返回证书中使用者名称的 Oid。Returns the Oid of the subject name from a certificate.

语法:Syntax:
str CertSubjectNameOid(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertThumbprint CertThumbprint

说明:Description:
返回证书的指纹。Returns the thumbprint of a certificate.

语法:Syntax:
str CertThumbprint(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CertVersion CertVersion

说明:Description:
返回证书的 X.509 格式版本。Returns the X.509 format version of a certificate.

语法:Syntax:
str CertThumbprint(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

CGuidCGuid

说明:Description:
CGuid 函数将 GUID 的字符串表示转换为其二进制表示形式。The CGuid function converts the string representation of a GUID to its binary representation.

语法:Syntax:
bin CGuid(str GUID)

  • 采用如下模式设置格式的字符串:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 或 {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}A String formatted in this pattern: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

ContainsContains

说明:Description:
Contains 函数查找多值属性内的字符串The Contains function finds a string inside a multi-valued attribute

语法:Syntax:
num Contains (mvstring attribute, str search) - 区分大小写- case-sensitive
num Contains (mvstring attribute, str search, enum Casetype)
num Contains (mvref attribute, str search) - 区分大小写- case-sensitive

  • attribute:要搜索的多值属性。attribute: the multi-valued attribute to search.
  • search:在属性中查找的字符串。search: string to find in the attribute.
  • Casetype:CaseInsensitive 或 CaseSensitive。Casetype: CaseInsensitive or CaseSensitive.

返回找到字符串的多值属性中的索引。Returns index in the multi-valued attribute where the string was found. 如果未找到字符串,则返回 0。0 is returned if the string is not found.

备注:Remarks:
对于多值字符串属性,搜索在值中查找子字符串。For multi-valued string attributes, the search finds substrings in the values.
对于引用属性,搜索的字符串必须与视为匹配的值完全匹配。For reference attributes, the searched string must exactly match the value to be considered a match.

示例:Example:
IIF(Contains([proxyAddresses],"SMTP:")>0,[proxyAddresses],Error("No primary SMTP address found."))
如果 proxyAddresses 属性具有主电子邮件地址(由大写“SMTP:”表示),则返回 proxyAddress 属性,否则返回错误。If the proxyAddresses attribute has a primary email address (indicated by uppercase "SMTP:"), then return the proxyAddress attribute, else return an error.


ConvertFromBase64ConvertFromBase64

说明:Description:
ConvertFromBase64 函数将指定的 base64 编码值转换为规则的字符串。The ConvertFromBase64 function converts the specified base64 encoded value to a regular string.

语法:Syntax:
str ConvertFromBase64(str source) - 采用 Unicode 编码- assumes Unicode for encoding
str ConvertFromBase64(str source, enum Encoding)

  • source:Base64 编码的字符串source: Base64 encoded string
  • Encoding:Unicode、ASCII、UTF8Encoding: Unicode, ASCII, UTF8

示例Example
ConvertFromBase64("SABlAGwAbABvACAAdwBvAHIAbABkACEA")
ConvertFromBase64("SGVsbG8gd29ybGQh", UTF8)

这两个示例均返回 "Hello world!"Both examples return "Hello world!"


ConvertFromUTF8HexConvertFromUTF8Hex

说明:Description:
ConvertFromUTF8Hex 函数将指定的 UTF8 Hex 编码值转换为字符串。The ConvertFromUTF8Hex function converts the specified UTF8 Hex encoded value to a string.

语法:Syntax:
str ConvertFromUTF8Hex(str source)

  • source:UTF8 2 字节编码的字符串source: UTF8 2-byte encoded sting

备注:Remarks:
该结果中此函数和 ConvertFromBase64([],UTF8) 之间的差异对 DN 属性来说是可以接受的。The difference between this function and ConvertFromBase64([],UTF8) in that the result is friendly for the DN attribute.
此格式被 Azure Active Directory 用作 DN。This format is used by Azure Active Directory as DN.

示例:Example:
ConvertFromUTF8Hex("48656C6C6F20776F726C6421")
返回 "Hello world!"Returns "Hello world!"


ConvertToBase64ConvertToBase64

说明:Description:
ConvertToBase64 函数将字符串转换为 Unicode base64 字符串。The ConvertToBase64 function converts a string to a Unicode base64 string.
将整数数组的值转换为其等效字符串表示形式,该表示形式使用 base 64 数字编码。Converts the value of an array of integers to its equivalent string representation that is encoded with base-64 digits.

语法:Syntax:
str ConvertToBase64(str source)

示例:Example:
ConvertToBase64("Hello world!")
返回 "SABlAGwAbABvACAAdwBvAHIAbABkACEA"Returns "SABlAGwAbABvACAAdwBvAHIAbABkACEA"


ConvertToUTF8HexConvertToUTF8Hex

说明:Description:
ConvertToUTF8Hex 函数将字符串转换为 UTF8 Hex 编码的值。The ConvertToUTF8Hex function converts a string to a UTF8 Hex encoded value.

语法:Syntax:
str ConvertToUTF8Hex(str source)

备注:Remarks:
此函数的输出格式被 Azure Active Directory 用作 DN 属性。The output format of this function is used by Azure Active Directory as DN attribute format.

示例:Example:
ConvertToUTF8Hex("Hello world!")
返回 48656C6C6F20776F726C6421Returns 48656C6C6F20776F726C6421


计数Count

说明:Description:
Count 函数返回多值属性中的元素数量The Count function returns the number of elements in a multi-valued attribute

语法:Syntax:
num Count(mvstr attribute)


CNumCNum

说明:Description:
CNum 函数使用字符串并返回数值数据类型。The CNum function takes a string and returns a numeric data type.

语法:Syntax:
num CNum(str value)


CRefCRef

说明:Description:
将字符串转换为引用属性Converts a string to a reference attribute

语法:Syntax:
ref CRef(str value)

示例:Example:
CRef("CN=LC Services,CN=Microsoft,CN=lcspool01,CN=Pools,CN=RTC Service," & %Forest.LDAP%)


CStrCStr

说明:Description:
CStr 函数转换为字符串数据类型。The CStr function converts to a string data type.

语法:Syntax:
str CStr(num value)
str CStr(ref value)
str CStr(bool value)

  • value:可以是数字值、引用属性或布尔值。value: Can be a numeric value, reference attribute, or Boolean.

示例:Example:
CStr([dn])
可能返回 "cn=Joe,dc=contoso,dc=com"Could return "cn=Joe,dc=contoso,dc=com"


DateAddDateAdd

说明:Description:
返回日期,其中包含已添加制定时间间隔的日期。Returns a Date containing a date to which a specified time interval has been added.

语法:Syntax:
dt DateAdd(str interval, num value, dt date)

  • interval:字符串表达式,即需要添加的时间间隔。interval: String expression that is the interval of time you want to add. 字符串必须具有下列值之一:The string must have one of the following values:
    • yyyy Yearyyyy Year
    • q Quarterq Quarter
    • m Monthm Month
    • y Day of yeary Day of year
    • d Dayd Day
    • w Weekdayw Weekday
    • ww Weekww Week
    • h Hourh Hour
    • n Minuten Minute
    • s Seconds Second
  • value:要添加的单元数。value: The number of units you want to add. 它可以是正值(以获取将来的日期)或负值(以获取过去的日期)。It can be positive (to get dates in the future) or negative (to get dates in the past).
  • date:DateTime,表示已向其添加间隔的日期。date: DateTime representing date to which the interval is added.

示例:Example:
DateAdd("m", 3, CDate("2001-01-01"))
添加 3 个月,并返回表示 "2001-04-01" 的 DateTimeAdds 3 months and returns a DateTime representing "2001-04-01".


DateFromNumDateFromNum

说明:Description:
DateFromNum 函数将 AD 的日期格式的值转换为 DateTime 类型。The DateFromNum function converts a value in AD’s date format to a DateTime type.

语法:Syntax:
dt DateFromNum(num value)

示例:Example:
DateFromNum([lastLogonTimestamp])
DateFromNum(129699324000000000)
返回表示 2012-01-01 23:00:00 的 DateTimeReturns a DateTime representing 2012-01-01 23:00:00


DNComponentDNComponent

说明:Description:
DNComponent 函数返回从左边起的指定 DN 组件的值。The DNComponent function returns the value of a specified DN component going from left.

语法:Syntax:
str DNComponent(ref dn, num ComponentNumber)

  • dn:要解释的引用属性dn: the reference attribute to interpret
  • ComponentNumber:要返回的 DN 中的组件ComponentNumber: The component in the DN to return

示例:Example:
DNComponent(CRef([dn]),1)
如果 dn 为 "cn=Joe,ou=…,",则返回 JoeIf dn is "cn=Joe,ou=…," it returns Joe


DNComponentRevDNComponentRev

说明:Description:
DNComponentRev 函数返回从右边起(末尾)的指定 DN 组件的值。The DNComponentRev function returns the value of a specified DN component going from right (the end).

语法:Syntax:
str DNComponentRev(ref dn, num ComponentNumber)
str DNComponentRev(ref dn, num ComponentNumber, enum Options)

  • dn:要解释的引用属性dn: the reference attribute to interpret
  • ComponentNumber - 要返回的 DN 中的组件ComponentNumber - The component in the DN to return
  • 选项:DC - 忽略具有“dc=”的所有组件Options: DC - Ignore all components with "dc="

示例:Example:
如果 dn 为“cn=Joe,ou=Atlanta,ou=GA,ou=US, dc=contoso,dc=com”,则If dn is "cn=Joe,ou=Atlanta,ou=GA,ou=US, dc=contoso,dc=com" then
DNComponentRev(CRef([dn]),3)
DNComponentRev(CRef([dn]),1,"DC")
两者都返回 US。Both return US.


错误Error

说明:Description:
Error 函数用于返回自定义错误。The Error function is used to return a custom error.

语法:Syntax:
void Error(str ErrorMessage)

示例:Example:
IIF(IsPresent([accountName]),[accountName],Error("AccountName is required"))
如果属性 accountName 不存在,则对象上引发错误。If the attribute accountName is not present, throw an error on the object.


EscapeDNComponentEscapeDNComponent

说明:Description:
EscapeDNComponent 函数使用 DN 的一个组件,并对其进行转义,以便它可以在 LDAP 中表示。The EscapeDNComponent function takes one component of a DN and escapes it so it can be represented in LDAP.

语法:Syntax:
str EscapeDNComponent(str value)

示例:Example:
EscapeDNComponent("cn=" & [displayName]) & "," & %ForestLDAP%)
即使 displayName 属性具有必须在 LDAP 中转义的字符,请确保可以在 LDAP 目录中创建对象。Makes sure the object can be created in an LDAP directory even if the displayName attribute has characters that must be escaped in LDAP.


FormatDateTimeFormatDateTime

说明:Description:
FormatDateTime 函数用于为具有指定格式的字符串设置 DateTime 格式The FormatDateTime function is used to format a DateTime to a string with a specified format

语法:Syntax:
str FormatDateTime(dt value, str format)

  • value:DateTime 格式的值value: a value in the DateTime format
  • format:表示要转换为的格式的字符串。format: a string representing the format to convert to.

备注:Remarks:
格式的可能值可以在此处找到:FORMAT 函数的自定义日期和时间格式The possible values for the format can be found here: Custom date and time formats for the FORMAT function.

示例:Example:

FormatDateTime(CDate("12/25/2007"),"yyyy-mm-dd")
结果是 "2007-12-25"。Results in "2007-12-25".

FormatDateTime(DateFromNum([pwdLastSet]),"yyyyMMddHHmmss.0Z")
结果可能是 "20140905081453.0Z"Can result in "20140905081453.0Z"


GuidGuid

说明:Description:
函数 GUID 生成新的随机 GUIDThe function Guid generates a new random GUID

语法:Syntax:
str Guid()


IIFIIF

说明:Description:
IIF 函数基于指定的条件返回一组可能值中的其中一个值。The IIF function returns one of a set of possible values based on a specified condition.

语法:Syntax:
var IIF(exp condition, var valueIfTrue, var valueIfFalse)

  • condition:计算结果可能为 true 或 false 的任何值或表达式。condition: any value or expression that can be evaluated to true or false.
  • valueIfTrue:如果条件计算结果为 true,则为返回值。valueIfTrue: If the condition evaluates to true, the returned value.
  • valueIfFalse:如果条件计算结果为 false,则为返回值。valueIfFalse: If the condition evaluates to false, the returned value.

示例:Example:
IIF([employeeType]="Intern","t-" & [alias],[alias])
如果用户是实习生,则返回用户的别名,同时将 "t-" 添加到其开头,否则按原样返回用户的别名。If the user is an intern, returns the alias of a user with "t-" added to the beginning of it, else returns the user’s alias as is.


InStrInStr

说明:Description:
InStr 函数查找字符串中第一次出现的子字符串The InStr function finds the first occurrence of a substring in a string

语法:Syntax:

num InStr(str stringcheck, str stringmatch)
num InStr(str stringcheck, str stringmatch, num start)
num InStr(str stringcheck, str stringmatch, num start , enum compare)

  • stringcheck:要搜索的字符串stringcheck: string to be searched
  • stringmatch:要查找的字符串stringmatch: string to be found
  • start:查找子字符串的起始位置start: starting position to find the substring
  • compare:vbTextCompare 或 vbBinaryComparecompare: vbTextCompare or vbBinaryCompare

备注:Remarks:
返回其中已找到子字符串的位置,如果未找到,则返回 0。Returns the position where the substring was found or 0 if not found.

示例:Example:
InStr("The quick brown fox","quick")
计算结果为 5Evalues to 5

InStr("repEated","e",3,vbBinaryCompare)
计算结果为 7Evaluates to 7


InStrRevInStrRev

说明:Description:
InStrRev 函数查找字符串中最后一次出现的子字符串The InStrRev function finds the last occurrence of a substring in a string

语法:Syntax:
num InstrRev(str stringcheck, str stringmatch)
num InstrRev(str stringcheck, str stringmatch, num start)
num InstrRev(str stringcheck, str stringmatch, num start, enum compare)

  • stringcheck:要搜索的字符串stringcheck: string to be searched
  • stringmatch:要查找的字符串stringmatch: string to be found
  • start:查找子字符串的起始位置start: starting position to find the substring
  • compare:vbTextCompare 或 vbBinaryComparecompare: vbTextCompare or vbBinaryCompare

备注:Remarks:
返回其中已找到子字符串的位置,如果未找到,则返回 0。Returns the position where the substring was found or 0 if not found.

示例:Example:
InStrRev("abbcdbbbef","bb")
返回 7Returns 7


IsBitSetIsBitSet

说明:Description:
函数 IsBitSet 测试是否设置了位The function IsBitSet Tests if a bit is set or not

语法:Syntax:
bool IsBitSet(num value, num flag)

  • value:计算的数字值。标志:表示具有要计算的位的数字值value: a numeric value that is evaluated.flag: a numeric value that has the bit to be evaluated

示例:Example:
IsBitSet(&HF,4)
返回 True,因为位 "4" 在十六进制值 "F" 中设置Returns True because bit "4" is set in the hexadecimal value "F"


IsDateIsDate

说明:Description:
如果表达式可以计算为 DateTime 类型,则 IsDate 函数计算结果为 True。If the expression can be evaluates as a DateTime type, then the IsDate function evaluates to True.

语法:Syntax:
bool IsDate(var Expression)

备注:Remarks:
用来确定 CDate() 是否成功。Used to determine if CDate() can be successful.


IsCert IsCert

说明:Description:
如果原始数据可以序列化为 .NET X509Certificate2 证书对象,则返回 true。Returns true if the raw data can be serialized into .NET X509Certificate2 certificate object.

语法:Syntax:
bool CertThumbprint(binary certificateRawData)

  • certificateRawData:X.509 证书的字节数组表示形式。certificateRawData: Byte array representation of an X.509 certificate. 字节数组可以是编码的二进制文件 (DER) 或 Base64 编码的 X.509 数据。The byte array can be binary (DER) encoded or Base64-encoded X.509 data.

IsEmptyIsEmpty

说明:Description:
如果属性出现在 CS 或 MV 中,但计算结果为空字符串,则 IsEmpty 函数计算结果为 True。If the attribute is present in the CS or MV but evaluates to an empty string, then the IsEmpty function evaluates to True.

语法:Syntax:
bool IsEmpty(var Expression)


IsGuidIsGuid

说明:Description:
如果字符串可以转换为 GUID,则 IsGuid 函数计算结果为 true。If the string could be converted to a GUID, then the IsGuid function evaluated to true.

语法:Syntax:
bool IsGuid(str GUID)

备注:Remarks:
GUID 定义为遵循以下其中一种模式的字符串:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 或 {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}A GUID is defined as a string following one of these patterns: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

用来确定 CGuid() 是否成功。Used to determine if CGuid() can be successful.

示例:Example:
IIF(IsGuid([strAttribute]),CGuid([strAttribute]),NULL)
如果 StrAttribute 具有 GUID 格式,则返回二进制表示形式,否则返回 Null。If the StrAttribute has a GUID format, return a binary representation, otherwise return a Null.


IsNullIsNull

说明:Description:
如果表达式的计算结果为 Null,则 IsNull 函数返回 true。If the expression evaluates to Null, then the IsNull function returns true.

语法:Syntax:
bool IsNull(var Expression)

备注:Remarks:
对于属性,Null 表示缺少属性。For an attribute, a Null is expressed by the absence of the attribute.

示例:Example:
IsNull([displayName])
如果属性没有在 CS 或 MV 中出现,则返回 True。Returns True if the attribute is not present in the CS or MV.


IsNullOrEmptyIsNullOrEmpty

说明:Description:
如果表达式为 null 或空字符串,则 IsNullOrEmpty 函数返回 true。If the expression is null or an empty string, then the IsNullOrEmpty function returns true.

语法:Syntax:
bool IsNullOrEmpty(var Expression)

备注:Remarks:
对于属性,如果属性不存在,或存在但为空字符串,此语法计算结果则为 True。For an attribute, this would evaluate to True if the attribute is absent or is present but is an empty string.
此函数的逆函数命名为 IsPresent。The inverse of this function is named IsPresent.

示例:Example:
IsNullOrEmpty([displayName])
如果属性在 CS 或 MV 中没有出现或为空字符串,则返回 True。Returns True if the attribute is not present or is an empty string in the CS or MV.


IsNumericIsNumeric

说明:Description:
IsNumeric 函数返回布尔值,该值指示表达式是否可以计算为数字类型。The IsNumeric function returns a Boolean value indicating whether an expression can be evaluated as a number type.

语法:Syntax:
bool IsNumeric(var Expression)

备注:Remarks:
用来确定 CNum() 是否能成功分析表达式。Used to determine if CNum() can be successful to parse the expression.


IsStringIsString

说明:Description:
如果表达式可以计算为字符串类型,则 IsString 函数计算结果为 True。If the expression can be evaluated to a string type, then the IsString function evaluates to True.

语法:Syntax:
bool IsString(var expression)

备注:Remarks:
用来确定 CStr() 是否能成功分析表达式。Used to determine if CStr() can be successful to parse the expression.


IsPresentIsPresent

说明:Description:
如果表达式的计算结果为字符串,该字符串不是 Null 且不为空,则 IsPresent 函数返回 true。If the expression evaluates to a string that is not Null and is not empty, then the IsPresent function returns true.

语法:Syntax:
bool IsPresent(var expression)

备注:Remarks:
此函数的逆函数被命名为 IsNullOrEmpty。The inverse of this function is named IsNullOrEmpty.

示例:Example:
Switch(IsPresent([directManager]),[directManager], IsPresent([skiplevelManager]),[skiplevelManager], IsPresent([director]),[director])


项目Item

说明:Description:
Item 函数返回多值字符串/属性中的一个项。The Item function returns one item from a multi-valued string/attribute.

语法:Syntax:
var Item(mvstr attribute, num index)

  • attribute:多值属性attribute: multi-valued attribute
  • index:对多值字符串中某个项的索引。index: index to an item in the multi-valued string.

备注:Remarks:
Item 函数与 Contains 函数一起使用很有利,因为后一函数返回对多值属性中某个项的索引。The Item function is useful together with the Contains function since the latter function returns the index to an item in the multi-valued attribute.

如果索引超出界限,则引发错误。Throws an error if index is out of bounds.

示例:Example:
Mid(Item([proxyAddresses],Contains([proxyAddresses], "SMTP:")),6)
返回主电子邮件地址。Returns the primary email address.


ItemOrNullItemOrNull

说明:Description:
ItemOrNull 函数返回多值字符串/属性中的一个项。The ItemOrNull function returns one item from a multi-valued string/attribute.

语法:Syntax:
var ItemOrNull(mvstr attribute, num index)

  • attribute:多值属性attribute: multi-valued attribute
  • index:对多值字符串中某个项的索引。index: index to an item in the multi-valued string.

备注:Remarks:
ItemOrNull 函数与 Contains 函数一起使用很有利,因为后一函数返回对多值属性中某个项的索引。The ItemOrNull function is useful together with the Contains function since the latter function returns the index to an item in the multi-valued attribute.

如果索引超出界限,则返回 Null 值。If index is out of bounds, then returns a Null value.


JoinJoin

说明:Description:
Join 函数使用多值字符串,并返回每个项之间插入指定分隔符的单值字符串。The Join function takes a multi-valued string and returns a single-valued string with specified separator inserted between each item.

语法:Syntax:
str Join(mvstr attribute)
str Join(mvstr attribute, str Delimiter)

  • 属性:包含要联接的字符串的多值属性。attribute: Multi-valued attribute containing strings to be joined.
  • delimiter:任意字符串,用于分隔返回的字符串中的子字符串。delimiter: Any string, used to separate the substrings in the returned string. 如果省略,则使用空格字符(“ ”)。If omitted, the space character (" ") is used. 如果分隔符为零长度字符串(“”)或零,则列表中的所有项都不使用分隔符连接。If Delimiter is a zero-length string ("") or Nothing, all items in the list are concatenated with no delimiters.

备注Remarks
Join 和 Split 函数之间没有奇偶校验。There is parity between the Join and Split functions. Join 函数使用字符串数组,并使用分隔符字符串将它们联接起来,以返回单个字符串。The Join function takes an array of strings and joins them using a delimiter string, to return a single string. Split 函数使用字符串并以分隔符分隔,以返回字符串数组。The Split function takes a string and separates it at the delimiter, to return an array of strings. 但是,主要区别是 Join 可以使用任何分隔符字符串将字符串连接起来,而 Split 仅可以使用单个字符分隔符分隔字符串。However, a key difference is that Join can concatenate strings with any delimiter string, Split can only separate strings using a single character delimiter.

示例:Example:
Join([proxyAddresses],",")
可能返回:“SMTP:john.doe@contoso.com,smtp:jd@contoso.com”Could return: "SMTP:john.doe@contoso.com,smtp:jd@contoso.com"


LCaseLCase

说明:Description:
LCase 函数将字符串中的所有字符都转换为小写。The LCase function converts all characters in a string to lower case.

语法:Syntax:
str LCase(str value)

示例:Example:
LCase("TeSt")
返回 "test"。Returns "test".


LeftLeft

说明:Description:
Left 函数从字符串左侧起返回指定的字符数。The Left function returns a specified number of characters from the left of a string.

语法:Syntax:
str Left(str string, num NumChars)

  • string:从中返回字符的字符串string: the string to return characters from
  • NumChar:标识从字符串开头(左侧)起返回的字符数的数字NumChars: a number identifying the number of characters to return from the beginning (left) of string

备注:Remarks:
包含字符串中第一个 numChars 字符的字符串:A string containing the first numChars characters in string:

  • 如果 numChar = 0,则返回空字符串。If numChars = 0, return empty string.
  • 如果 numChar < 0,则返回输入字符串。If numChars < 0, return input string.
  • 如果字符串为 null,则返回空字符串。If string is null, return empty string.

如果字符串包含的字符数比 numChars 中指定的数量少,则返回与该字符串相同的字符串(即,包含参数 1 中的所有字符)。If string contains fewer characters than the number specified in numChars, a string identical to string (that is, containing all characters in parameter 1) is returned.

示例:Example:
Left("John Doe", 3)
返回 “Joh”。Returns "Joh".


LenLen

说明:Description:
Len 函数返回字符串中的字符数。The Len function returns number of characters in a string.

语法:Syntax:
num Len(str value)

示例:Example:
Len("John Doe")
返回 8Returns 8


LTrimLTrim

说明:Description:
LTrim 函数从字符串中删除前导空格。The LTrim function removes leading white spaces from a string.

语法:Syntax:
str LTrim(str value)

示例:Example:
LTrim(" Test ")
返回 "Test"Returns "Test "


MidMid

说明:Description:
Mid 函数从字符串指定位置起返回指定的字符数。The Mid function returns a specified number of characters from a specified position in a string.

语法:Syntax:
str Mid(str string, num start, num NumChars)

  • string:从中返回字符的字符串string: the string to return characters from
  • start:标识从中返回字符的字符串中起始位置的数字start: a number identifying the starting position in string to return characters from
  • NumChar:标识从字符串中的位置返回的字符数的数字NumChars: a number identifying the number of characters to return from position in string

备注:Remarks:
从字符串中的开始位置开始返回 numChars 字符。Return numChars characters starting from position start in string.
包含字符串中开始位置的 numChar 字符的字符串:A string containing numChars characters from position start in string:

  • 如果 numChar = 0,则返回空字符串。If numChars = 0, return empty string.
  • 如果 numChar < 0,则返回输入字符串。If numChars < 0, return input string.
  • 如果 start > 字符串的长度,则返回输入字符串。If start > the length of string, return input string.
  • 如果 start <= 0,则返回输入字符串。If start <= 0, return input string.
  • 如果字符串为 null,则返回空字符串。If string is null, return empty string.

如果字符串中开始位置没有保留的 numChar 字符,则返回尽可能多的字符。If there are not numChar characters remaining in string from position start, as many characters as possible are returned.

示例:Example:
Mid("John Doe", 3, 5)
返回 "hn Do"。Returns "hn Do".

Mid("John Doe", 6, 999)
返回 "Doe"Returns "Doe"


NowNow

说明:Description:
Now 函数根据计算机的系统日期和时间返回指定当前日期和时间的 DateTime。The Now function returns a DateTime specifying the current date and time, according to your computer's system date and time.

语法:Syntax:
dt Now()


NumFromDateNumFromDate

说明:Description:
NumFromDate 函数返回 AD 的日期格式的日期。The NumFromDate function returns a date in AD’s date format.

语法:Syntax:
num NumFromDate(dt value)

示例:Example:
NumFromDate(CDate("2012-01-01 23:00:00"))
返回 129699324000000000Returns 129699324000000000


PadLeftPadLeft

说明:Description:
PadLeft 函数使用提供的填充字符将字符串从左侧填充到指定长度。The PadLeft function left-pads a string to a specified length using a provided padding character.

语法:Syntax:
str PadLeft(str string, num length, str padCharacter)

  • string:要填充的字符串。string: the string to pad.
  • length:表示所需字符串长度的整数。length: An integer representing the desired length of string.
  • padCharacter:包含用作填充字符的单个字符的字符串padCharacter: A string consisting of a single character to use as the pad character

备注:Remarks:

  • 如果字符串的长度小于 length,则 padCharacter 会向字符串的开头(左侧)反复追加,直到其长度等于 length。If the length of string is less than length, then padCharacter is repeatedly appended to the beginning (left) of string until it has a length equal to length.
  • PadCharacter 可以是空格字符,但不能为 null 值。PadCharacter can be a space character, but it cannot be a null value.
  • 如果字符串的长度等于或大于 length,则返回不变的字符串。If the length of string is equal to or greater than length, string is returned unchanged.
  • 如果字符串的长度大于或等于 length,则返回与 string 相同的字符串。If string has a length greater than or equal to length, a string identical to string is returned.
  • 如果字符串的长度小于 length,则返回具有所需长度的新字符串,其中包含用 padCharacter 填充的字符串。If the length of string is less than length, then a new string of the desired length is returned containing string padded with a padCharacter.
  • 如果字符串为 null,该函数则返回空字符串。If string is null, the function returns an empty string.

示例:Example:
PadLeft("User", 10, "0")
返回 "000000User"。Returns "000000User".


PadRightPadRight

说明:Description:
PadRight 函数使用提供的填充字符将字符串从右侧填充到指定长度。The PadRight function right-pads a string to a specified length using a provided padding character.

语法:Syntax:
str PadRight(str string, num length, str padCharacter)

  • string:要填充的字符串。string: the string to pad.
  • length:表示所需字符串长度的整数。length: An integer representing the desired length of string.
  • padCharacter:包含用作填充字符的单个字符的字符串padCharacter: A string consisting of a single character to use as the pad character

备注:Remarks:

  • 如果字符串的长度小于 length,则 padCharacter 向字符串的末尾(右侧)反复追加,直到其长度等于 length。If the length of string is less than length, then padCharacter is repeatedly appended to the end (right) of string until it has a length equal to length.
  • PadCharacter 可以是空格字符,但不能为 null 值。padCharacter can be a space character, but it cannot be a null value.
  • 如果字符串的长度等于或大于 length,则返回不变的字符串。If the length of string is equal to or greater than length, string is returned unchanged.
  • 如果字符串的长度大于或等于 length,则返回与 string 相同的字符串。If string has a length greater than or equal to length, a string identical to string is returned.
  • 如果字符串的长度小于 length,则返回具有所需长度的新字符串,其中包含用 padCharacter 填充的字符串。If the length of string is less than length, then a new string of the desired length is returned containing string padded with a padCharacter.
  • 如果字符串为 null,该函数则返回空字符串。If string is null, the function returns an empty string.

示例:Example:
PadRight("User", 10, "0")
返回 "User000000"。Returns "User000000".


PCasePCase

说明:Description:
PCase 函数将字符串中每个空格分隔词的第一个字符转换为大写形式,并将所有其他字符都转换为小写形式。The PCase function converts the first character of each space delimited word in a string to upper case, and all other characters are converted to lower case.

语法:Syntax:
String PCase(string)

备注:Remarks:

  • 此函数目前无法正常转换全大写单词(例如首字母缩写词)的大小写。This function does not currently provide proper casing to convert a word that is entirely uppercase, such as an acronym.

示例:Example:
PCase("TEsT")
返回 "test"。Returns "Test".

PCase(LCase("TEST"))
返回 "Test"Returns "Test"


RandomNumRandomNum

说明:Description:
RandomNum 函数返回指定间隔之间的随机数字。The RandomNum function returns a random number between a specified interval.

语法:Syntax:
num RandomNum(num start, num end)

  • start:标识要生成的随机值的下限的数字start: a number identifying the lower limit of the random value to generate
  • end:标识要生成的随机值的上限的数字end: a number identifying the upper limit of the random value to generate

示例:Example:
Random(100,999)
可以返回 734。Can return 734.


RemoveDuplicatesRemoveDuplicates

说明:Description:
RemoveDuplicates 函数使用多值字符串,并确保每个值都是唯一值。The RemoveDuplicates function takes a multi-valued string and make sure each value is unique.

语法:Syntax:
mvstr RemoveDuplicates(mvstr attribute)

示例:Example:
RemoveDuplicates([proxyAddresses])
返回净化的 proxyAddress 属性,其中所有重复值已被删除。Returns a sanitized proxyAddress attribute where all duplicate values have been removed.


ReplaceReplace

说明:Description:
Replace 函数将所有出现的某一字符串替换为另一个字符串。The Replace function replaces all occurrences of a string to another string.

语法:Syntax:
str Replace(str string, str OldValue, str NewValue)

  • string:替换其中的值的字符串。string: A string to replace values in.
  • OldValue:要搜索和替换的字符串。OldValue: The string to search for and to replace.
  • NewValue:要替换的字符串。NewValue: The string to replace to.

备注:Remarks:
该函数可以识别以下特殊 moniker:The function recognizes the following special monikers:

  • \n – 新行\n - New Line
  • \r – 回车符\r - Carriage Return
  • \t – Tab\t - Tab

示例:Example:
Replace([address],"\r\n",", ")
将 CRLF 替换为逗号和空格,可能导致出现“One Microsoft Way, Redmond, WA, USA”Replaces CRLF with a comma and space, and could lead to "One Microsoft Way, Redmond, WA, USA"


ReplaceCharsReplaceChars

说明:Description:
ReplaceChars 函数替换 ReplacePattern 字符串中找到的所有出现的字符。The ReplaceChars function replaces all occurrences of characters found in the ReplacePattern string.

语法:Syntax:
str ReplaceChars(str string, str ReplacePattern)

  • string:要替换其中的字符的字符串。string: A string to replace characters in.
  • ReplacePattern:包含具有要替换字符的字典的字符串。ReplacePattern: a string containing a dictionary with characters to replace.

格式为 {source1}:{target1},{source2}:{target2},{sourceN},{targetN},其中源是要查找并确定要替换的目标字符串的字符。The format is {source1}:{target1},{source2}:{target2},{sourceN},{targetN} where source is the character to find and target the string to replace with.

备注:Remarks:

  • 该函数使用每次出现的定义的源,并使用目标替换它们。The function takes each occurrence of defined sources and replaces them with the targets.
  • 源必须正好是一个 (unicode) 字符。The source must be exactly one (unicode) character.
  • 源不能为空或长度超过一个字符(分析错误)。The source cannot be empty or longer than one character (parsing error).
  • 目标可以有多个字符,例如 ö:oe、β:ss。The target can have multiple characters, for example ö:oe, β:ss.
  • 目标可以为空,该值指示应删除字符。The target can be empty indicating that the character should be removed.
  • 源区分大小写,并且必须是完全匹配。The source is case-sensitive and must be an exact match.
  • 逗号 (,) 和冒号 (:) 是保留字符,不能使用此函数进行替换。The , (comma) and : (colon) are reserved characters and cannot be replaced using this function.
  • 空格和 ReplacePattern 字符串中的其他空白字符被忽略。Spaces and other white characters in the ReplacePattern string are ignored.

示例:Example:
%ReplaceString% = ’:,Å:A,Ä:A,Ö:O,å:a,ä:a,ö,o

ReplaceChars("Räksmörgås",%ReplaceString%)
返回 RaksmorgasReturns Raksmorgas

ReplaceChars("O’Neil",%ReplaceString%)
返回 "ONeil",定义要删除单次勾选。Returns "ONeil", the single tick is defined to be removed.


说明:Description:
Right 函数从字符串右侧(末尾)起返回指定的字符数。The Right function returns a specified number of characters from the right (end) of a string.

语法:Syntax:
str Right(str string, num NumChars)

  • string:从中返回字符的字符串string: the string to return characters from
  • NumChar:标识从字符串末尾(右侧)起返回的字符数的数字NumChars: a number identifying the number of characters to return from the end (right) of string

备注:Remarks:
NumChars 字符从字符串的最后位置返回。NumChars characters are returned from the last position of string.

包含字符串中最后的 numChar 字符的字符串:A string containing the last numChars characters in string:

  • 如果 numChar = 0,则返回空字符串。If numChars = 0, return empty string.
  • 如果 numChar < 0,则返回输入字符串。If numChars < 0, return input string.
  • 如果字符串为 null,则返回空字符串。If string is null, return empty string.

如果字符串包含的字符数比 NumChar 中指定的数量少,则返回与该字符串相同的字符串。If string contains fewer characters than the number specified in NumChars, a string identical to string is returned.

示例:Example:
Right("John Doe", 3)
返回 "Doe"。Returns "Doe".


RTrimRTrim

说明:Description:
RTrim 函数从字符串中删除尾随空格。The RTrim function removes trailing white spaces from a string.

语法:Syntax:
str RTrim(str value)

示例:Example:
RTrim(" Test ")
返回 "Test"。Returns " Test".


选择 Select

说明:Description:
根据指定函数处理多值属性(或表达式输出)中的所有值。Process all values in a multi-valued attribute (or output of an expression) based on function specified.

语法:Syntax:
mvattr Select(variable item, mvattr attribute, func function)
mvattr Select(variable item, exp expression, func function)

  • item:表示多值属性中的元素item: Represents an element in the multi-valued attribute
  • attribute:多值属性attribute: the multi-valued attribute
  • expression:一个返回值集合的表达式expression: an expression that returns a collection of values
  • condition:可以处理属性中某个项的任何函数condition: any function that can process an item in the attribute

示例:Examples:
Select($item,[otherPhone],Replace($item,"-",""))
在删除连字符 (-) 后,返回多值属性 otherPhone 中的所有值。Return all the values in the multi-valued attribute otherPhone after hyphens (-) have been removed.


拆分Split

说明:Description:
Split 函数使用采用分隔符分隔的字符串,并使其成为多值字符串。The Split function takes a string separated with a delimiter and makes it a multi-valued string.

语法:Syntax:
mvstr Split(str value, str delimiter)
mvstr Split(str value, str delimiter, num limit)

  • value:用分隔符字符来分隔的字符串。value: the string with a delimiter character to separate.
  • delimiter:用作分隔符的单个字符。delimiter: single character to be used as the delimiter.
  • limit:可返回的最大数目的值。limit: maximum number of values that can return.

示例:Example:
Split("SMTP:john.doe@contoso.com,smtp:jd@contoso.com",",")
返回多值字符串,其中 2 个元素对 proxyAddress 属性有用。Returns a multi-valued string with 2 elements useful for the proxyAddress attribute.


StringFromGuidStringFromGuid

说明:Description:
StringFromGuid 函数使用二进制 GUID,并将其转换为字符串The StringFromGuid function takes a binary GUID and converts it to a string

语法:Syntax:
str StringFromGuid(bin GUID)


StringFromSidStringFromSid

说明:Description:
StringFromSid 函数包含安全标识符的字节数组转换为字符串。The StringFromSid function converts a byte array containing a security identifier to a string.

语法:Syntax:
str StringFromSid(bin ObjectSID)


SwitchSwitch

说明:Description:
Switch 函数用于基于计算的条件返回单个值。The Switch function is used to return a single value based on evaluated conditions.

语法:Syntax:
var Switch(exp expr1, var value1[, exp expr2, var value … [, exp expr, var valueN]])

  • expr:需要计算其结果的变体表达式。expr: Variant expression you want to evaluate.
  • value:当相应表达式为 True 时要返回的值。value: Value to be returned if the corresponding expression is True.

备注:Remarks:
Switch 函数参数列表包含表达式和值对。The Switch function argument list consists of pairs of expressions and values. 表达式从左到右计算结果,并返回与计算结果为 True 的第一个表达式相关联的值。The expressions are evaluated from left to right, and the value associated with the first expression to evaluate to True is returned. 如果没有正确配对部件,则会发生运行时错误。If the parts aren't properly paired, a run-time error occurs.

例如,如果 expr1 为 True,则 Switch 返回 value1。For example, if expr1 is True, Switch returns value1. 如果 expr-1 为 False,但 expr-2 为 True,则 Switch 返回 value-2,依此类推。If expr-1 is False, but expr-2 is True, Switch returns value-2, and so on.

如果满足以下条件,Switch 返回 Nothing:Switch returns a Nothing if:

  • 没有任何表达式求值为 True。None of the expressions are True.
  • 第一个 True 表达式的相应值为 Null。The first True expression has a corresponding value that is Null.

Switch 对所有表达式求值,即使它只返回其中一个结果。Switch evaluates all expressions, even though it returns only one of them. 为此,应监视非预期的负面影响。For this reason, you should watch for undesirable side effects. 例如,如果任何表达式的计算结果导致除数为零的错误,则会出现错误。For example, if the evaluation of any expression results in a division by zero error, an error occurs.

值还可以是返回自定义字符串的错误函数。Value can also be the Error function, which would return a custom string.

示例:Example:
Switch([city] = "London", "English", [city] = "Rome", "Italian", [city] = "Paris", "French", True, Error("Unknown city"))
返回某些主要城市所使用的语言,否则返回错误。Returns the language spoken in some major cities, otherwise returns an Error.


TrimTrim

说明:Description:
Trim 函数从字符串中删除前导空格和尾随空格。The Trim function removes leading and trailing white spaces from a string.

语法:Syntax:
str Trim(str value)

示例:Example:
Trim(" Test ")
返回 "test"。Returns "Test".

Trim([proxyAddresses])
删除 proxyAddress 属性中每个值的前导空格和尾随空格。Removes leading and trailing spaces for each value in the proxyAddress attribute.


UCaseUCase

说明:Description:
UCase 函数将字符串中的所有字符都转换为大写形式。The UCase function converts all characters in a string to upper case.

语法:Syntax:
str UCase(str string)

示例:Example:
UCase("TeSt")
返回 "test"。Returns "TEST".


Where Where

说明:Description:
根据指定条件,从多值属性(或表达式输出)中返回值子集。Returns a subset of values from a multi-valued attribute (or output of an expression) based on specific condition.

语法:Syntax:
mvattr Where(variable item, mvattr attribute, exp condition)
mvattr Where(variable item, exp expression, exp condition)

  • item:表示多值属性中的元素item: Represents an element in the multi-valued attribute
  • attribute:多值属性attribute: the multi-valued attribute
  • condition:计算结果可能为 true 或 false 的任何表达式condition: any expression that can be evaluated to true or false
  • expression:一个返回值集合的表达式expression: an expression that returns a collection of values

示例:Example:
Where($item,[userCertificate],CertNotAfter($item)>Now())
返回多值属性 userCertificate 中未过期的证书值。Return the certificate values in the multi-valued attribute userCertificate which aren’t expired.


With With

说明:Description:
通过使用变量来表示在复杂表达式中出现一次或多次的子表达式,With 函数提供了一种简化复杂表达式的方法。The With function provides a way to simplify a complex expression by using a variable to represent a subexpression which appears one or more times in the complex expression.

语法:Syntax: With(var variable, exp subExpression, exp complexExpression)

  • variable:表示子表达式。variable: Represents the subexpression.
  • subExpression:由变量表示的子表达式。subExpression: subexpression represented by variable.
  • complexExpression:复杂表达式。complexExpression: A complex expression.

示例:Example:
With($unExpiredCerts,Where($item,[userCertificate],CertNotAfter($item)>Now()),IIF(Count($unExpiredCerts)>0,$unExpiredCerts,NULL))
在功能上等效于:Is functionally equivalent to:
IIF (Count(Where($item,[userCertificate],CertNotAfter($item)>Now()))>0, Where($item,[userCertificate],CertNotAfter($item)>Now()),NULL)
它在 userCertificate 属性中仅返回未过期的证书值。Which returns only unexpired certificate values in the userCertificate attribute.


WordWord

说明:Description:
基于描述要使用的分隔符与要返回的单词数的参数,Word 函数返回字符串中包含的单词。The Word function returns a word contained within a string, based on parameters describing the delimiters to use and the word number to return.

语法:Syntax:
str Word(str string, num WordNumber, str delimiters)

  • string:从中返回单词的字符串。string: the string to return a word from.
  • WordNumber:标识应返回单词数的数字。WordNumber: a number identifying which word number should return.
  • delimiter:表示应该用于标识单词的分隔符的字符串delimiters: a string representing the delimiter(s) that should be used to identify words

备注:Remarks:
字符串中的字符由分隔符中其中一个字符分隔的每个字符串被标识为单词:Each string of characters in string separated by the one of the characters in delimiters are identified as words:

  • 如果数字 < 1,则返回空字符串。If number < 1, returns empty string.
  • 如果字符串为 null,则返回空字符串。If string is null, returns empty string.

如果字符串包含的单词少于应返回数字或字符串不包含由分隔符标识的任何单词,则返回空字符串。If string contains less than number words, or string does not contain any words identified by delimiters, an empty string is returned.

示例:Example:
Word("The quick brown fox",3," ")
返回 "brown"Returns "brown"

Word("This,string!has&many separators",3,",!&#")
返回 "has"Would return "has"

其他资源Additional Resources