Reply to Message

View discussion in a popup

Replying to:
doskiran
Enthusiast
Enthusiast

Use vSphere SOAP-based (vSphere Management SDK) APIs to get the API sessions.

API: SessionManager 

sessionList*UserSession[]

The list of currently active sessions.

 

To get your API sessions, compare the client machine's IP address and application name with the IpAddress and UserAgent of the UserSession object.

 

Sample code:

 

	public void printUserSessions(String vCenterServer, String userName, String password) {
		try {
			si = new ServiceInstance(new URL("https://" + vCenterServer + "/sdk"), userName, password, false);
			SessionManager sm = si.getSessionManager();
			UserSession[] usList = sm.getSessionList();
			for (UserSession us : usList) {
				System.out.println("Client IPAddress::" + us.getIpAddress());
				System.out.println("Session Username::" + us.getUserName());
				System.out.println("Application/UserAgent::" + us.getUserAgent());
				System.out.println("--------------------------------------------------");
			}
		} catch (Exception e) {
			System.err.println("Error ServiceInstance::" + e.getLocalizedMessage());
		}
	}

 

 

 

Reply
0 Kudos