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.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

distinguishedname-1.0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: distinguishedname-1.0.2.tar.gz
  • Upload date:
  • Size: 3.2 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.2.tar.gz
Algorithm Hash digest
SHA256 63ec0204ad7067f937ae70b7617ef0aa9cb42ac6c3decefd178e02ada6d1dec3
MD5 474de2f2f74cff82dab7d654e33acef5
BLAKE2b-256 57d8b8dc8266cd3a08a153c0ee5cfc8e475de0d4e63cac5ed409fce1807ac555

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for distinguishedname-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 494010874e95d803b391c93222a949ff80ba66009648ff1d2c5f85a9c0de27f8
MD5 027437343956c764cc7a6149750f95da
BLAKE2b-256 5451c4c0865c4152b8ba1f4e40b631786f06bb9a9c610454884e3dae5194fd6e

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