【发布时间】:2016-07-04 13:35:15
【问题描述】:
我有一个 PHP 网站,想针对 Azure Active Directory 对用户进行身份验证。使用 ldap_connect 和 bind,我可以毫无问题地对我们公司的本地 AD-Server 执行此操作。
function checkADAccount($username, $password)
{
$adServer = "myADServer";
$ldaprdn = 'myDomain' . "\\" . $username;
$ldap = ldap_connect($adServer);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$bind = @ldap_bind($ldap, $ldaprdn, $password);
if ($bind) {
@ldap_close($ldap); // Verbindung schließen
return true;
} else {
return false;
}
}
但是我的应用程序托管在 Amazon Web Services (AWS) 上并且不在同一个域中,所以我不能使用这种方式。
使用 ldap_connect 并将此函数绑定到我们公司的本地 AD-Server。但是我的应用程序托管在 Amazon Web Services (AWS) 并且不在同一个域中,所以我不能使用这种方式。
我使用 Azure 中我公司的 ClientId 和密钥测试了 graphapi。所以我可以读取用户数据,但我看不到任何检查用户/密码组合的可能性。我只想检查,如果存在使用此密码的用户,我不需要从那里读取它。
因此,我尝试通过更改 adServer 和用户的参数来修改上面的 LDAP 解决方案
$ldaprdn = 'sAMAccountname=' . $username . ',cn=users' . ',dc=myDomain,dc=com';
但我总是得到:“警告:ldap_bind():无法绑定到服务器:无法联系 LDAP 服务器”。我尝试了 adServer 的多个版本,但任何版本都提供了绑定。
你知道错误在哪里吗?我建议使用 ldap_connect 是错误的方式,尤其是我不知道哪个服务器地址是正确的,以及我必须如何告诉 ClientId 和密钥。
【问题讨论】:
标签: php azure amazon-web-services active-directory azure-active-directory