trailx
Enthusiast
Enthusiast

How to retrieve list of all users in your Cloud ?

Jump to solution

Hello,

I use the REST API VMware vCloud Director 1.5 and I am faced with a problem.

I want to list all the users of a specific organization from the admin account (system organization).

Is it possible?

with GET /admin/users/query ?

Operation:
GET /admin/users/query
Description:
Retrieves a list of users for organization the org admin belongs to by using REST API general QueryHandler; If filter is provided it will be applied to the corresponding result set. Format determines the elements representation - references or records. Default format is references.

Thank you in advance,

--- If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!
0 Kudos
1 Solution

Accepted Solutions
rkamal
VMware Employee
VMware Employee

Hi,

https://vcloud/api/query?type=adminUser - lists all users in all orgs.

https://vcloud/api/query?type=adminUser&filter=org=={orghref} - lists users of the specififed org.

orghref = https://vcloud/api/org/a93c9db9-7471-3192-8d09-a8f7eeda85f9 The organizations href for which you need to filter the users for.

Regards,

Rajesh Kamal.

View solution in original post

0 Kudos
9 Replies
rkamal
VMware Employee
VMware Employee

Hi,

You can use the "adminUser" query and do a filter onto the org.

Ex: https://vcloud/api/query?type=adminUser&filter=org==https://vcloud/api/org/a93c9db9-7471-3192-8d09-a...

Regards,
Rajesh Kamal.

0 Kudos
trailx
Enthusiast
Enthusiast

Hum,

I don't understand how to do this...

I'm login to REST API with org=system login=admin pwd=*
After that, I send a socket to https://<ip>/api/admin/users/query this is already an admin operation as u know.

If i follow u idea, should i replace my HTTPS socket by https://<ip>/api/admin/users/query?type=admin&filter=<org_target_id> ?

thks

--- If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!
0 Kudos
rkamal
VMware Employee
VMware Employee

Hi,

https://vcloud/api/query?type=adminUser - lists all users in all orgs.

https://vcloud/api/query?type=adminUser&filter=org=={orghref} - lists users of the specififed org.

orghref = https://vcloud/api/org/a93c9db9-7471-3192-8d09-a8f7eeda85f9 The organizations href for which you need to filter the users for.

Regards,

Rajesh Kamal.

View solution in original post

0 Kudos
trailx
Enthusiast
Enthusiast

Hi Rajesh,

That's exactly what i need, thank you.

--- If you found this information useful, please consider awarding points for "Correct" or "Helpful". Thanks!
0 Kudos
LovingIt
Contributor
Contributor

Do I understand correctly ?

You say that passing this string

https://vcloud/api/query?type=adminUser&filter=org=={https://vcloud/api/org/a93c9db9-7471-3192-8d09-a8f7eeda85f9}

will only get users for that specified organisation ?

I have tried a number of conbinations like

https://vcloud/api/query?type=adminUser&filter=org=={https://vcloud/api/org/a93c9db9-7471-3192-8d09-a8f7eeda85f9}

https://vcloud/api/query?type=adminUser&filter=org==https://vcloud/api/org/a93c9db9-7471-3192-8d09-a...

https://vcloud/api/query?type=adminUser&filter=org=={a93c9db9-7471-3192-8d09-a8f7eeda85f9}

none of these - it keeps returning ALL users.

It seems as if everything in the string after the & is ignored ?

...OR ...

is it a case of returning all users above the structure as well ie ALL System users as well as the Organisation Specific users ?

0 Kudos
Todor_Todorov
Hot Shot
Hot Shot

Hi,

This variant: https://vcloud/api/query?type=adminUser&filter=org==https://vcloud/api/org/a93c9db9-7471-3192-8d09-a...

works on my vCD 1.5 instance. Can you double check that you're properly passing the organization href?

Regards,

Todor Todorov

0 Kudos
LovingIt
Contributor
Contributor

Hi, thank you for the quick response

I am using this string

https://xxx.xxxxxx.xxx/api/query?type=adminUser&filter=org==https://xxx.xxxxxx.xxx/api/org/aaaaaaaa-...

