简体   繁体   English

“LDAP_OPT_PROTOCOL_VERSION”和“LDAP_OPT_REFERRALS”有什么作用?

[英]What does “LDAP_OPT_PROTOCOL_VERSION” and “LDAP_OPT_REFERRALS” do?

I've seen the following code snippet in many PHP scripts that are using the ldap extension. 我在许多使用ldap扩展的PHP脚本中看到了以下代码片段。 I've searched online but didn't find something helpful. 我在网上搜索但没有找到有用的东西。

ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);

I know that the first line sets the ldap protocol version to 3. But what is the advantage of this version? 我知道第一行将ldap协议版本设置为3.但是这个版本有什么优势? Why is it needed? 为什么需要它?

But i really don't know what the second line is doing, can someone explain it to me? 但我真的不知道第二行在做什么,有人可以向我解释一下吗?

Over time there's been multiple versions of the LDAP protocol with incompatibilities. 随着时间的推移,有多个版本的LDAP协议存在不兼容性。 The latest version and the only viable one is version 3 (LDAPv2 has been set historical and deprecated). 最新版本和唯一可行的版本是版本3(LDAPv2已设置为历史版本且已弃用)。 Many LDAP client libraries still offer support for both LDAPv2 and LDAPv3, and to show their age, they are still defaulting to LDAPv2, unless setting the option to use LDAPv3 (I don't know if that's still the case for PHP, but better be safe and set it explicitly). 许多LDAP客户端库仍然提供对LDAPv2和LDAPv3的支持,并且为了显示它们的年龄,它们仍然默认为LDAPv2,除非设置选项以使用LDAPv3(我不知道PHP的情况是否仍然如此,但更好的是安全并明确设置)。

The second line defines how the client library should handle Referrals returned by the server. 第二行定义客户端库应如何处理服务器返回的引用。 A referral is an indication that the server cannot proceed with the request, but if you send the same request to the referred server, it should proceed. 引用表示服务器无法继续处理请求,但如果您向引用的服务器发送相同的请求,则应继续进行。 Client libraries can chase referrals automatically or not, but when they do, they will reuse exactly the same credentials as the initial request. 客户端库可以自动或不自动追踪引用,但是当它们执行时,它们将重用与初始请求完全相同的凭据。 Chasing referrals automatically can result to security issues. 自动追逐推荐可能会导致安全问题。 So it's wise to disable this by default as well. 因此,默认情况下禁用此功能也是明智之举。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM