LDAPSEARCH转换成表格格式 [英] LDAPSEARCH into table format

查看:415
本文介绍了LDAPSEARCH转换成表格格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以执行LDAP搜索并将结果保存为表格格式(例如csv)?

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

欢呼 豪尔赫

推荐答案

以防万一其他人必须这样做:

基于提供的答案 使用awk/bash过滤ldapsearch

这会将LDAP信息输出为csv格式:

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

注意 您需要注意用awk解析LDAP数据的顺序!需要按照与LDAP数据相同的顺序对其进行解析!

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!

这篇关于LDAPSEARCH转换成表格格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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