You are not logged in.
Situation: Im programming a external app and i try to make a user view of a ticket but i cant get "access" to translate a requester or technician in charge names.
Reading the API Doc and CommonDBTM i can get the Ticket user requester and technician in charge Id´s (Example: http://server/glpi/apirest.php/Ticket/xxxxx/Ticket_User )but if i try to relate it with the user info, because of profile restriction y cant show the realname. There is some CommonDBTM related to get it as normal profile?
i dont know if i am explain correctly
Regards!
You can mark this thread as [Solved] in the subject of your thread. (This is only available edit of the first post.) It is good for users who help others to quickly see which post is still open.
############################################################
Offline
Hello,
I made a function to get users info by its ID
it is part of a class but you get the idea
/**
* @param $user_id
* @return bool|mixed
*
*/
public function user($user_id){
if($this->sess_token == ""){
$this->error = "Erreur : Vous n'êtes pas connecté";
return false;
}
$fin_url = "?session_token=$this->sess_token&app_token=$this->app_token";
$url = $this->api_url ."/User/".$user_id."/$fin_url";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$json = curl_exec($ch);
if(!$json){
$this->error = 'Erreur Curl : ' . curl_error($ch);
curl_close ($ch);
return false;
}else{
$obj = json_decode($json,true);
curl_close ($ch);
return $obj;
}
}
Last edited by ben2249 (2020-01-23 17:20:39)
Offline
Hello,
I made a function to get users info by its ID
it is part of a class but you get the idea/** * @param $user_id * @return bool|mixed * */ public function user($user_id){ if($this->sess_token == ""){ $this->error = "Erreur : Vous n'êtes pas connecté"; return false; } $fin_url = "?session_token=$this->sess_token&app_token=$this->app_token"; $url = $this->api_url ."/User/".$user_id."/$fin_url"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); $json = curl_exec($ch); if(!$json){ $this->error = 'Erreur Curl : ' . curl_error($ch); curl_close ($ch); return false; }else{ $obj = json_decode($json,true); curl_close ($ch); return $obj; } }
Thanks for the reply, your function is based by super-admin profile? or normal? because with super-admin i can get it, but i trying to get in normal profile. i dont know if i need like a "Service User" to get the permissions and use it to get the usernames, but i dont know if this is a good practice. That is why i am looking on CommonDBTD if i can get it.
Regards!..
You can mark this thread as [Solved] in the subject of your thread. (This is only available edit of the first post.) It is good for users who help others to quickly see which post is still open.
############################################################
Offline
Hello,
Indeed, it is a super-admin. I use it to get things normal users cannot get access to.
Last edited by ben2249 (2020-01-24 09:45:19)
Offline
Hello,
Indeed, it is a super-admin. I use it to get things normal users cannot get access to.
Hi!! exactly, i do some things with super-admin but for example.
In WEB GLPI as normal profile, when the user enter in his ticket to see the "Requester", "Watcher" or "Assigned To", they can see the realnames but trying to se the same thing by calling the API i have the issue about the permission restriction and i dont know if is a good practice call two diferent users/profiles to get some fields like username or groupname who have the same situation, getting both ID's but i cant get the names linked.
Im relative new in programming or "good practices of programming" and that is why i am asking that.
Regards!..
You can mark this thread as [Solved] in the subject of your thread. (This is only available edit of the first post.) It is good for users who help others to quickly see which post is still open.
############################################################
Offline