VMware {code} Community
adramirez
Contributor
Contributor
Jump to solution

How to get user fullname after login

Hello.

I'm trying to develop a simple web control pannel with readonly information from vCloud API.

I have been able to get information about Organizations, vApps, vDCs and VMs, but something as "simple" as getting the fullname of the user who logged in using vCloud API login process is being impossible for me. Smiley Sad

Please, can someone give me help on this subject?

I'm using vCloud API SDK for PHP, but I would appreciate any kind of information or instructions about how to get logged in user fullname.

Thanks in advance for you help.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
admin
Immortal
Immortal
Jump to solution

In order to be able to do this you will first need to log into the organization with "organization administrator" user and save the information about the users somewhere - in a database, or some kind of in-memory cache. You cannot get lots of information about a user with normal user.

To obtain the users info you need to get the "admin" representation of an organization.

GET https://<<cell-ip>>/api/v1.0/admin/org/<<orgID>>

When you make the request above in the response you will find a section

<Users>

     <UserReference type="application/vnd.vmware.admin.user+xml" name="name" href="<<user-href>>"/>

</Users>

After that you make a GET request for each user and read the information. Save it somewhere and use it later.

GET <<user-href>>

View solution in original post

0 Kudos
5 Replies
admin
Immortal
Immortal
Jump to solution

In order to be able to do this you will first need to log into the organization with "organization administrator" user and save the information about the users somewhere - in a database, or some kind of in-memory cache. You cannot get lots of information about a user with normal user.

To obtain the users info you need to get the "admin" representation of an organization.

GET https://<<cell-ip>>/api/v1.0/admin/org/<<orgID>>

When you make the request above in the response you will find a section

<Users>

     <UserReference type="application/vnd.vmware.admin.user+xml" name="name" href="<<user-href>>"/>

</Users>

After that you make a GET request for each user and read the information. Save it somewhere and use it later.

GET <<user-href>>

0 Kudos
adramirez
Contributor
Contributor
Jump to solution

Thanks for your help.

I knew I could get that user list, in the way you explain, but I thought there could be a more direct way to get current user info.

If there is no alternative I will use that and think about how to create a cache as you explain.

Regards.

0 Kudos
Todor_Todorov
Hot Shot
Hot Shot
Jump to solution

adramirez wrote:

Thanks for your help.

I knew I could get that user list, in the way you explain, but I thought there could be a more direct way to get current user info.

If there is no alternative I will use that and think about how to create a cache as you explain.

Regards.

Hi,

You can obtain information about the currently logged in user by using the <Session> object (available only in 1.5 version of the REST API).

GET-ting https://<<cell-ip>>/api/session returns a <Session> object which has 'user' and 'org' attributes containing the names of the currently logged in user and his/her organization. The only "problem" is that the 'user' attribute contains the user name instead of his/her full name. In order to get the full name you'll have to follow the procedure of listing all users in the organization, matching the name of the currently logged in user to its href and getting the full information about him/her.

Note: A faster way to get all users in the current organization together with their full names is by executing the query https://<<cell-ip>>/api/query?type=user - this returns an array of <UserRecord> elements with 'fullName' attribute. Note that this is also only available in the 1.5 version of the API.

Regards,

Todor Todorov

adramirez
Contributor
Contributor
Jump to solution

Hello.

I didn't know about that "session" object.

I'll check the API version in the system I'm working on and try to follow your instructions.

Thank you!

0 Kudos
jeyakarthika
Contributor
Contributor
Jump to solution

Hi,

         I have an vclod director 1.5 .

I tried this URL : https://<<cell-ip>>/api/session  from web browser then i got the below error

Unable to download session from <cell-ip>

Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.

How to resolve this? or how to get the user session details using vcloud java sdk 1.5.

When i check the java api  there is a class as SessionType. But i cant able to get the instance of the class. If anyone knows please help me.

Thanks

Karthika

0 Kudos