I parse and create RFC2253 compliant distinguished names (DNs)
Project description
distinguishedname
Parse RFC 2253 Distinguished Names from strings and create strings from DNs (which are implemented here as lists of RDNs - which are lists of strings in "TAG=VALUE" format).
Examples
>>> string_to_dn(r'CN= James \"Bond\" +UID= 007, OU = 00 Division\, Special Services, O=MI5,C=UK')
[['CN=James "Bond"', 'UID=007'], ['OU=00 Division, Special Services'], ['O=MI5'], ['C=UK']]
>>> dn_to_string([['CN="Pinkie" Stevens', 'UID=1'], ['O= Name With Spaces ']])
'CN=\\"Pinkie\\" Stevens+UID=1,O=\\20Name With Spaces\\20'
Rationale
I couldn't find any existing libraries for this. In theory, python-ldap has a DN class that
should be able to do this, but I've never been able to pip install
it successfully.
This is essentially a single file, so you could also just drop this file into your project, ansible module, CLI script or whatever.
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
Built Distribution
File details
Details for the file distinguishedname-1.0.1.tar.gz
.
File metadata
- Download URL: distinguishedname-1.0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83ca75c6da39345191fe0ccbedeba2e3022ae07b6d5f12a0259a577246112597 |
|
MD5 | b55fbae72d4a4c3ff62c60ab40f14b47 |
|
BLAKE2b-256 | 73a3f9e888527e1951a9e829ec08399036f79176540e65ff15fc6e97ecf4a13a |
File details
Details for the file distinguishedname-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: distinguishedname-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22e97a58cb38904924d69a5e0b50268d327fa82d69446b4ea31365e134faa255 |
|
MD5 | 5932d24260f68c6f121a1b97adce51a4 |
|
BLAKE2b-256 | ad296909cb43d2848ceb19de7e1f0cf8dbf485d5971c4094cc3ebb8c4df6cad3 |