doushua7737 2016-06-22 09:11
浏览 114

带有ldap身份验证的PHP登录页面(用户组)

I have a PHP login page with LDAP authentication. The script connect successfully to my LDAP server, and it is possible for me to log in with my credentials. But I want to make the script more specific. I Want that the script connect to specific user group in my AD. The usergroup is TEST_LDAP. And it located in OU=Groups,OU=BE,OU=Company,DC=wetnl. I have tried it, but without succes.
Here is the PHP script:

session_start();
$succes = TRUE;
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if ( isset($_POST['gebruikersnaam']) && isset($_POST['wachtwoord']))
{
    /* aanmelden via LDAP */
    $ds=ldap_connect("10.10.10.110"); // geef hier het ip-adres in van een geldige LDAP server!
    if(!$ds)
    {
        $succes = FALSE;
        $foutmelding = 'Geen verbinding met Active Directory';
    }

    if($succes === TRUE)
    {
        ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
        $r=ldap_bind($ds, $_POST['gebruikersnaam'], $_POST['wachtwoord']);
        if($r)
        {
       $_SESSION['gebruiker_id'] = $row['GEBRUIKERID'];
       $_SESSION['aangemeld'] = TRUE;
       header("Location: index.php");
        }
        else
        {
      $succes = FALSE;
      $foutmelding = 'Inloggen is niet gelukt door ongeldige combinatie gebruikersnaam/wachtwoord.<br/>';
  }
  ldap_close($ds);
}
   }
   else
   {
   $error = 'Vul zowel gebruikersnaam als wachtwoord in om in te loggen.';
   }
    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大