插入适用于所有AD情况的解决方案几乎不存在!这通常是系统管理员的工作。
您的设备需要询问许多字段,例如服务器地址,服务器端口,使用SSL,代理代理(应用程序名称和应用程序DN),代理密码,基本DN和代理模式。
然后,您的应用程序应用程序,Java或PHP或其他应用程序需要实现LDAP协议,并执行身份验证检查。
我已经将企业LDAP与Wordpress和Mediawiki集成在一起(之前他们有插件),而且非常简单,只是没有即插即用。
我在PHP中使用了两个文件 - 一个使用设置,另一个使用auth函数。包括这两个在任何PHP应用程序,只是通过输入的用户名和密码,并返回与用户名称,电子邮件等信息的身份验证...
这是我创建一个测试页,当我第一次得到它所有的工作。
<html><body>
<?php
# Matt Hart - PHP-based authentication against active directory
# Tested on Fedora Core 4 with Apache 2.0.54, PHP 4.3.11, OpenLDAP
# OpenSSL, php-ldap
# Working on RHEL4
echo "<br>Attempting Secure LDAP Connection<br>";
// $mh_ldaphost = "ldaps://directory.yoursite.com:636";
$mh_ldaphost = "ldaps://ldap.yoursite.com:636";
$mh_ldapconn = ldap_connect($mh_ldaphost) or die ("Failed");
echo "<br>Succeeded ... Testing app binding<br>";
# Bind using app credentials
$mh_appid = "yourappid"; // ****** Use your application id
$mh_dn = "uid=" . $mh_appid . ",ou=Apps,o=Yoursite.com";
$mh_bind = ldap_bind($mh_ldapconn, $mh_dn) or die("Failed");
echo "<br>Succeeded ... Get user corp ID</br>";
# Get the user's corporate ID
$mh_search = "ou=employees,ou=people,o=yoursite.com";
$mh_userid = "johnny"; // ****** User ID to find
$mh_filter = "(uid=" . $mh_userid . ")";
$mh_search = ldap_search($mh_ldapconn, $mh_search, $mh_filter) or die ("Failed");
echo "<br>Succeeded: ";
$mh_entries = ldap_get_entries($mh_ldapconn, $mh_search);
$mh_corpid = $mh_entries[0]["corpidfield"][0];
echo "CorpID=" . $mh_corpid;
# Authenticate the user
echo "<br><br>Authenticating...<br>";
$mh_authdn = "corpidfield=" . $mh_corpid . ",ou=employees,ou=people,o=yoursite.com";
$mh_authpass = "Depp1"; // ****** User password
$mh_authbind = ldap_bind($mh_ldapconn, $mh_authdn, $mh_authpass) or die("Failed");
die("Success");
?>
</body></html>
您还可以打印整个条目[]数组,以查看所有可能的返回结果。
您的解决方案是开源的吗? – kristopolous
添加了我创建的示例页面中的代码。你可以从应用版本看到它有多大!但它仍然可以在PHP5和最新的Active Directory服务器上正常工作。 –