2014-02-07 295 views
1

我试图从LDAP获得认证,我歌厅错误 “的ldap_bind():无法绑定到服务器:无效的凭证” 任何一个可以提供关于此的任何信息。的ldap_bind():无法绑定到服务器:无效的DN语法

下面的代码我使用:

$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"; } 
} 
+0

能*你*提供有关这方面的消息? – ixe013

+0

是否尝试连接到Microsoft域? –

回答

1
$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..."; 
} 
} 
相关问题