Ldap – How to specify a username in ldapsearch tool

command-line-interfaceldap

I'm new to ldap. I need to specify username in plaintext with some parameter without any sasl.

So this command gonna give you some search results, but it always empty cause there's no authorization:

ldapsearch -h 1.1.1.1 -p 389 -D "OU=SysAcc,OU=Infra,dc=mydomain,dc=com" -b "OU=blg,dc=whatever,dc=whatever2,dc=com"

I've found that I can add -w mypasswd to specify password, where can I specify a username? I started with ldapsearch because I'm having hard time to configure LDAP in one of web application I'm trying to setup. Just wanna check if my parameters are correct with ldapsearch tool, but I can't find how to specify username.

EDIT:

as from answer above just wanna write a final command how it should be:

   ldapsearch -h 1.1.1.1 -p 389 -W -D "CN=sysMYUSER,OU=SysAcc,OU=Infra,dc=mydomain,dc=com" -b "OU=blg,dc=whatever,dc=whatever2,dc=com"

Best Answer

The -D option is the LDAP username-equivalent. It's the BindDN, which is the account you're trying to authenticate against with the password you supply either with -w or when prompted. You probably also want to use the -x option for a simple bind, since you're using a BindDN/password pair instead of SASL authentication.