How to authenticate ldap server to query?

I am using ldapsearch command and getting below error while querying:

$ ldapsearch -x "(objectclass=*)"
# extended LDIF
#
# LDAPv3
# base <dc=goexample,dc=me> (default) with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# search result
search: 2
result: 1 Operations error
text: 00002020: Operation unavailable without authentication

# numResponses: 1

Open in new window


content of /etc/openldap/ldap.conf
#
# LDAP Defaults
#

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

#BASE   dc=example,dc=com
#URI    ldap://ldap.example.com ldap://ldap-master.example.com:666

#SIZELIMIT      12
#TIMELIMIT      15
#DEREF          never

BASE    dc=goexample,dc=me
URI     ldap://10.0.1.203
TLS_CACERTDIR /etc/openldap/cacerts

Open in new window


I think I am getting authentication error.. I can I supply a userid and password with ldapsearch command?
beer9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan McFaddenSystems EngineerCommented:
You can use the -D and the -w/-W options.

1. "-D" indicates the username being used for the search
2. "-W" will make ldapsearch prompt you for the password associated with the "-D" option
3. "-w" is the password for the "-D" option.  Meaning you type your password in the command line command.

Reference link:  https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.2/html/Administration_Guide/Finding_Directory_Entries-Using_ldapsearch.html#Using_ldapsearch-Commonly_Used_ldapsearch_Options

Example link:  https://www.27partners.com/2012/08/query-active-directory-with-ldapsearch/

Dan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.