Php 将LDAP服务器与香草论坛集成

Php 将LDAP服务器与香草论坛集成,php,active-directory,ldap,single-sign-on,vanilla-forums,Php,Active Directory,Ldap,Single Sign On,Vanilla Forums,我正在尝试将香草论坛与我的公司LDAP服务器集成。它不成功。我不知道怎么了:( 我是这样做的: 流程: 插件jsconnect已安装,配置如下: ClientID:已生成 秘密:生成 验证URL:LoginController.php LoginController.php的源代码 <?php include 'ChromePhp.php'; require_once 'functions.jsconnect.php'; // using ldap bind $user_ = $

我正在尝试将香草论坛与我的公司LDAP服务器集成。它不成功。我不知道怎么了:(

我是这样做的:

流程:

插件jsconnect已安装,配置如下:

  • ClientID:已生成
  • 秘密:生成
  • 验证URL: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,$\u GET,$clientID,
    $secret,$secure);
    没有发生任何事情,没有创建新用户,角色是 还是客人

@VeeK你让它工作了吗?几个月后它几乎不工作了。我对LDAP一无所知,但这里有一个基本概念。当用户单击登录/注册页面时,你会将他们发送到你网站的正常登录页面(登录Url)。不要做任何特殊的事情,只要让他登录,就像香草一样简单(lol)然后将它们发送回论坛。当用户返回论坛时,香草将自动ping您的“AuthenticationURL”。在此页面上,您只需查看用户是否通过您常用的方法登录,如果用户是,则向该
$userArray
添加变量,否则将向
WriteJsConnect
传递一个空数组。您好,什么意思是勉强工作?登录是否有一些参数触发“身份验证Url”?身份验证url不发送签名参数以获得完整响应,因此用户看到他的姓名和头像,他必须再次单击以完成登录。因此需要两次单击。我对此有一个开放性问题。登录url与我所说的身份验证url无关。在登录页面上,不要执行loggin使用的任何其他操作r inIt很遗憾,该论坛上的支持几乎消失了:(Vanilla是一个非常有潜力的论坛软件:(@VeeK你管理它工作了吗?几个月后它几乎不工作了。我对LDAP一无所知,但这里有一个基本概念。当用户单击登录/注册页面时,你会将它们发送到网站的正常登录页面(登录Url)。不要做任何特别的事情,只要让他登录,就像香草一样简单(lol),然后将它们发送回论坛。当用户返回论坛时,香草会自动ping您的“AuthenticationURL”。在此页面上,您只需查看用户是否通过您常用的方法登录,如果用户是,则向该
$userArray
添加变量,否则将向
WriteJsConnect
传递一个空数组。您好,什么意思是勉强工作?登录是否有一些参数触发“身份验证Url”?身份验证url不发送签名参数以获得完整响应,因此用户看到他的姓名和头像,他必须再次单击以完成登录。因此需要两次单击。我对此有一个开放性问题。登录url与我所说的身份验证url无关。在登录页面上,不要执行loggin使用的任何其他操作r inIt很遗憾,该论坛上的支持几乎消失了:(Vanilla是一款非常有潜力的论坛软件:(