A robust Python tool for converting LDAP Data Interchange Format (LDIF) files to JSON with support for hierarchical nesting and Base64 decoding.
Project description
LDIF to JSON Converter
A robust Python tool for converting LDAP Data Interchange Format (LDIF) files to JSON with support for hierarchical nesting and Base64 decoding.
Features
- LDIF Parsing: Convert LDIF files to structured JSON
- Base64 Handling: Optional decoding of Base64-encoded attributes (
-d
flag) - Hierarchical Nesting: Organize entries by DN structure (
-n
option) - Flexible I/O: Works with files or stdin/stdout
- Custom Formatting: Control JSON indentation (
-i
option)
Installation
pip install ldif2json
Usage
Basic conversion:
ldif2json input.ldif -o output.json
With hierarchical nesting:
ldif2json input.ldif --nest -o output.json
With Base64 decoding:
ldif2json input.ldif --decode -o output.json
Using pipes:
ldapsearch -x -b "dc=example,dc=com" | ldif2json --nest children
Options
usage: ldif2json.py [-h] [-o OUTPUT] [-i INDENT] [-n [ATTRIBUTE]] [-d] [input_file]
Convert LDIF to JSON with optional Base64 decoding and nesting
positional arguments:
input_file Input LDIF file (default: stdin)
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
Output JSON file (default: stdout)
-i INDENT, --indent INDENT
JSON indentation spaces (0 for compact output) (default: 2)
-n [ATTRIBUTE], --nest [ATTRIBUTE]
Enable hierarchical nesting under specified attribute (default: None)
-d, --decode Decode Base64-encoded attributes (marked with ::) (default: False)
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ldif2json-1.0.8.tar.gz
(6.5 kB
view details)
Built Distribution
File details
Details for the file ldif2json-1.0.8.tar.gz
.
File metadata
- Download URL: ldif2json-1.0.8.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
9b3606bda3b57f3df972c94bcec7d59077c28448112c487b64f6cf3a5a5950a0
|
|
MD5 |
44248a925bd5451431059c4ce713bd8e
|
|
BLAKE2b-256 |
06b9aa9c020ab6c0f5efda51761c846eb61fefe101ef97b13b3c0a7b156a38a8
|
File details
Details for the file ldif2json-1.0.8-py3-none-any.whl
.
File metadata
- Download URL: ldif2json-1.0.8-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
e630bcc23caddee0a0cbbf8abf5b47cb66968550c4a3a769a0186f1cebe35372
|
|
MD5 |
540ebcc63af256bd9fdbc35a4af470b2
|
|
BLAKE2b-256 |
6746d387c815e620125fe8ceec5b49071d9fd93e4c623116bf1fcc74c04a3aec
|