Linux command
ldapsearch 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Search for user
ldapsearch -x -H ldap://[server] -b "[dc=example,dc=com]" "(uid=[username])"
Search with authentication
ldapsearch -x -D "[cn=admin,dc=example,dc=com]" -W -b "[dc=example,dc=com]" "(objectClass=*)"
Return specific attributes
ldapsearch -x -b "[dc=example,dc=com]" "(uid=[user])" cn mail
Search with TLS
ldapsearch -x -ZZ -H ldap://[server] -b "[base]" "[filter]"
Output in LDIF format
ldapsearch -x -b "[base]" -LLL "(uid=[user])"
说明
ldapsearch queries LDAP directories. It connects to an LDAP server, performs searches based on filters, and returns matching entries. The tool is essential for directory administration, user lookup, and debugging LDAP configurations.
参数
- -x
- Simple authentication.
- -H _uri_
- LDAP server URI.
- -b _dn_
- Search base DN.
- -D _dn_
- Bind DN.
- -W
- Prompt for password.
- -w _pass_
- Bind password.
- -s _scope_
- Search scope (base, one, sub).
- -Z
- Start TLS.
- -ZZ
- Require TLS.
- -L
- LDIF output format.
- -LL
- No comments in output.
- -LLL
- No comments or version.
FAQ
What is the ldapsearch command used for?
ldapsearch queries LDAP directories. It connects to an LDAP server, performs searches based on filters, and returns matching entries. The tool is essential for directory administration, user lookup, and debugging LDAP configurations.
How do I run a basic ldapsearch example?
Run `ldapsearch -x -H ldap://[server] -b "[dc=example,dc=com]" "(uid=[username])"` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -x do in ldapsearch?
Simple authentication.