Table: ldap_group - Query LDAP Groups using SQL
Lightweight Directory Access Protocol (LDAP) is a protocol used to access directory listings within Active Directory (AD), OpenLDAP, and other directory systems. It allows users to access and manage a variety of information, including user profiles, groups, and network information. The LDAP service in provides a way to connect to and manage your LDAP directories.
Table Usage Guide
The ldap_group
table provides insights into LDAP groups within LDAP service. As a Systems Administrator, explore group-specific details through this table, including distinguished names (DN), common names (CN), and member details. Utilize it to uncover information about groups, such as those with specific members, the hierarchical relationships between groups, and the verification of group configurations.
Important Notes
- This table supports optional quals. Queries with optional quals in a
where
clause are optimised to use LDAP search filters. - If
filter
is provided, other optional quals will not be used when searching. - Optional quals are supported for the following columns:
cn
description
filter
- Allows use of an explicit filter. Please refer to LDAP filter language.object_sid
sam_account_name
when_changed
when_created
Examples
Basic info
Explore which groups exist within your LDAP directory by identifying their distinguished names, common names, and organizational units. This can be particularly useful for auditing purposes, helping to ensure that all groups are accounted for and appropriately organized.
select dn, cn, ou, when_created, sam_account_namefrom ldap_group;
select dn, cn, ou, when_created, sam_account_namefrom ldap_group;
List all members for each group
Explore which members belong to each group in your LDAP directory. This helps in managing access controls and user permissions effectively.
select jsonb_pretty(attributes -> 'member') as membersfrom ldap_group;
select attributes as membersfrom ldap_group;
List groups that have been created in the last 30 days
Discover the groups that have been established in the recent 30 days. This query is useful for monitoring the creation of new groups and maintaining an up-to-date overview of your system's group structure.
select dn, sam_account_name, when_createdfrom ldap_groupwhere when_created > current_timestamp - interval '30 days';
select dn, sam_account_name, when_createdfrom ldap_groupwhere when_created > datetime('now', '-30 days');
Get details for groups the group 'Database' is a member of
Explore the hierarchical relationships within your group structures, specifically identifying the parent groups to which your 'Database' group belongs. This is useful for managing access controls and understanding how permissions are inherited within your organization.
select g.dn as group_nd, g.ou as group_ou, g.object_sid as group_object_sid, mg.dn as parent_group_dn, mg.cn as parent_group_name, mg.object_sid as parent_group_object_sidfrom ldap.ldap_group as g cross join jsonb_array_elements_text(g.member_of) as groups inner join ldap.ldap_group as mg on mg.dn = groupswhere g.cn = 'Database';
select g.dn as group_nd, g.ou as group_ou, g.object_sid as group_object_sid, mg.dn as parent_group_dn, mg.cn as parent_group_name, mg.object_sid as parent_group_object_sidfrom ldap.ldap_group as g, json_each(g.member_of) as groups inner join ldap.ldap_group as mg on mg.dn = groups.valuewhere g.cn = 'Database';
Filter Examples
List groups that "Bob Smith" is a member of
Discover the groups that a specific user, such as Bob Smith, belongs to, providing insights into the user's roles and permissions within the organization. This can be useful for auditing user access and ensuring appropriate security measures.
select dn, ou, description, when_createdfrom ldap_groupwhere filter = '(member=CN=Bob Smith,OU=Devs,OU=SP,DC=sp,DC=turbot,DC=com)';
select dn, ou, description, when_createdfrom ldap_groupwhere filter = '(member=CN=Bob Smith,OU=Devs,OU=SP,DC=sp,DC=turbot,DC=com)';
Schema for ldap_group
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
attributes | jsonb | All attributes that have been returned from LDAP. | |
base_dn | text | The Base DN on which the search was performed. | |
cn | text | = | Common/Full name of the group. |
description | text | = | Description of the group. |
dn | text | = | Distinguished name of the group. |
filter | text | = | Optional search filter. |
host_name | text | =, !=, ~~, ~~*, !~~, !~~* | The name of the host. |
member_of | jsonb | Groups that the group is a member of. | |
object_class | jsonb | Object classes of the group. | |
object_sid | text | = | The security identifier (SID) of the group. |
ou | text | Organizational unit to which the group belongs to. | |
sam_account_name | text | = | SAM Account name of the group. |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
title | text | Title of the group. | |
when_changed | timestamp with time zone | >, >=, =, <, <= | Date when the group was last changed. |
when_created | timestamp with time zone | >, >=, =, <, <= | Date when the group was created. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- ldap
You can pass the configuration to the command with the --config
argument:
steampipe_export_ldap --config '<your_config>' ldap_group