简体   繁体   English

PHP-针对Windows 2003 Active Directory的LDAP身份验证(用户名不同于名字和姓氏)

[英]PHP - LDAP authentication against Windows 2003 Active Directory (User ID different from First Name and Last Name)

Need your help with authenticating an active directory user ID against LDAP. 在根据LDAP验证活动目录用户ID时需要您的帮助。 My problem is unique. 我的问题很独特。 Let me explain here. 让我在这里解释。 Before posting this question, I've googled it and also searched in this forum and did not get any matching posts. 在发布此问题之前,我已经对其进行了谷歌搜索,并且还在该论坛中进行了搜索,但没有找到任何匹配的帖子。

Here is the issue I have a windows 2003 domain controller. 这是我有Windows 2003域控制器的问题。 My company policy is to create the user IDs in the domain as below 我的公司政策是在域中创建用户ID,如下所示

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

When I update the user properties in Active Directory Users and Computers, I have to update the full first and full last name - John Wagner 当我更新Active Directory用户和计算机中的用户属性时,我必须更新全名和全名-John Wagner

When I try to authenticate a html web form in php using the User ID, it doesnt work. 当我尝试使用用户ID对php中的html Web表单进行身份验证时,它不起作用。 However, when I authenticate with the first name and last name, it works. 但是,当我使用名字和姓氏进行身份验证时,它可以工作。

//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");
}
}

I'm not sure where am I going wrong. 我不确定我要去哪里。 Is it not possible to authenticate active directory account using php if the user id is not equal to the first name and last name of the active directory account? 如果用户ID不等于活动目录帐户的名字和姓氏,是否无法使用php对活动目录帐户进行身份验证?

Thanks for all your advise and help in advance. 感谢您的所有建议和帮助。

Regards, Vinay 此致Vinay

If you enter you user like this : 如果输入这样的用户:

在此处输入图片说明

have you simply test : 你简单地测试一下:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM