0

在针对 LDAP 验证活动目录用户 ID 方面需要您的帮助。我的问题是独一无二的。让我在这里解释一下。在发布这个问题之前,我已经用谷歌搜索过它,也在这个论坛中搜索过,没有得到任何匹配的帖子。

这是我有一个 Windows 2003 域控制器的问题。我的公司政策是在域中创建用户 ID,如下所示

First Name = John
Last Name = Wagner
User ID = jwagner@company.com (domain controller is company.com)

当我更新 Active Directory 用户和计算机中的用户属性时,我必须更新完整的名字和完整的姓氏 - John Wagner

当我尝试使用用户 ID 在 php 中验证 html Web 表单时,它不起作用。但是,当我使用名字和姓氏进行身份验证时,它可以工作。

//username is given as jwagner in the html form in this case. Authentication Fails.
//username is given as "john wagner" (without the quotes). Authentication Success.

if ((isset($_POST['username'])) && (isset($_POST['password'])))
{
$username=$_POST['username'];
$password=$_POST['password'];

$adServer = "10.23.1.1";
$ldapconn = ldap_connect($adServer)
    or die("Could not connect to LDAP server.");

$ldaprdn = $username;
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $password);

if ($ldapbind)
{
    $_SESSION['username'] = $username;
    $_SESSION['password'] = $password;
    header("Location: http://company.com/website1");
}
else
{
    //if authentication fails, redirect back to the login page
    header("Location: http://company.com/index.php");
}
}

我不确定我哪里出错了。如果用户 id 不等于活动目录帐户的名字和姓氏,是否无法使用 php 验证活动目录帐户?

感谢您提前提供的所有建议和帮助。

问候, 维奈

4

1 回答 1

1

如果您像这样输入您的用户:

在此处输入图像描述

你有没有简单的测试:

$ldap_domain = 'company.com';
$ldapbind = ldap_bind($ldapconn, "$ldaprdn@$ldap_domain", $password);
于 2011-10-08T03:33:27.007 回答