VMware Cloud Community
carl1
Expert
Expert
Jump to solution

requesting user in vro custom input

I am trying to create a vRA XaaS service that puts the user account that requested the service on a drop-down menu.  This is of course part of a much larger plan.  This is just testing how to get the user account data on that menu.

So, I created an action

pastedImage_0.png

---------------------------------------  Code ------------------------------------------------

var ans = ["fooy"];

var tenant;

var name;

try {

    tenant = vCACCAFEHost.tenant;

    name =  System.getContext().getParameter("__asd_requestedBy");

} catch (e) {

    ans = ["Exception", e];

}

ans = [ "testing", "tenant:" + tenant, "Req by:" + requestedBy, "Name:" + name, "done"];

return ans;

-----------------------------------------------------

Then I created a vRO Workflow for vRA to call

pastedImage_1.png

-----------------------------------------------------------------

Then create and run the XaaS blueprint.

But when I run it, All I get is

pastedImage_2.png

What am I missing here.  How do I get the account of the user requesting this blueprint on this menu?

The entire system is vRA 6.2.2 and vRO 6.,0.3

Thanks all,

Carl L.

    tenant = vCACCAFEHost.tenant;

0 Kudos
1 Solution

Accepted Solutions
jasnyder
Hot Shot
Hot Shot
Jump to solution

Carl - that's what I told you to do.  You said you didn't want to change it on hundreds of blueprints.

This is where I told you to do that:

You could take the same value and wire it to RequestedBy input on the action you're already calling.  It would look something like this (mapping external value parameter inputs):

pastedImage_2.png

View solution in original post

0 Kudos
9 Replies
jasnyder
Hot Shot
Hot Shot
Jump to solution

So I can't remember if vRA 6.x had this in there, but you can try linking an input to the action to the PrincipalID from vRA.  I have an example of this on an XaaS blueprint form which calls a vRO workflow that uses their ID to do some work.  The form looks like this in vRA 7.2:

pastedImage_0.png

If you make a request for this item in the catalog, the form is displayed like this (the input is constrained to that value):

pastedImage_1.png

You could take the same value and wire it to RequestedBy input on the action you're already calling.  It would look something like this (mapping external value parameter inputs):

pastedImage_2.png

I have several 6.x environments in my lab, but none of them are booted at the moment so I couldn't easily check to see if this was there in 6.2.2.  Hopefully you could use this approach.

iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

1) You get tenant:undefined, because in the expression tenant = vCACCAFEHost.tenant; vCACCAFEHost is a scripting object type, not an object instance, and retrieving tenant runtime value from a type does not make sense. You need to obtain an instance of vCACCAFEHost, and then you will be able to retrieve the tenant property value.

2) You get Name:null, because context parameters like __asd_requestedBy are available in the runtime context when you execute a workflow, not when you execute a presentation (I'm not 100% sure about this, though, so you may want to get a confirmation from someone more familiar with vRA internals).

carl1
Expert
Expert
Jump to solution

Thanks to both.

Ilian:

This is how I got the instance but not sure where to go from here to get the user.  But tenant does now get a value.  Thanks so much!

    var host = vCACCAFEEntitiesFinder.getHost("abc-123-456-def");
    tenant = host.tenant;

Now returns the tenant but I am not really any closer to figuring out how to get the user account.  I had a look at host.createAuthenticationClient() but that seems more for checking a user that you already know.  I need to know the user that is calling me. 

Justin:

I would really like to avoid the option you gave as that would require several hundred blueprints to be altered in a non-standard way.  That is, all the current service blueprints get their values from vRO.  In this case, I would need to make sure all the values were set from vRA.  Doable, just a pain.

Thanks again to you both for the quick response.

Ilian, good suggestion:  I will post to the vRA group and see if someone over there has any idea's.

Carl L.

    var host = vCACCAFEEntitiesFinder.getHost("d1a45031-e74f-4db6-ba8a-20a7c2a3f221");
    tenant = host.tenant;

0 Kudos
jasnyder
Hot Shot
Hot Shot
Jump to solution

Well, give this one a shot - it works in vRA 7.2/vRO 7.2, so I assume it will in 6.x.

var username = Server.getCurrentLdapUser().userPrincipalName;

0 Kudos
carl1
Expert
Expert
Jump to solution

That returns the user that vRO is using to login to vRA with.  I am looking for the real user, not the service account.

Thanks,
Carl L.

0 Kudos
jasnyder
Hot Shot
Hot Shot
Jump to solution

OK, then it must not work in 6.x because in 7, it returns the vRA user making the request.  This is from an XaaS blueprint form in vRA 7.2 catalog:

pastedImage_0.png

The first entry on the list = Server.getCurrentLdapUser().userPrincipalName.  The remaining items are built from Server.getCurrentLdapUser().allGroups, which is a list of all groups the user is a member of.

The user listed in my screenshot is the vRA logged in user, not the service account connecting to the embedded vRO server.

If I had to guess why it's different in 6 vs. 7, I would say either because of the Horizon Identitity manager integration vs. SSO identity appliance integration in 6; or if you're using an external vRO server (as was recommended in 6.x) it could be due to the authentication scheme used on the vRO server not being federated with vRA's SSO.  At this point I can't remember if an external vRO 6.x appliance had an option to integrate with an SSO domain/vRA instance, so it's just a guess.

0 Kudos
carl1
Expert
Expert
Jump to solution

Found the answer.  Thought I would put it here in case anyone else looks for how to do it.

pastedImage_0.pngpastedImage_0.png

The secret was to use the "Values" tab in vRA  (not presentation in vRO) and have the action that generates the list of values take one parameter (in my case "requestedBy") and then pass the vRA principal as the value for that argument.

0 Kudos
jasnyder
Hot Shot
Hot Shot
Jump to solution

Carl - that's what I told you to do.  You said you didn't want to change it on hundreds of blueprints.

This is where I told you to do that:

You could take the same value and wire it to RequestedBy input on the action you're already calling.  It would look something like this (mapping external value parameter inputs):

pastedImage_2.png

0 Kudos
carl1
Expert
Expert
Jump to solution

And that was my bad.  I thought you were tying it to another field, not setting an input value for the vRO workflow.

Thanks so much!

I marked you as correct so you get the points!

Carl L.

0 Kudos