我试图从CentOS 5.8计算机查询Windows LDAP服务器。这是可以做到的吗?具体来说,我尝试使用'ldapsearch'查询LDAP服务器。这是查询:
ldapsearch -V -h ldapserver.host.name -b 'YourADDN' -x -s base -z 1 -l 1 '(&(objectCategory=Person)(objectClass=user)(sAMAccountName=username))' @inetOrgPerson
根据我的结果,我甚至不确定是否可以从Linux客户端连接到Windows LDAP服务器。如果有人能证实这一点,我会非常感激。我想要做的就是从Linux机器运行LDAP查询(&(objectCategory=Person)(objectClass=user)(sAMAccountName=username))
到LDAP服务器并将结果返回到Linux服务器屏幕。
ldapsearch -b "dc=example,dc=com" -D "xxx\user1" -x -W -h x.x.x.x -p 3268 "(&(objectClass=user)(objectCategory=person)(sAMAccountName=username))"
有关更多信息,请查看http://www.sghaida.com/useful-ldap-queries-against-any-directory-service/
ldap在unix中搜索
\usr/bin/ldapsearch -h <ipaddress> -b 'DC=<domainname> , DC=com' -F'|' sAMAccountName=<name to search> extensionName personalPager url department physicalDeliveryOfficeName otherPager sAMAccountName name title mail manager mobile telephoneNumber | awk -F"|" '
{ if (NR!=1) {abc[NR]=$1"|"$2}} END { for (i in abc) {printf("%s\n",abc[i])}}' > ldap_out.txt