Skip to main content

Get a CSV formatted list from an LDAP database based on given attributes.

Project description

LDAP Attributes Selector

This command line program, allows you to query an LDAP server, based on a custom set of provided attributes. The results are given in CSV format, though they are not written to a CSV file unless explicitly specified.

Requirements

Make sure you meet the following requirements:

Also, note that when establishing an SSL connection, depending on the security settings in your LDAP server, you might gonna need to perform some additional configuration on your LDAP client!.

As a general rule, if you are able to make an LDAP query with the ldapsearch tool, this script should work as well!.

Installation

You can install it with pip:

pip install ldap-attributes-selector

Usage

Help output:

usage: ldap-attributes-selector [-h] [-u USERDN] [-S SIZELIMIT] [-f FILTER]
                                   [-w WRITETOCSV] [-v]
                                   SERVER BASEDN USER_ATTRS

Get a CSV formatted list from an LDAP database, given a custom set of provided
attributes.

positional arguments:
  SERVER                URI formatted address (IP or domain name) of the LDAP
                        server
  BASEDN                Specify the searchbase or base DN of the LDAP server
  USER_ATTRS            A set of comma separated LDAP attributes to list

optional arguments:
  -h, --help            show this help message and exit
  -u USERDN, --userdn USERDN
                        Distinguished Name (DN) of the user to bind to the
                        LDAP directory
  -S SIZELIMIT, --sizelimit SIZELIMIT
                        Specify the maximum number of LDAP entries to display
                        (Default: 500)
  -f FILTER, --filter FILTER
                        Specify an LDAP filter (Default: 'objectClass=*')
  -w WRITETOCSV, --writetocsv WRITETOCSV
                        Write results to a CSV file!.
  -v, --version         Show current version

Note that whenever an entry doesn't have any of the provided LDAP attributes, nothing will be printed!.

Examples

In the following example, an encrypted LDAP query (note the ldaps:// when specifying the LDAP server) is made, and the attributes name, mail and ipPhone are retrieved. In addition, the search base used is objectClass=person and a maximum of 50 entries will be printed!:

ldap-attributes-selector ldaps://somecorp.com "dc=somecorp,dc=com" -u "cn=Joe,ou=Users,dc=somecorp,dc=com" "name,mail,ipPhone" -S 50 -f objectClass=person

Unlike the previous example, on the next one, the query won't be encrypted; a different LDAP filter is used and no limits on the number of results to display are given, other than the defults (500 entries):

ldap-attributes-selector ldap://somecorp.com "dc=somecorp,dc=com" -u "uid=zimbra,cn=admins,cn=zimbra" "givenName,mail,zimbraAccountStatus" -f 'objectClass=inetOrgPerson'

This other example is similar to the first one, except that, this time, the retrieved results, are gonna be exported to a CSV file!:

ldap-attributes-selector ldaps://somecorp.com "dc=somecorp,dc=com" -u "cn=joe,ou=Users,dc=somecorp,dc=com" "name,mail,ipPhone" -S 50 -f objectClass=person -w users.csv

If no user identity (in DN format!) is specified (-u argument), an anonymous LDAP query is performed, as in the following example:

ldap-attributes-selector ldap://somecorp.com "dc=somecorp,dc=com" "sn,givenName,mail"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ldap-attributes-selector-0.2.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

ldap_attributes_selector-0.2.1-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file ldap-attributes-selector-0.2.1.tar.gz.

File metadata

  • Download URL: ldap-attributes-selector-0.2.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.5.3

File hashes

Hashes for ldap-attributes-selector-0.2.1.tar.gz
Algorithm Hash digest
SHA256 9c6de28dace11ebc81b09801bbd4fb4cac74cd6c90fb402b3cc01cc6ed39a602
MD5 614f6b507eb6aee39ae7c70e052cdddb
BLAKE2b-256 61a777544c87a9c0855c50a2c8d01abc1a541a015fbc716e21b00ca2bf493b7f

See more details on using hashes here.

File details

Details for the file ldap_attributes_selector-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: ldap_attributes_selector-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.5.3

File hashes

Hashes for ldap_attributes_selector-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8713f1c8d707553545463a3f56be977cffed052d009358385a30d297c88186a2
MD5 e078d2b7e4040d88dbe2d51afa0f9b12
BLAKE2b-256 0ade529d8f80322823e672e4585219682945d12d5549d85ef2e0d27d7c2d478b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page