Skip to main content

I parse and create RFC2253 compliant distringuished 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.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file distinguishedname-1.0.0.tar.gz.

File metadata

  • Download URL: distinguishedname-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 517b6d27402c867695692ef866aec722d74b2b553ab869e331b6bf02754230f1
MD5 0b2a61edf6555ac561dcb983628904a5
BLAKE2b-256 1d9db8773808de51228691dda86cbf112b72aaf8e5cc88d54bb3eb2eeb6c8c57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for distinguishedname-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fba77121deede7ce939d476099b82fdca006e470eb995936f2e77bd5f1fb667
MD5 3c2e0c39f97e0b43a0ab309d0fa06136
BLAKE2b-256 e5ea0759d85ea72a032d785a284aa53585733085df7f4bdd813fbf6f5158ce00

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