我有这个ldap代码,我只希望用户从一个特定的组(cn)能够登录


I have this ldap code and i only want users from a specific group (cn) to be able to login

这是我的代码

    if ($bind) {
        $_SESSION['user'] = $username['username'];
        header("Location: /Login/Homepage.php");
        //@ldap_close($ldap);
    }else {
   $errMSG = "Wrong Credentials, Try again...";
  }

你能帮我在我的代码中添加什么,只让用户从一个特定的组(cn)访问主页。谢谢!

您没有对结果做任何事情(除了排序,您不应该再使用ldap_sort)。您在$result中有一个结果句柄,就是这样…也许您应该检查https://gist.github.com/heiglandreas/5689592,看看它是否对您有更多帮助。