我正在尝试将香草论坛与我公司的 LDAP 服务器集成。这并不成功。我不知道怎么了:(
这是我如何做到这一点:
流量:
插件 jsconnect 已安装并配置如下:
- 客户 ID:已生成
- 秘密:生成
- 认证网址:LoginController.php
来源LoginController.php
<?php
include 'ChromePhp.php';
require_once 'functions.jsconnect.php';
// using ldap bind
$user_ = $_POST['user'];
$pass_ = $_POST['pass'];
// $ldaprdn = 'uid=riemann,dc=example,dc=com'; // ldap rdn or dn
// $ldappass = 'password'; // associated password
$ldaprdn = 'uid=';
$ldaprdn.=$user_.',dc=example,dc=com';
$ldappass=$pass_;
ChromePhp::log($ldaprdn);
// connect to ldap server
$ldapconn = ldap_connect("ldap.forumsys.com")
or die("Could not connect to LDAP server.");
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
ChromePhp::log("LDAP bind start...");
$validatedUser= FALSE;
if ($ldapconn) {
// binding to ldap server
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
// verify binding
if ($ldapbind) {
// echo "LDAP bind successful...";
ChromePhp::log("LDAP bind successful...");
$validatedUser =TRUE;
} else {
// echo "LDAP bind failed...";
ChromePhp::log("LDAP bind failed...");
}
}
$attributes = array('mail','cn');
$accountname = $user_;
$filter_person = "uid={$accountname}";
$search = ldap_search($ldapconn,"DC=example,DC=com",$filter_person , $attributes);
$data = ldap_get_entries($ldapconn, $search);
ChromePhp::log($data);
$fullname= $data[0]['cn'];
$mail= $data[0]['mail'];
ChromePhp::log($fullname);
ChromePhp::log($mail);
#intergrate
$clientID = "string";
$secret = "stringSecret";
$userArray = array();
if ($validatedUser) {
// CHANGE THESE FOUR LINES.
ChromePhp::log("start fill user...");
$userArray['uniqueid'] = $user_;
$userArray['name'] = $fullname['0'];
$userArray['email'] = $mail['0'];
$userArray['photourl'] = '';
}
// 4. Generate the jsConnect string.
// This should be true unless you are testing.
// You can also use a hash name like md5, sha1 etc which must be the name as the connection settings in Vanilla.
ChromePhp::log($userArray);
$secure = false;
WriteJsConnect($userArray, $_GET, $clientID, $secret, $secure);
//header("Location: ../../../v/"); /* Redirect browser */ //somehow add this make the file stop working :p
//exit();
?>
问题是
- LoginController 输出是 {"name":"","photourl":""} 似乎不对。
- 当 php 跳转过去时
WriteJsConnect($user, $_GET, $clientID, $secret, $secure);
没有任何反应,没有创建新用户,角色仍然是 guest。