gpt4 book ai didi

php - 将 flex/php 连接到 Active Directory

转载 作者:可可西里 更新时间:2023-11-01 13:27:13 25 4
gpt4 key购买 nike

有没有办法将我的 flex web 应用程序连接到 Active Directory,并获取记录的用户名?

现在我们有一个连接到 flex 应用程序的 PHP 脚本,它从用户那里获取用户/密码输入,并检查 AD 中是否有这样的用户,以及密码是否正确。
我不想询问用户/密码,而是让应用程序获得与其连接的域用户名,这样我就可以使用它(检查用户是否有权访问我的应用程序等)。

有办法吗?

最佳答案

<?php

// using ldap bind
$ldaprdn = 'uname'; // ldap rdn or dn
$ldappass = 'password'; // associated password

// connect to ldap server
$ldapconn = ldap_connect("ldap.example.com")
or die("Could not connect to LDAP server.");

if ($ldapconn) {

// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

// verify binding
if ($ldapbind) {
echo "LDAP bind successful...";
} else {
echo "LDAP bind failed...";
}

}

?>

当您的应用程序启动时,您需要使用 Windows 登录凭据访问 LDAP。

`AUTH_USER` request variable is the one which you have to check. 
This will hold your Windows login username and AUTH_USER will be
MYDOMAINNAME\user.name

The username/password I need for this, is that admin credentials, or any user on the system?

您可以单独获取用户名,而不是密码...当用户登录到他的窗口机器时,我们可以在 C# 中使用 Environment.username 检查他的凭据,在 PHP 中我们可以使用 AUTH_USER验证登录的用户是否有效。

Plus, do you know where can I find a list of variables (like auth_user) of which information can I get?

http://in3.php.net/manual/en/ref.ldap.php

您可以从上面的链接中获取很多信息。

关于php - 将 flex/php 连接到 Active Directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2826197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com