[英]Issue connecting to LDAP through PHP
My company recently changed domains due to an ownership change and I am having an issue getting my LDAP bind to complete on the new domain. 我的公司最近由于所有权变更而更改了域,而我的LDAP绑定无法在新域上完成时遇到问题。
My connect command creates the resource correctly but when I go to bind I get the error. 我的connect命令正确创建了资源,但是当我进行绑定时出现错误。
"Warning: ldap_bind(): Unable to bind to server: Strong(er) authentication required"
“警告:ldap_bind():无法绑定到服务器:需要强(er)身份验证”
I am not using ldaps. 我没有使用ldaps。 I have confirmed I have the correct domain url for LDAP.
我已经确认我具有用于LDAP的正确域URL。
$ad
is the resource, $dmun
is the username with domain added and the $pw
is the password. $ad
是资源, $dmun
是添加了域的用户名, $pw
是密码。
$bd = ldap_bind($ad,$dmun,$pw);
It's an intranet site. 这是一个Intranet网站。
Try This code. 尝试此代码。 This code worked for me
这段代码对我有用
$username = 'username';
$password = 'password';
$ldap_host = "domain.com";
$ldap_port = 389;
$base_dn = "DC=domain,DC=com";
$filter = '(sAMAccountName=' . $username . ')';
$connect = ldap_connect($ldap_host, $ldap_port) or exit("Error : Could not connect to LDAP server.");
if ($connect) {
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
if (@$bind = ldap_bind($connect, "$username@domain.com", $password)) {
echo "Bind Successfull";
} else {
echo "Invalid Username / Password";
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.