Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

distinguishedname-1.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

distinguishedname-1.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for distinguishedname-1.0.1.tar.gz
Algorithm Hash digest
SHA256 83ca75c6da39345191fe0ccbedeba2e3022ae07b6d5f12a0259a577246112597
MD5 b55fbae72d4a4c3ff62c60ab40f14b47
BLAKE2b-256 73a3f9e888527e1951a9e829ec08399036f79176540e65ff15fc6e97ecf4a13a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for distinguishedname-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22e97a58cb38904924d69a5e0b50268d327fa82d69446b4ea31365e134faa255
MD5 5932d24260f68c6f121a1b97adce51a4
BLAKE2b-256 ad296909cb43d2848ceb19de7e1f0cf8dbf485d5971c4094cc3ebb8c4df6cad3

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