Metadata-Version: 2.4
Name: ldif2json
Version: 1.0.8
Summary: A robust Python tool for converting LDAP Data Interchange Format (LDIF) files to JSON with support for hierarchical nesting and Base64 decoding.
Author-email: Jairsinho Ramirez Ruiz <jairsinho@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/jairsinho/ldif2json
Project-URL: Documentation, https://github.com/jairsinho/ldif2json#readme
Project-URL: BugTracker, https://github.com/jairsinho/ldif2json/issues
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Requires-Dist: pytest-cov>=4.0; extra == "test"
Dynamic: license-file

# LDIF to JSON Converter

[![PyPI version](https://badge.fury.io/py/ldif2json.svg)](https://pypi.org/project/ldif2json/)
[![Python versions](https://img.shields.io/pypi/pyversions/ldif2json.svg)](https://pypi.org/project/ldif2json/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/jairsinho/ldif2json/actions/workflows/release.yml/badge.svg)](https://github.com/jairsinho/ldif2json/actions)

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

```bash
pip install ldif2json
```

## Usage

Basic conversion:
```bash
ldif2json input.ldif -o output.json
```

With hierarchical nesting:
```bash
ldif2json input.ldif --nest -o output.json
```

With Base64 decoding:
```bash
ldif2json input.ldif --decode -o output.json
```

Using pipes:
```bash
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
