通过后台API登录可以获得对SuiteCRM的完全访问权限吗?
例如,我们在一个单独的站点上使用LDAP,并且我想在后台将经过身份验证的用户传递给suitecrm,然后让suitecrm授予对所述用户的访问权限,而无需他们再次登录。
我已经能够让API工作并“登录”用户并返回session_id,但它仍然指示我进入登录页面。如果我试图强制重定向,我会得到一个err_to_many_redirects。
编辑:
我不相信这个问题来自API脚本,而是使用返回的数据来完成所需的会话数据,这是我能够生成的。
获取<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
require_once('./shield_secureaccess.php');
$url = "http://{site_location}/service/v4_1/rest.php";
session_start();
$username = $_SESSION['SHIELD_user'];
session_write_close();
if(isset($username)){
$password = shield_secureaccess($username);}
else{require 'shield_session.php';}
//function to make cURL request
function call($method, $parameters, $url)
{
ob_start();
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, $url);
curl_setopt($curl_request, CURLOPT_POST, 1);
curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($curl_request, CURLOPT_HEADER, 1);
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
$jsonEncodedData = json_encode($parameters);
$post = array(
"method" => $method,
"input_type" => "JSON",
"response_type" => "JSON",
"rest_data" => $jsonEncodedData
);
curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($curl_request);
curl_close($curl_request);
$result = explode("\r\n\r\n", $result, 2);
$response = json_decode($result[1]);
ob_end_flush();
return $response;
}
//login ------------------------------
$login_parameters = array(
"user_auth" => array(
"user_name" => $username,
"password" => md5($password),
"version" => "1"
),
"application_name" => "RestTest",
"name_value_list" => array(),
);
$login_result = call("login", $login_parameters, $url);
echo "<pre>";
// print_r($_SESSION);
print_r($login_result);
// print_r($current_user);
print_r($_SESSION);
echo "</pre>";
//get session id
$session_id = $login_result->id;
// header("Location: http://{site_location}/index.php?module=Home&action=inde");
// header("Location: http://{site_location}/index.php?MSID=$session_id");
?>
答案 0 :(得分:0)
你快到了。会话ID无法立即用于登录,您首先必须致电seamless_login
。
所以流程是:
http://{site_location}/index.php?MSID=$session_id
,其中$session_id
是原始API登录电话中的会话ID。