microsoft.ad.split_dn filter – Splits an LDAP DistinguishedName.

Note

This filter plugin is part of the microsoft.ad collection (version 1.8.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install microsoft.ad.

To use it in a playbook, specify: microsoft.ad.split_dn.

New in microsoft.ad 1.8.0

Synopsis

  • Splits the provided LDAP DistinguishedName (DN) string value giving you the first/leaf RDN component or the remaining/parent RDN components.

  • The rules for parsing as defined in RFC 4514.

  • Each DN contains Relative DistinguishedNames (RDN) separated by ,.

  • The returned string for each DN will be either the first/leaf RDN component representing the name of the object, or the remaining/parent components representing the parent DN path. Use the section kwarg to control what should be returned.

  • A DN that is invalid will raise a filter error.

  • As the values are canonicalized, the returned values may not match the original DN string provided but do represent the same LDAP DN value.

  • Leading and trailing whitespace from each component is removed from the returned value.

Input

This describes the input of the filter, the value before | microsoft.ad.split_dn.

Parameter

Comments

Input

string / required

The LDAP DistinguishedName string to split.

Keyword parameters

This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following example: input | microsoft.ad.split_dn(key1=value1, key2=value2, ...)

Parameter

Comments

section

string

The DN section to return.

Defaults to leaf which will return the first RDN component.

Set to parent to return the remaining RDN components.

Do not specify section as a keyword, this value is passed as a positional argument.

Choices:

  • "leaf" ← (default)

  • "parent"

See Also

See also

microsoft.ad.dn_escape

microsoft.ad.dn_escape filter

microsoft.ad.parse_dn

microsoft.ad.parse_dn filter

Examples

- name: Gets the leaf RDN of a DN
  set_fact:
    my_dn: '{{ "CN=Foo,DC=domain,DC=com" | microsoft.ad.split_dn }}'

# CN=Foo

- name: Gets the parent RDNs of a DN
  set_fact:
    my_dn: >-
      {{
        "CN=Acme\, Inc.,O=OrgName,C=AU+ST=Queensland" |
          microsoft.ad.split_dn("parent")
      }}

# O=OrgName,C=AU+ST=Queensland,

Return Value

Key

Description

Return value

string

The split RDN components based on the section requested.

Returned: success

Sample: "CN=Foo"

Authors

  • Jordan Borean (@jborean93)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.