microsoft.ad.object_info 模块 – 收集 Active Directory 对象信息
注意
此模块是 microsoft.ad 集合 (版本 1.7.1) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install microsoft.ad。您需要其他要求才能使用此模块,有关详细信息,请参见 要求。
要在 playbook 中使用它,请指定:microsoft.ad.object_info。
概要
- 收集有关多个 Active Directory 对象的信息。 
要求
执行此模块的主机需要以下要求。
- ActiveDirectoryPowerShell 模块
参数
| 参数 | 注释 | 
|---|---|
| domain_username 的密码。 这可以在 play 的模块默认值 下的  | |
| 指定要连接到的 Active Directory 域服务实例。 可以是 FQDN 或 NetBIOS 名称的形式。 如果未指定,则该值基于运行 PowerShell 的计算机的默认域。 这可以在 play 的模块默认值 下的  | |
| 与 AD 交互时使用的用户名。 如果未设置此项,则用于身份验证的用户将是连接用户。 除非身份验证是具有凭据委派或 CredSSP 的 Kerberos,或者在任务上使用了 become,否则 Ansible 将无法使用连接用户。 这可以在 play 的模块默认值 下的  | |
| 使用 PowerShell 表达式语言语法指定查询字符串。 这遵循与 PowerShell AD cmdlet 的  这与 identity 和 ldap_filter 互斥。 | |
| 通过其可分辨名称或对象 GUID 指定单个 Active Directory 对象。 这与 filter 和 ldap_filter 互斥。 这不能与 search_base 或 search_scope 选项一起使用。 | |
| 还搜索已删除的 Active Directory 对象。 选项 
 | |
| 类似于 filter,但这是一个传统的 LDAP 查询字符串,用于过滤要返回的对象。 这与 filter 和 identity 互斥。 | |
| 要返回的属性列表。 如果属性是  如果属性在对象上有效但未设置,则仅当在此选项列表中显式定义时才返回它。 属性  指定多个属性可能会影响性能,最好只返回所需内容。 如果指定了无效属性,则模块将为每个无效的对象显示警告。 | |
| 指定要在其中搜索对象的 Active Directory 路径。 这不能与 identity 一起设置。 默认情况下,搜索基准是目标 AD 实例的默认命名上下文,即  | |
| 指定在 search_base 中搜索对象时的范围。 
 
 
 这不能与 identity 一起设置。 选项 
 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完全支持 | 可以在 check_mode 下运行并返回更改状态预测而无需修改目标,如果不受支持,则将跳过操作。 | |
| 支持:不支持 | 在差异模式下,将返回有关已更改内容(或在 check_mode 中可能需要更改的内容)的详细信息 | |
| 平台: windows | 可以对其进行操作的目标操作系统/系列 | 
备注
注意
- 属性 - groupType_AnsibleFlags、- msDS-SupportedEncryptionTypes_AnsibleFlags、- sAMAccountType_AnsibleFlags和- userAccountControl_AnsibleFlags的返回值是由模块本身设置的,方便查看这些标志的含义。这些属性不能用作filter 或 ldap_filter 的一部分,如果请求了这些属性,则会自动添加。
- 此模块必须在安装了 - ActiveDirectory模块的 Windows 目标主机上运行。
另请参阅
另请参阅
- microsoft.ad.domain
- 确保 Windows 域的存在。 
- microsoft.ad.domain_controller
- 管理 Windows 主机的域控制器/成员服务器状态。 
- microsoft.ad.group
- 管理 Active Directory 组对象。 
- microsoft.ad.object
- 管理 Active Directory 对象。 
- microsoft.ad.user
- 管理 Active Directory 用户。 
- microsoft.ad.computer
- 管理 Active Directory 计算机对象。 
- 迁移指南
- 此模块替换了 - community.windows.win_domain_object_info。有关详细信息,请参阅迁移指南。
- community.windows.win_domain_object_info
- 收集 Active Directory 对象的信息。 
示例
- name: Get all properties for the specified account using its DistinguishedName
  microsoft.ad.object_info:
    identity: CN=Username,CN=Users,DC=domain,DC=com
    properties: '*'
- name: Get the SID for all user accounts as a filter
  microsoft.ad.object_info:
    filter: ObjectClass -eq 'user' -and objectCategory -eq 'Person'
    properties:
      - objectSid
- name: Get the SID for all user accounts as a LDAP filter
  microsoft.ad.object_info:
    ldap_filter: (&(objectClass=user)(objectCategory=Person))
    properties:
      - objectSid
- name: Search all computer accounts in a specific path that were added after February 1st
  microsoft.ad.object_info:
    filter: objectClass -eq 'computer' -and whenCreated -gt '20200201000000.0Z'
    properties: '*'
    search_scope: one_level
    search_base: CN=Computers,DC=domain,DC=com
返回值
常见的返回值已在 此处 记录,以下是此模块独有的字段
| 键 | 描述 | 
|---|---|
| 找到的 Active Directory 对象以及请求的属性的字典列表。 字典的键是属性名称,值是属性的值。 所有日期属性都以 UTC 时区的 ISO 8601 格式返回。 所有 SID 属性都作为字典返回,键  所有字节属性都作为 base64 字符串返回。 所有安全描述符属性都作为该描述符的 SDDL 字符串返回。 属性  返回值:始终 示例:  | 
