《节选自 Netkiller LDAP 手札》编程
经过ldapsearch查询Windows Active Directory 是一件颇有趣事情。服务器
列出全部员工姓名测试
ldapsearch -x -H ldap://192.168.19.238 -D neo.chen@company.com -w 12345678 -b 'OU=china,DC=company,DC=com' '(&(objectCategory=person)(objectClass=user)(company=*)(mail=*))'|grep '^name::' | awk -F ' ' '{print $2}' |base64 --decode | sed 's/)/)\r\n/g'
统计员工数目spa
ldapsearch -x -H ldap://192.168.19.238 -D neo.chen@company.com -w 12345678 -b 'OU=china,DC=company,DC=com' '(&(objectCategory=person)(objectClass=user)(company=*)(mail=*))'|grep '^name::' | wc -l
制做通信录,或导出邮件列表设计
ldapsearch -x -H ldap://192.168.19.238 -D neo.chen@company.com -w 12345678 -b 'OU=china,DC=company,DC=com' '(&(objectCategory=person)(objectClass=user)(company=*)(mail=*))'|grep ^mail:|awk -F ' ' '{print $2}'
列出 name mail mobile telephoneNumbercode
ldapsearch -x -H ldap://192.168.19.238 -D neo.chen@company.com -w 12345678 -b 'OU=china,DC=company,DC=com' '(&(objectCategory=person)(objectClass=user)(name=*)(mail=*))' name mail mobile telephoneNumber
延伸阅读进程
MySQL 转换 latin1 到 UTF-8base64
金融交易系统设计思路awk
长按下面二维码,关注个人公众号,天天推推送原创技术文章。