-2

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

bsnitin
  • 1
  • 1
  • 1

2 Answers2

2

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.

Adam Butler
  • 2,733
  • 23
  • 27
1

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.

Vardan Gupta
  • 3,505
  • 5
  • 31
  • 40
  • You could delete the whole answer then. But your code is still an useful sample and is a valid answer so why don't you edit it? Just remove the error and say "... and make sure the SessionId you're passing is not URLencoded" or something :) – eyescream Nov 07 '12 at 15:00
  • Cool, first time I'm downvoting a question and upvoting an answer (downvoting because I'm afraid it's an attempt to capture values from cookies or sth like that and hijack session information). – eyescream Nov 07 '12 at 17:10