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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 14:57:29  来源:igfitidea点击:

How to stop ldapsearch(1) from base64 encoding userPassword and other attributes?

bashldap

提问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 userPasswordwill 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 ldapsearchnot 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_DEBUGdisabled.

我想做的是告诉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