Searching Windows AD by username and email with ldapsearch
Further to my post on querying AD with LDAP, to search for users by Windows username or email address one can use these commands:
# By username "username"
ldapsearch -x -W -D user@WINDOWS.DOMAIN.TLD -b dc=windows,dc=domain,dc=tld -H ldap://dc_ip_address/ samaccountname=username
# By email "email_address@domain.tld" (returning just CN and samaccountname)
ldapsearch -x -W -D user@WINDOWS.DOMAIN.TLD -b dc=windows,dc=domain,dc=tld -H ldap://dc_ip_address/ proxyaddresses=smtp:email_address@domain.tld samaccountname