IT袋

当前位置:主页 > 经验教程 > 建站编程 >

curl命令怎么用

curl命令怎么用 curl常用命令及参数详解(13)

更新:2023-08-11 17:28:08 来源:IT袋 作者:马勇
导读:curl命令怎么用,curl dict://dict.org/show:db curl dict://dict.org/show:strat Authentication support is still missing LDAP If you have installed the OpenLDAP library, curl can take advantage of it and offer ldap:// su

curl命令怎么用

curl dict://dict.org/show:db
curl dict://dict.org/show:strat
Authentication support is still missing

LDAP

If you have installed the OpenLDAP library, curl can take advantage of it and offer ldap:// support. On Windows, curl will use WinLDAP from Platform SDK by default.

Default protocol version used by curl is LDAPv3. LDAPv2 will be used as a fallback mechanism in case LDAPv3 fails to connect.

LDAP is a complex thing and writing an LDAP query is not an easy task. I do advise you to dig up the syntax description for that elsewhere. One such place might be: RFC 2255, The LDAP URL Format

To show you an example, this is how I can get all people from my local LDAP server that has a certain sub-domain in their email address:

curl -B "ldap://ldap.frontec.se/o=frontec??sub?mail=*sth.frontec.se"
If I want the same info in HTML format, I can get it by not using the -B (enforce ASCII) flag.

You also can use authentication when accessing LDAP catalog:

curl -u user:passwd "ldap://ldap.frontec.se/o=frontec??sub?mail=*"
curl "ldap://user:passwd@ldap.frontec.se/o=frontec??sub?mail=*"
By default, if user and password are provided, OpenLDAP/WinLDAP will use basic authentication. On Windows you can control this behavior by providing one of --basic, --ntlm or --digest option in curl command line

curl --ntlm "ldap://user:passwd@ldap.frontec.se/o=frontec??sub?mail=*"
On Windows, if no user/password specified, auto-negotiation mechanism will be used with current logon credentials (SSPI/SPNEGO).

Environment Variables
Curl reads and understands the following environment variables:

http_proxy, HTTPS_PROXY, FTP_PROXY
They should be set for protocol-specific proxies. General proxy should be set with

ALL_PROXY

设置了不应通过任何代理的主机名的逗号分隔列表(只有星号,*匹配所有主机)

NO_PROXY

如果主机名与这些字符串之一匹配,或者主机位于这些字符串之一的域内,则不会代理与该节点的事务。使用域时,需要以句点开头。用户可以通过设置为来指定www.example.com和 foo.example.com 都不应使用代理。通过包含全名,您可以排除特定的主机名,因此要不使用代理但仍然可以使用,请设置为.NO_PROXY.example.comwww.example.comfoo.example.comNO_PROXYwww.example.com

-x/标志的使用--proxy会覆盖环境变量。

网路

Unix.netrc很久以前就引入了这个概念。这是用户在文件中为经常访问的 FTP 站点指定名称和密码的一种方式,这样您就不必在每次访问这些站点时都输入它们。您意识到如果其他人掌握了您的密码,这是一个很大的安全风险,因此大多数 Unix 程序不会读取此文件,除非它只能由您自己读取(但 curl 不在乎)。

.netrc如果被告知,Curl 支持文件(使用-n/--netrc和--netrc-optional选项)。这不仅限于 FTP,因此 curl 可以将它用于所有使用身份验证的协议。

相关阅读