php - ldap_bind() : Unable to bind to server: Invalid DN syntax

标签 php ldap

我尝试从 ldap 获取身份验证,但收到错误消息 “ldap_bind():无法绑定(bind)到服务器:凭据无效” 任何人都可以提供有关此的任何信息。

下面是我使用的代码:

$ldaphost = "ldap.mydomain.com"; $ldapport = 389; 
$ds = ldap_connect($ldaphost, $ldapport) or die("Could not connect to $ldaphost"); 
if ($ds) { 
   $username = "myUser"; 
   $upasswd = "*****"; 
   $binddn = "uid=$username,ou=people,dc=yourdomain,dc=com"; $ldapbind = ldap_bind($ds, $binddn, $upasswd); 
if ($ldapbind) { echo "login" ; } else { echo " not login"; } 
}

最佳答案

$ldaphost = "ldap.mydomain.com"; 
$ldapport = 389; 

$ds = ldap_connect($ldaphost, $ldapport) or die("Could not connect to $ldaphost"); 
if ($ds) { 
 $username = "myUser"; 
 $upasswd = "*****"; 
 $binddn = "cn=admin,dc=yourdomain,dc=com"; //cn=admin or whatever you use to login by phpldapadmin
 $ldapbind = ldap_bind($ds,$binddn, $upasswd); 

 //check if ldap was sucessfull 
 if ($ldapbind) {
    echo "LDAP bind successful...";
 } else {
    echo "LDAP bind failed...";
 }
}

关于php - ldap_bind() : Unable to bind to server: Invalid DN syntax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21628764/

相关文章:

python - Windows SSL 证书存储和 Python LDAP

javascript - 如何使用客户端 Javascript 向 Ldap 发出请求?

java - 检查 LDAP 连接 (Java)

php - Ajax PHP JavaScript : error when using POST method

php - session 不应自行过期

php - 使用 php 下载文件,而不是处理大文件?

php - 使用 Zend_Http_Client 发送 json POST

PHP调用监听脚本持续运行

java - 列出 Active Directory 组中的所有用户

python - 使用 ldap 在 python 中处理错误