在PHP中验证通过Active Directory使用LDAPActive、PHP、LDAP、Directory

2023-09-08 12:02:15 作者:血染素衣泪倾城

我在寻找一种方法,通过LDAP用PHP来验证用户身份(使用Active Directory作为供应商)。理想情况下,应该能够在IIS 7上运行( adLDAP 做它在Apache)。任何人做过类似的话,成功?

I'm looking for a way to authenticate users through LDAP with PHP (with Active Directory being the provider). Ideally, it should be able to run on IIS 7 (adLDAP does it on Apache). Anyone had done anything similar, with success?

编辑:我想preFER库/类code,它已经准备好去...这将会是愚蠢的发明轮子,当有人已经这样做了

推荐答案

导入全库似乎效率不高时,你需要的是本质上的两行code ...

Importing a whole library seems inefficient when all you need is essentially two lines of code...

$ldap = ldap_connect("ldap.example.com");
if ($bind = ldap_bind($ldap, $_POST['username'], $_POST['password'])) {
  // log them in!
} else {
  // error message
}