Skip to main content

Parse LDIF data into YAML or JSON

Project description

ldifparse

Parse LDIF data into common text formats. It currently supports conversion to JSON and to YAML.

This is a thin wrapper around the python-ldap package.

From:

$ ldapsearch -Q -L -Y EXTERNAL -H ldapi:/// -b dc=company,dc=com
version: 1

#
# LDAPv3
# base <dc=company,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# company.com
dn: dc=company,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: company
dc: company

# admin, company.com
dn: cn=admin,dc=company,dc=com
objectClass: simpleSecurityObject
objectClass: organizationalRole
cn: admin
description: LDAP administrator

# search result

# numResponses: 3
# numEntries: 2

To :

$ ldapsearch -Q -L -Y EXTERNAL -H ldapi:/// -b dc=company,dc=com | ldifparse
cn=admin,dc=company,dc=com:
  cn: admin
  description: LDAP administrator
  objectClass:
  - simpleSecurityObject
  - organizationalRole
dc=company,dc=com:
  dc: company
  o: company
  objectClass:
  - top
  - dcObject
  - organization

Installation

with pip/pipx

The recommended way of installing ldifparse is through the pipx installer :

pipx install ldifparse

ldifparse will be installed in an isolated environment but will be available globally as a shell application.

Alternatively, you can install ldifparse in an environment of your choosing with pip :

pip install ldifparse

manually

You can also download the source code from github :

git clone https://github.com/MatteoBouvier/ldifparse.git

Tips

We recommend also installing jq for viewing and manipulating JSON in the terminal. The YAML equivalent is yq.

Usage

The simplest way to use ldifparse is by piping it some LDIF data :

cat input.ldif | ldifparse

This will print a YAML version of the data to stdout.

Output format

You can specify the ouput format with the --output parameter (-o for the short version). The output can either be json or yaml (-oj and -oy are also accepted as shorthands).

Tree structure

Instead of a perfect translation of LDIF to JSON/YAML, you can get a tree representation with the --tree (-t) parameter.

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

ldifparse-1.0.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

ldifparse-1.0.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file ldifparse-1.0.1.tar.gz.

File metadata

  • Download URL: ldifparse-1.0.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/5.15.0-91-generic

File hashes

Hashes for ldifparse-1.0.1.tar.gz
Algorithm Hash digest
SHA256 408488315911fc2f885cff91f53394523daefd3d41a6f90e9385416171cb0f1d
MD5 6880775dfb830c83e5fe23bc54425921
BLAKE2b-256 73439fc27bf7d7f482cfa53458db2966ad40a77118fa25820149071150fc164e

See more details on using hashes here.

File details

Details for the file ldifparse-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ldifparse-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/5.15.0-91-generic

File hashes

Hashes for ldifparse-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8cffba18bef8aad2a55b0089d8c5a2cb592984faf3e2ee0a37f07b9b0c1ca61
MD5 0c3c530d235b57faf0246ddae2fefb4d
BLAKE2b-256 a865333977ecb438ed94d2e7e3b44b6a11bb88f31613daa4738734736a1c60a6

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