Remove dn
and "modifying values" from output
This commit is contained in:
parent
494b916b86
commit
f7efc1cd17
1 changed files with 10 additions and 1 deletions
|
@ -25,8 +25,17 @@ template = (
|
||||||
"}})"
|
"}})"
|
||||||
)
|
)
|
||||||
for ldif in ldifs:
|
for ldif in ldifs:
|
||||||
|
# Delete all modifying values (non-permitted by ldapadd)
|
||||||
|
del ldif['modifyTimestamp']
|
||||||
|
del ldif['structuralObjectClass']
|
||||||
|
del ldif['entryCSN']
|
||||||
|
del ldif['modifiersName']
|
||||||
|
del ldif['creatorsName']
|
||||||
|
del ldif['createTimestamp']
|
||||||
|
del ldif['entryUUID']
|
||||||
# Cast all values to str instead of bytes
|
# Cast all values to str instead of bytes
|
||||||
|
dn = ldif.pop('dn', [b'CHANGE_ME'])[0].decode()
|
||||||
data = '\n'.join("'{}': {},".format(k,[vv.decode() for vv in v]) for k, v in ldif.items())
|
data = '\n'.join("'{}': {},".format(k,[vv.decode() for vv in v]) for k, v in ldif.items())
|
||||||
name = ldif.get('cn', ldif.get('ou', [b'CHANGE_ME']))[0].decode()
|
name = ldif.get('cn', ldif.get('ou', [b'CHANGE_ME']))[0].decode()
|
||||||
print(template.format(name=name, dn=ldif['dn'][0].decode(), data=data))
|
print(template.format(name=name, dn=dn, data=data))
|
||||||
print()
|
print()
|
Loading…
Add table
Add a link
Reference in a new issue