We are using vSphere web client SDK 6.0 (HTML bridge) and trying to retrieve session with com.vmware.vise.usersession.UserSessionService.getUserSession().
for JAVA code you can refer vsphere-wssdk example from vsphere-client-sdk\html-bridge\samples.
After injecting UserSessionService interface in class VmDataProviderImpl, it will return proxy object of UserSessionService and _userSessionService.getUserSession() always returns null.
How will we get current logged in user session of vSphere web client with vim25.
Please advise.
Hi Denis,
First up all, thanks to you for showing interest in assisting us.
This issue is fixed now.
Actually, when we developed any plugin for vCenter, we need to perform authentication with the help of .html pages.
In my case, I was trying to retrieve current user session before authentication of .html page. Hence we were getting userSessionService.getUserSession() as null.
Thanks once again.
Hi,
Can you provide more information about where and when are you calling the _userSessionService.getUserSession().
It is possible that you are calling the method too early when there is no active user session.
I have tested it on our sample "vsphere-wssdk" and everything works as expected.
You can have a look at the code of "vsphere-wssdk" sample from 6.5 Update 1 SDK (html-client-sdk) for any clues.
Regards,
Denis
Hi Denis,
First up all, thanks to you for showing interest in assisting us.
This issue is fixed now.
Actually, when we developed any plugin for vCenter, we need to perform authentication with the help of .html pages.
In my case, I was trying to retrieve current user session before authentication of .html page. Hence we were getting userSessionService.getUserSession() as null.
Thanks once again.
Hi,
can you please elaborate on this statement : Actually, when we developed any plugin for vCenter, we need to perform authentication with the help of .html pages.
If possible give a small code snippet explaining the same ? i am also facing the same problem with a NetApp plugin called SCV.
[2020-09-22T11:37:56.433Z] [INFO ] http-bio-5090-exec-40925 com.vmware.vsphere.client.security.util.Util getUserSession called on an inactive session.
[2020-09-22T11:37:56.433Z] [ERROR] http-bio-5090-exec-40925 com.netapp.scv.summary.controllers.SummaryController Error in getJobStatusCounts: User Session has timed out. Please login again to the vSphere Web Client.
[2020-09-22T11:37:56.433Z] [INFO ] http-bio-5090-exec-40821 com.vmware.vsphere.client.security.util.Util getUserSession called on an inactive session.
[2020-09-22T11:37:56.433Z] [ERROR] http-bio-5090-exec-40821 System.err com.netapp.nvpf.api.model.ApiException: User Session has timed out. Please login again to the vSphere Web Client.
Thanks and Regards.