getting client_id from ISPConfig API

Discussion in 'Developers' Forum' started by dgmufasa, Nov 16, 2011.

  1. dgmufasa

    dgmufasa New Member

    Hello,

    In many of the ISPConfig functions, a "client_id" is needed for use. For example, in the "add_client" functionality, there is an option to enter "parent_id".

    How can one get this parent_id from the ISPConfig user interface?

    What function can one execute to get it?

    Is one supposed to query the client DB table directly to get it?

    TIA
     
  2. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    See function client_get_id($sys_userid) in API docs. Please post API and dev related questions in the Developer forum.
     
  3. dgmufasa

    dgmufasa New Member

    Thanks again for the response.

    At first, I was doing a select on the "client" table and using the "client_id" directly.

    Can you please confirm that this would/could not work?

    Also, it is my understanding that the sys_userid is the "system id" of the person currently logged in.

    How would this work in the case of a remote user (since this is required to use the API to begin with) - or - am I missing something?

    TIA
     
  4. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    Thats absolutely ok and the preferred way.

    Thats correct too.

    All functions that get executed by a remote user have admin permissions. So basically the remote user is a ISPConfig administrator.

    The client_get_id function is used when you need to know which client owns a record. E.g. you querid ispconfig for a mail domain and you want to know the owner of that domain.
     
  5. dgmufasa

    dgmufasa New Member

    Is this something that would work to get the correct client_id? When querying direct from the DB, the other functionality is still not working -so - I am thinking of trying this approach.

    Can you confirm whether or not it would get the needed data?


    $record_record = $client->client_get_by_username($session_id, $username);

    $sysuserid = $record_record['userid'];

    $sys_userid = $sysuserid;

    $client_record = $client->client_get_id($session_id, $sys_userid);



    Also, I must have some kind of different version because I see:
    client_get
    client_get_by_username
    client_get_id
    client_get_sites_by_user
     
  6. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    Yes. But you can make the code more simple:

    $sys_user_record = $client->client_get_by_username($session_id, $username);
    $client_record = $client->client_get_id($session_id, $sys_user_record['userid']);
     

Share This Page