and I have checked and double checked that the org_id matches the href returned from orgList in fact I programmatically extract it - but to make sure I echo it to the screen - and compared it to the value returned.

I have also tried filtering on filter=name==test-user ... still returned ALL users.

Very peculiar - I also tried entering some invalid info like filter=lkdjflasj dflaj dflkaj sdf

Still returned all records.

I found this reference as well ... http://blogs.vmware.com/vsphere/2012/04/quickly-finding-objects-using-the-vcloud-api-query-service.h...

They use ( and ) for the filter - however if I put that in - I get 'a blank page returned to me.

0 Kudos
MayaIlieva
VMware Employee
VMware Employee

Hi LovingIt,

what you have tried should work. I tested it in my vCD 1.5 test environment.

1.There are 14 users in total.

GET https://cloud/api/query?type=adminUser&fields=name,org

<?xml version="1.0" encoding="UTF-8"?>
<QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="14" pageSize="25" page="1" name="adminUser" type="application/vnd.vmware.vcloud.query.records+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=records&fields=name,org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://cloud/api/v1.5/schema/master.xsd">
    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=references&fields=name,org"/>
    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.idrecords+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=idrecords&fields=name,org"/>
    <AdminUserRecord org="https://cloud/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" name="catalogcreator" href="https://cloud/api/admin/user/1086bfea-15b3-4b07-9b6e-d0bbafe9c879"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="orgadmin" href="https://cloud/api/admin/user/25c3450b-b02f-4658-b731-78726017d4f1"/>
    <AdminUserRecord org="https://cloud/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" name="orgadmin" href="https://cloud/api/admin/user/2b07e05c-f322-462a-af74-163780076d93"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="tgeorgiev" href="https://cloud/api/admin/user/4b392183-c1e5-4e05-bce7-6ebb790c981f"/>
    <AdminUserRecord org="https://cloud/api/org/a93c9db9-7471-3192-8d09-a8f7eeda85f9" name="vadmin" href="https://cloud/api/admin/user/5ce898ff-2f91-4818-a704-53c20116ad70"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="vanya" href="https://cloud/api/admin/user/6038f7ad-2861-44fa-80af-e3fa3d0ecfe8"/>
    <AdminUserRecord org="https://cloud/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" name="catalogauthor" href="https://cloud/api/admin/user/98f10e7e-35d5-4542-a5ee-4565ccb68243"/>
    <AdminUserRecord org="https://cloud/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" name="vappauthor" href="https://cloud/api/admin/user/9d834502-def8-4c1e-b281-68f7ddd8b16c"/>
    <AdminUserRecord org="https://cloud/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" name="vappowner" href="https://cloud/api/admin/user/b42c3a03-4b1e-4bff-a749-c91165011612"/>
    <AdminUserRecord org="https://cloud/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" name="vappuser" href="https://cloud/api/admin/user/c159f469-eb9e-4a43-b46e-743894ba58f7"/>
    <AdminUserRecord org="https://cloud/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" name="viewonly" href="https://cloud/api/admin/user/c27c2445-6a33-4920-8103-86a1da152a9b"/>
    <AdminUserRecord org="https://cloud/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" name="user" href="https://cloud/api/admin/user/d3f7c9d9-b720-403d-a9a1-60bc26c053d5"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="administrator" href="https://cloud/api/admin/user/dbe6aa65-b761-4fa6-93c9-213bf548be7a"/>
    <AdminUserRecord org="https://cloud/api/org/73ab2eb6-802b-46a6-8a3d-e55a0a99a957" name="consoleaccess" href="https://cloud/api/admin/user/ebb2da83-b8ab-4c6b-a9ed-f527b577aa56"/>
</QueryResultRecords>

2. Adding filtering to get users from org with uuid=ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63:


GET https://cloud/api/query?type=adminUser&fields=name,org&filter=org==https://cloud/api/org/ec1fa8d3-ff...

