【问题标题】:PHP - LDAP authentication against Windows 2003 Active Directory (User ID different from First Name and Last Name)PHP - 针对 Windows 2003 Active Directory 的 LDAP 身份验证(用户 ID 不同于名字和姓氏)
【发布时间】:2011-10-07 18:21:02
【问题描述】:

在针对 LDAP 验证 Active Directory 用户 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 验证活动目录帐户?

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

问候, 维奈

【问题讨论】:

    标签: php authentication active-directory ldap windows-2003-webserver


    【解决方案1】:

    如果你这样输入你的用户:

    你有没有简单的测试:

    $ldap_domain = 'company.com';
    $ldapbind = ldap_bind($ldapconn, "$ldaprdn@$ldap_domain", $password);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多