将Base64 LDIF文件转换为纯文本(用于导入) [英] Convert a Base64 LDIF file to plaintext (for import)

查看:286
本文介绍了将Base64 LDIF文件转换为纯文本(用于导入)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个LDIF文件,该文件具有多值Base64编码的属性,我想将其转换为非Base64编码的语法.该怎么办?

I have a LDIF file which has a multi-value Base64-encoded attribute, and I'd like to convert it in non-Base64-encoded syntax. How can this be done?

上下文

LDIF文件是这样的:

The LDIF file is as such:

dn: cn=johndoe,ou=clients,ou=management,dc=example,dc=com
changetype: modify
replace: foobarStatus
foobarStatus:: ZW5hYmxl... (Base64 string) ...ZCA9IHRydWU

解码后的Base64字符串是这样的:

where the decoded Base64 string is as such:

market = "US"
mgmt.account.mode = "X12"
foo.field = "Something"
bar.field = "Something else" 
...

问题

当我尝试通过ldapmodify将此LDIF文件导入LDAP服务器时,出现错误:

When I try to import this LDIF file into a LDAP server via ldapmodify, I get an error:

ldapmodify: invalid format (line 4) entry: "cn=johndoe,ou=clients,ou=management,dc=example,dc=com"

我已经尝试解决了一段时间,但找不到错误.在某处可能是一些虚假的人物.因此,我想到了转换LDIF的Base64部分并以这种格式导入它.属性值不包含任何不可打印的ASCII(例如重音字母),因此应该可以正常工作.

I've been trying to solve this for a while but couldn't find the error. It could be some spurious character somewhere. Therefore I thought of converting the Base64 part of the LDIF and importing it on this format. The attribute values don't contain any non-printable ASCII (e.g. accented letters) so it should work fine.

注意

这可能是 XY问题,所以如果有人有其他建议,我很想读.

This could be a XY problem so if anyone has another suggestion, I'm eager to read it.

推荐答案

事实证明ldapmodify不喜欢长行.因此,在此处分割Base64代码后

It turns out ldapmodify doesn't like long lines. Therefore, after splitting the Base64 code here

foobarStatus:: ZW5hYmxl... (Base64 string) ...ZCA9IHRydWU

导入多行不超过79个字符的字符,ldapmodify能够将其导入.

into multiple lines of 79 chars or less, ldapmodify was able to import it.

这解决了我原来的问题.我将解决方案留给以后的读者.

This solved my original problem. I'm leaving the solution here for future readers.

这篇关于将Base64 LDIF文件转换为纯文本(用于导入)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