LDAPSEARCH into table format

余生长醉 提交于 2019-12-11 14:33:48

问题


Is there any way to perform a LDAP search and save the results into a table format (e.g. csv)?

Cheers Jorge


回答1:


Just in case someone else has to do this:

Based on the answer provided in Filter ldapsearch with awk/bash

this will output the LDAP info into a csv format:

$ ldapsearch -x -D "cn=something" | awk -v OFS=',' '{split($0,a,": ")} /^mail:/{mail=a[2]} /^uidNumber:/{uidNumber=a[2]} /^uid:/{uid=a[2]} /^cn/{cn=a[2]; print uid, uidNumber,cn , mail}' > ldap_dump.csv

NOTE You need to be careful about the order in which you parse the LDAP data with awk! It needs to be parsed in the same order as it appears on the LDAP data!



来源:https://stackoverflow.com/questions/48644911/ldapsearch-into-table-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!