# 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](https://www.python-ldap.org/en/python-ldap-3.4.3/) package.
From:
```sh
$ 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 :
```sh
$ 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 :
```sh
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 :
```sh
pip install ldifparse
```
### manually
You can also download the source code from github :
```sh
git clone https://github.com/MatteoBouvier/ldifparse.git
```
## Tips
We recommend also installing [jq](https://jqlang.github.io/jq/) for viewing and manipulating JSON in the terminal.
The YAML equivalent is [yq](https://github.com/mikefarah/yq).
## Usage
The simplest way to use **ldifparse** is by piping it some LDIF data :
```sh
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/MatteoBouvier/ldifparse",
"name": "ldifparse",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Matteo Bouvier",
"author_email": "m.bouvier@vidium-solutions.com",
"download_url": "https://files.pythonhosted.org/packages/73/43/9fc27bf7d7f482cfa53458db2966ad40a77118fa25820149071150fc164e/ldifparse-1.0.1.tar.gz",
"platform": null,
"description": "# ldifparse\nParse LDIF data into common text formats. It currently supports conversion to JSON and to YAML.\n\nThis is a thin wrapper around the [python-ldap](https://www.python-ldap.org/en/python-ldap-3.4.3/) package.\n\nFrom:\n```sh\n$ ldapsearch -Q -L -Y EXTERNAL -H ldapi:/// -b dc=company,dc=com\nversion: 1\n\n#\n# LDAPv3\n# base <dc=company,dc=com> with scope subtree\n# filter: (objectclass=*)\n# requesting: ALL\n#\n\n# company.com\ndn: dc=company,dc=com\nobjectClass: top\nobjectClass: dcObject\nobjectClass: organization\no: company\ndc: company\n\n# admin, company.com\ndn: cn=admin,dc=company,dc=com\nobjectClass: simpleSecurityObject\nobjectClass: organizationalRole\ncn: admin\ndescription: LDAP administrator\n\n# search result\n\n# numResponses: 3\n# numEntries: 2\n```\n\nTo :\n```sh\n$ ldapsearch -Q -L -Y EXTERNAL -H ldapi:/// -b dc=company,dc=com | ldifparse\ncn=admin,dc=company,dc=com:\n cn: admin\n description: LDAP administrator\n objectClass:\n - simpleSecurityObject\n - organizationalRole\ndc=company,dc=com:\n dc: company\n o: company\n objectClass:\n - top\n - dcObject\n - organization\n```\n\n## Installation\n\n### with pip/pipx\n\nThe recommended way of installing **ldifparse** is through the pipx installer : \n\n```sh\npipx install ldifparse\n```\n\n**ldifparse** will be installed in an isolated environment but will be available globally as a shell application.\n\nAlternatively, you can install **ldifparse** in an environment of your choosing with pip :\n\n```sh\npip install ldifparse\n```\n\n### manually\n\nYou can also download the source code from github :\n\n```sh\ngit clone https://github.com/MatteoBouvier/ldifparse.git\n```\n\n## Tips\n\nWe recommend also installing [jq](https://jqlang.github.io/jq/) for viewing and manipulating JSON in the terminal.\nThe YAML equivalent is [yq](https://github.com/mikefarah/yq).\n\n## Usage\n\nThe simplest way to use **ldifparse** is by piping it some LDIF data : \n\n```sh\ncat input.ldif | ldifparse\n```\n\nThis will print a YAML version of the data to stdout.\n\n### Output format\n\nYou can specify the ouput format with the `--output` parameter (`-o` for the short version). The output can either be\n`json` or `yaml` (`-oj` and `-oy` are also accepted as shorthands).\n\n### Tree structure\n\nInstead of a perfect translation of LDIF to JSON/YAML, you can get a tree representation with the `--tree` (`-t`) \nparameter.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Parse LDIF data into YAML or JSON",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/MatteoBouvier/ldifparse",
"Repository": "https://github.com/MatteoBouvier/ldifparse"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a865333977ecb438ed94d2e7e3b44b6a11bb88f31613daa4738734736a1c60a6",
"md5": "0c3c530d235b57faf0246ddae2fefb4d",
"sha256": "e8cffba18bef8aad2a55b0089d8c5a2cb592984faf3e2ee0a37f07b9b0c1ca61"
},
"downloads": -1,
"filename": "ldifparse-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0c3c530d235b57faf0246ddae2fefb4d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 4616,
"upload_time": "2024-02-23T19:18:54",
"upload_time_iso_8601": "2024-02-23T19:18:54.501772Z",
"url": "https://files.pythonhosted.org/packages/a8/65/333977ecb438ed94d2e7e3b44b6a11bb88f31613daa4738734736a1c60a6/ldifparse-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "73439fc27bf7d7f482cfa53458db2966ad40a77118fa25820149071150fc164e",
"md5": "6880775dfb830c83e5fe23bc54425921",
"sha256": "408488315911fc2f885cff91f53394523daefd3d41a6f90e9385416171cb0f1d"
},
"downloads": -1,
"filename": "ldifparse-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "6880775dfb830c83e5fe23bc54425921",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 3696,
"upload_time": "2024-02-23T19:18:55",
"upload_time_iso_8601": "2024-02-23T19:18:55.631570Z",
"url": "https://files.pythonhosted.org/packages/73/43/9fc27bf7d7f482cfa53458db2966ad40a77118fa25820149071150fc164e/ldifparse-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-23 19:18:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MatteoBouvier",
"github_project": "ldifparse",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ldifparse"
}