Forum Discussion

Billy's avatar
Billy
Comet
4 months ago
Solved

API Request to get all SDP users

Hi everyone,

I'm trying to get all users within my Cato platform. Like in Access > Users when you select SDP Users Activity. 

 

I cannot find any direct way to do it, maybe i'm missing something ?

I tried with AccountSnapshot but here you can only find connected users, it is also stated that if I want users that are offline I need to specify the ID, is it the only way to do it ? 

Thanks,

Billy

  • Hi Billy,

    Take a look at the entityLookup. I was able to view our SDP users with it.

    query: "query GetVpnUsers($accountID: ID!, $limit: Int = 25, $from: Int = 0) {
      entityLookup(
        accountID: $accountID,
        type: vpnUser, 
        limit: $limit,
        from: $from
      ) {
        items {
          entity {
            id
            name
            type
          }
         description
        }
        total
      }
    }"
    variables: "{
        "accountID": "12345"
    }"

     

  • Hi Billy,

    Take a look at the entityLookup. I was able to view our SDP users with it.

    query: "query GetVpnUsers($accountID: ID!, $limit: Int = 25, $from: Int = 0) {
      entityLookup(
        accountID: $accountID,
        type: vpnUser, 
        limit: $limit,
        from: $from
      ) {
        items {
          entity {
            id
            name
            type
          }
         description
        }
        total
      }
    }"
    variables: "{
        "accountID": "12345"
    }"

     

    • Billy's avatar
      Billy
      Comet

      Hi JessieBryan,

      Thanks a lot! It worked very well.

       

    • Brian-Anderson's avatar
      Brian-Anderson
      Icon for Cato Employee rankCato Employee

      Hi, 

      Exactly right, the entityLookup gets you the data you are looking for.  Also, I recommend running the api explorer app (dockerized app available on github), which helps you easily generate queries for any of the latest APIs from with all of the parameters presented in easy to use HTML elements.

      https://github.com/catonetworks/cato-api-explorer

       

      • BennettCarter's avatar
        BennettCarter
        Comet

        Hello Brian

        I have an issue similar to what Billy had. I am trying to retrieve a list of all users  including their last connected datetime, which doesnt seem to be included in the results for entity lookup. I do get this field from accountSnapshot, but that only returns a list of users that are currently connected, I need all of them. 

        I am trying to retrieve all user ids via entity lookup and then pass them to the accountSnapshot since you can get non connected users by specifying their ids. Do you have any suggestions on how to adjust my qu

        Query = $@"
           {{
               accountSnapshot(accountID:  {accountId}, userIDs: {userIds}]) {{
                   id
                   timestamp
                   users {{
                       id
                       name
                       deviceName
                       uptime
                       lastConnected
                       version
                       versionNumber
                       popName
                       osType
                       osVersion
                       connectedInOffice
                       info {{
                           name
                           status
                           email
                           creationTime
                           phoneNumber
                           origin
                           authMethod
                       }}
                   }}
               }}
           }}"