<?xml version="1.0" encoding="UTF-8"?>
<QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="4" pageSize="25" page="1" name="adminUser" type="application/vnd.vmware.vcloud.query.records+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=records&filter=org==https://cloud/a..." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://cloud/api/v1.5/schema/master.xsd">
    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=references&filter=org==https://clou..."/>
    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.idrecords+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=idrecords&filter=org==https://cloud..."/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="orgadmin" href="https://cloud/api/admin/user/25c3450b-b02f-4658-b731-78726017d4f1"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="tgeorgiev" href="https://cloud/api/admin/user/4b392183-c1e5-4e05-bce7-6ebb790c981f"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="vanya" href="https://cloud/api/admin/user/6038f7ad-2861-44fa-80af-e3fa3d0ecfe8"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="administrator" href="https://cloud/api/admin/user/dbe6aa65-b761-4fa6-93c9-213bf548be7a"/>
</QueryResultRecords>

3. Use in the filter only the org uuid as shown bellow:


GET https://cloud/api/query?type=adminUser&fields=name,org&filter=org==ec1fa8d3-ff98-4479-87d9-fb0c6f3bb...

<?xml version="1.0" encoding="UTF-8"?>
<QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="4" pageSize="25" page="1" name="adminUser" type="application/vnd.vmware.vcloud.query.records+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=records&filter=org==ec1fa8d3-ff98-4..." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://cloud/api/v1.5/schema/master.xsd">
    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=references&filter=org==ec1fa8d3-ff9..."/>
    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.idrecords+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=idrecords&filter=org==ec1fa8d3-ff98..."/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="orgadmin" href="https://cloud/api/admin/user/25c3450b-b02f-4658-b731-78726017d4f1"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="tgeorgiev" href="https://cloud/api/admin/user/4b392183-c1e5-4e05-bce7-6ebb790c981f"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="vanya" href="https://cloud/api/admin/user/6038f7ad-2861-44fa-80af-e3fa3d0ecfe8"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="administrator" href="https://cloud/api/admin/user/dbe6aa65-b761-4fa6-93c9-213bf548be7a"/>
</QueryResultRecords>

4. Add additional filter to get users from org you want AND have name that contains "admin"

GET https://cloud/api/query?type=adminUser&fields=name,org&filter=org==ec1fa8d3-ff98-4479-87d9-fb0c6f3bb...

<?xml version="1.0" encoding="UTF-8"?>
<QueryResultRecords xmlns="http://www.vmware.com/vcloud/v1.5" total="2" pageSize="25" page="1" name="adminUser" type="application/vnd.vmware.vcloud.query.records+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=records&filter=org==ec1fa8d3-ff98-4..." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://cloud/api/v1.5/schema/master.xsd">
    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.references+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=references&filter=org==ec1fa8d3-ff9..."/>
    <Link rel="alternate" type="application/vnd.vmware.vcloud.query.idrecords+xml" href="https://cloud/api/query?type=adminUser&page=1&pageSize=25&format=idrecords&filter=org==ec1fa8d3-ff98..."/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="orgadmin" href="https://cloud/api/admin/user/25c3450b-b02f-4658-b731-78726017d4f1"/>
    <AdminUserRecord org="https://cloud/api/org/ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63" name="administrator" href="https://cloud/api/admin/user/dbe6aa65-b761-4fa6-93c9-213bf548be7a"/>
</QueryResultRecords>

5. The filters below are equivalent to those in 4.


GET https://cloud/api/query?type=adminUser&fields=name,org&filter=(org==ec1fa8d3-ff98-4479-87d9-fb0c6f3b...)
GET https://cloud/api/query?type=adminUser&fields=name,org&filter=(org==ec1fa8d3-ff98-4479-87d9-fb0c6f3b...)

If you still have problems with that aftre trying the simple filter org==ec1fa8d3-ff98-4479-87d9-fb0c6f3bba63,

then I can suggest to provide me temporarily access to your environment.


Good luck!

Maya

0 Kudos
LovingIt
Contributor
Contributor

Excellent --- thank you very much

My problem was the & - becasue I am using command line cURL I had to escape it - therefore

type=adminUser\&fields=name,org\&filter=org==xxxxx

Thanks again !

Regards

0 Kudos