You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2020-01-22 22:20:29

lordbat
Member
From: Spain
Registered: 2016-02-12
Posts: 158

Normal Profile - see user and technician Realname (Not Id only)

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

#2 2020-01-23 17:19:53

ben2249
Member
From: FRANCE
Registered: 2019-12-03
Posts: 35

Re: Normal Profile - see user and technician Realname (Not Id only)

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

#3 2020-01-23 18:00:28

lordbat
Member
From: Spain
Registered: 2016-02-12
Posts: 158

Re: Normal Profile - see user and technician Realname (Not Id only)

ben2249 wrote:

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

#4 2020-01-24 09:45:07

ben2249
Member
From: FRANCE
Registered: 2019-12-03
Posts: 35

Re: Normal Profile - see user and technician Realname (Not Id only)

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

#5 2020-01-24 15:20:18

lordbat
Member
From: Spain
Registered: 2016-02-12
Posts: 158

Re: Normal Profile - see user and technician Realname (Not Id only)

ben2249 wrote:

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

Board footer

Powered by FluxBB