Get UserId from the Session Id and Server URL

a 夏天 提交于 2019-12-14 03:27:05

问题


I have a requirement, where I will be getting the Session Id and Server URL(parameters of a webservice method).

Say like this:

Session ID : 00D900000xxxxxx!ARUAQOb4VVoQR1UXlY_Hvuy1DdKdN6nSfnNJKYwPTF9R3tYuA2jzBsWXHIGDQUFL13iebnYSDKKC45H98TzVxxxxxxxxxx

Server URL : https://ap1.salesforce.com/services/Soap/u/12.0/00D900000xxxxxx

Now i need to get the User Id(or any other user details) from these two.

Thanks in Advance!!

Nitin


回答1:


You could use the SOAP API, which has a GetUserInfo method. Calling this method will return a GetUserInfoResult object, which will contain the user ID associated to the session.




回答2:


Adam, GetUserInfo method requires existing connection object which we can create by calling method, so I applied the following code and now everything works fine!

ConnectorConfig config = new ConnectorConfig(); config.setAuthEndpoint("https://login.salesforce.com/services/Soap/c/24.0/"); config.setServiceEndpoint("https://na14.salesforce.com/services/Soap/c/24.0/00DXXXXXXXXXXXX"); config.setSessionId("00DXXXXXXXXXXXX!1AQ4AQO980Fmu25SOFQxxOlQN8zAaHOlnfdk._rZU2Vkf_CV0HJREqKavMLaPg9jtA9N517MNHLdLeF.aVkoZtnk2eu7u.XNn"); connection = new EnterpriseConnection(config); GetUserInfoResult userInfo = connection.getUserInfo();

I used the same server URL and sessionId that I have received from query parameter string.



来源:https://stackoverflow.com/questions/13133651/get-userid-from-the-session-id-and-server-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!