Querying Windows Active Directory server using ldapsearch from command line

不想你离开。 提交于 2019-12-02 14:16:59
Richard Neish

The short answer is "yes". A sample ldapsearch command to query an Active Directory server is:

ldapsearch \
    -x -h ldapserver.mydomain.com \
    -D "mywindowsuser@mydomain.com" \
    -W \
    -b "cn=users,dc=mydomain,dc=com" \
    -s sub "(cn=*)" cn mail sn

This would connect to an AD server at hostname ldapserver.mydomain.com as user mywindowsuser@domain.com, prompt for the password on the command line and show name and email details for users in the cn=users,dc=mydomain,dc=com subtree.

See Managing LDAP from the Command Line on Linux for more samples. See LDAP Query Basics for Microsoft Exchange documentation for samples using LDAP queries with Active Directory.

Anand

You could query an LDAP server from the command line with ldap-utils: ldapsearch, ldapadd, ldapmodify

Yes we can query active directory using ldap utilities. Also we can query AD using java api's jndi as well.

Yes you can query any ldap server using ldapsearch provided you have ldap-utils package installed on your system and user which you are using to connect to ldap server already has necessary permissions.

To install ldap-utils on Debian destro

sudo apt install ldap-utils

Refer below links:

Examples of Common ldapsearches

How To Manage and Use LDAP Servers with OpenLDAP Utilities

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