[英]Steps to implement LDAP on my website using PHP
任何人都可以让我使用PHP在我的网站上逐步解释LDAP
默认情况下不启用PHP中的LDAP支持。 在编译PHP以启用LDAP支持时,您将需要使用--with-ldap [= DIR]配置选项。 DIR是LDAP基本安装目录。 要启用SASL支持,请确保使用--with-ldap-sasl [= DIR],并且系统上存在sasl.h。
首先确保你安装了PHP的LDAP扩展,正如@YYYN建议的那样。 要实现基于LDAP的身份验证机制,我建议您使用Zend_Auth及其适配器进行LDAP 。 可以使用Zend_Ldap处理进一步的操作。
似乎您的问题仍未得到解答,因为您没有选择答案。
因此,如果您想知道如何验证用户,可以这样做:
$userFound = false;
$ds = ldap_connect('my.ldap.com');
if ($ds)
{
// Anonymous bind
ldap_bind($ds);
// Search the DN of the user
$searchRes = ldap_search($ds, 'ou=people,dc=my_company,dc=com', 'uid=your_user_uid');
$info = ldap_get_entries($ds, $searchRes);
// If the search returned at least one result, try to bind to the server
// using the DN you just get, and the password provided by you user
if ($info['count'] < 0)
$userFound = ldap_bind($ds, $info[0]['dn'], $password);
ldap_close($ds);
}
var_dump($userFound);
请注意,正如miku所说,您必须安装LDAP。 默认情况下不安装它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.