我试图将vanilla论坛与我的公司LDAP服务器集成。它没有成功。我不知道什么是错的:(
这是我如何做到的:
流程:
安装插件jsconnect并配置如下:
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();
?>
问题是
WriteJsConnect($user, $_GET, $clientID,
$secret, $secure);
时,没有任何事情发生,没有新用户创建,角色是
仍然是客人。