PHP ldap_bind() authentication - error无法绑定到服务器:无效凭据


PHP ldap_bind() authentication - error Unable to bind to server: Invalid credentials?

我正在尝试使用PHP验证LDAP用户。我有用户的DN,我检查过是正确的。我也有密码。这是用户使用SamAccountName进行身份验证时的正确密码。

我希望这是使用DN进行身份验证时使用的密码。没有针对LDAP的专有名称特定密码,是吗?下面是我使用PHP的ldap_bind()函数进行身份验证的代码。我这样做对吗?

$ldaphost="ldap://somehost.com:3268";
$dn = "cn=LastName', FirstName Dept/Country/ext,OU=Accounts,OU=Location,ou=Division,";
$basedn="dc=abc,dc=enterprise";
if (!($connect = ldap_connect($ldaphost))) {    
  die ("Could not connect to LDAP server"); 
} 
$ldapbind = ldap_bind($connect, "$dn" . "$basedn", $password);
if ($ldapbind) {
   echo "LDAP bind successful...";
} else {
   echo "LDAP bind failed...";
}
我从上面的代码得到的结果是:

警告:ldap_bind() [function。ldap-bind]:无法绑定服务器:LDAP绑定失败…

ldap_bind()呼叫所在行开始:

$ldapbind = ldap_bind($connect, "$dn" . "$basedn", $password);

无效凭据使我相信DN或密码可能有问题。我已经三次检查了DN,据我所见,那里没有错误。

任何想法?

我猜你正在连接到一个微软域,你可以尝试域语法的凭据。

当处理ldap时,我总是发现jxplorer很有用