簡體   English   中英

PHP-針對Windows 2003 Active Directory的LDAP身份驗證(用戶名不同於名字和姓氏)

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

在根據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對活動目錄帳戶進行身份驗證?

感謝您的所有建議和幫助。

此致Vinay

如果輸入這樣的用戶:

在此處輸入圖片說明

你簡單地測試一下:

$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