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/

相关文章:

php - 10 到 15 条 XMPP 消息后出现错误 503

php - 为什么我在对象上调用函数时会在非对象上出现此函数调用错误?

active-directory - 使用 rfc2254 中指定的 objectGUID 编码的事件目录过滤器不起作用

spring - 如何转换grails 2 LDAP Active Directory值以使用Spring Boot

php - MySQL在where子句中多次查询同一个字段

php - 从 script.php 中打开 file.html

php - 如何防止用户使用 jQuery 以最大长度输入值

C++ 使用 ldap.h 中的 ldap_bind

php - 在 PHP 中从 openLDAP 获取所有可能的属性和所有 objectClass

vbscript - 使用 ADODB 检索 AD SID 返回不正确的 SID