简体   繁体   English

我如何从 LDAP 更改为 Ldaps

[英]How can i change from Ldap to Ldaps

I have a functioning code that creats an Ldap connection to an online test server.我有一个功能正常的代码,可以创建到在线测试服务器的 Ldap 连接。

<?php

$ldap_dn = "uid=".$_POST["username"].",dc=example,dc=com";
$ldap_password = $_POST["password"];

$ldap_con = ldap_connect("ldap.forumsys.com");
ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);

if(@ldap_bind($ldap_con,$ldap_dn,$ldap_password))
    {
    $_SESSION['username'] = $_POST["username"];

    header("Location: Startseite.php");

    }

else
    {
    echo "Invalid Credential";
    }
?>

Now i want to change the code to connect to a local Windows server and retrieve data from the active directory.现在我想更改代码以连接到本地 Windows 服务器并从活动目录中检索数据。 This connection should be an Ldaps.这个连接应该是一个 Ldaps。 Here is the code i tried.这是我试过的代码。

<?php

$ldap_dn = "uid=".$_POST["username"].",dc=ULTIMATE,dc=local";
$ldap_password = $_POST["password"];

$ldap_con = ldap_connect("ldaps://192.168.***.**:636,OU=ULTIMATE,DC=ultimate,DC=local");
ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);

if(@ldap_bind($ldap_con,$ldap_dn,$ldap_password))
    {
    $_SESSION['username'] = $_POST["username"];

    header("Location: Startseite.php");

    }

else
    {
    echo "Invalid Credential";
    }
?>

And i get the following error我收到以下错误

Warning: ldap_connect(): Could not create session handle: Bad parameter to an ldap routine in C:\\xampp\\htdocs\\Kulinarik\\ldap.php on line 10警告:ldap_connect():无法创建会话句柄:第 10 行 C:\\xampp\\htdocs\\Kulinarik\\ldap.php 中 ldap 例程的错误参数

Why is it a bad parameter ?为什么它是一个坏参数?

EDIT编辑

So the Active directory is Passwort protected and the users who want to start the query have no rights.所以 Active Directory 是受密码保护的,想要开始查询的用户没有权限。 So i would have to make a Bind with the Credentials of the Sysadmin and then make a query inside the active directory with the Credentials of the users.因此,我必须使用系统管理员的凭据进行绑定,然后使用用户的凭据在活动目录中进行查询。

Is that right?那正确吗?

Try something like:尝试类似:

$ldap_con = ldap_connect("ldaps://192.168.***.**:636");

Without ,OU=ULTIMATE,DC=ultimate,DC=local part.没有,OU=ULTIMATE,DC=ultimate,DC=local部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM