bash 如何停止 ldapsearch(1) 从 base64 编码 userPassword 和其他属性?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38710483/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to stop ldapsearch(1) from base64 encoding userPassword and other attributes?
提问by Steve Shipway
The ldapsearch(1)
command retrieves objects from an LDAP server, and prints them out as an LDIF structure, like this (not real data):
dn: [email protected],dc=domain,dc=com
objectclass: top
objectclass: person
mail: [email protected]
userPassword:: hdfy74dhn79wdhyr74hy7489fhw46789f
If an attribute contains non-ASCII data, it is Base64-encoded, indicated by a double ::
after the attribute name. In addition, it appears that any attribute called userPassword
will alwaysbe so encoded, even if it is ASCII-clean.
该ldapsearch(1)
命令从 LDAP 服务器检索对象,并将它们作为 LDIF 结构打印出来,如下所示(不是真实数据):
dn: [email protected],dc=domain,dc=com
objectclass: top
objectclass: person
mail: [email protected]
userPassword:: hdfy74dhn79wdhyr74hy7489fhw46789f
如果属性包含非 ASCII 数据,则它是 Base64 编码的,由::
属性名称后的双精度数表示。此外,似乎叫任何属性userPassword
将始终被这样编码,即使是ASCII清洁。
What I want to do is to tell ldapsearch
not to do this. I have not been able to find an option flag to pass to suppress this behaviour; only recompiling the source with LDAP_PASSWD_DEBUG
disabled.
我想做的是告诉ldapsearch
不要这样做。我无法找到要传递的选项标志来抑制这种行为;仅重新编译LDAP_PASSWD_DEBUG
禁用的源。
Is there an undocumented option to prevent this encoding?
是否有未记录的选项来防止这种编码?
(Leaving aside security concerns etc. as this is for testing purposes)
(抛开安全问题等,因为这是出于测试目的)
采纳答案by Steve Shipway
Short of recompiling ldapsearch, there seems to be no way to do this with a simple flag.
除了重新编译 ldapsearch,似乎没有办法用一个简单的标志来做到这一点。
However you can create a shell alias like this, which will have the same effect - provided you have the Perl MIME::Base64 module installed.
但是,您可以像这样创建一个 shell 别名,这将具有相同的效果 - 前提是您安装了 Perl MIME::Base64 模块。
myldapsearch()
{
ldapsearch $* | perl -MMIME::Base64 -n -00 -e 's/\n +//g;s/(?<=:: )(\S+)/decode_base64($1)/eg;print'
}
alias ldapsearch=myldapsearch
myldapsearch()
{
ldapsearch $* | perl -MMIME::Base64 -n -00 -e 's/\n +//g;s/(?<=:: )(\S+)/decode_base64($1)/eg;print'
}
alias ldapsearch=myldapsearch