Requirement :- Login Customer community user into Salesforce using Partner WSDL.

I tried solution provided here and it works for customer community users for me using SOAP UI.

But when I used partner wsdl and the c# code shared in Salesforce examples for customer community users, I am getting error : An unexpected error has occurred: INVALID_LOGIN: Invalid username, password, security token; or user locked out.

The same code is working for Salesforce User license users, I am able to get session id for Salesforce user License successfully.

Is there any API login issue for customer community license?


I found the below solution which works for me.


  1. Clone customer community profile with restricted access (enabled API access)
  2. Create a new Customer community user with a new profile.
  3. Generate Partner WSDL and shared in C# project with org Id. (for C# project I have used Visual Studio 2013 tool)
  4. In C# code, Call Login Method in Partner.WSDL with customer community credentials and SFDC Organization Id.
  5. Retrieve session id and call customize REST/SOAP webservice or we can call query using query() function.

My C# code:

public bool login(){
// Web Reference to the imported Partner WSDL.
SforceService partnerBinding = new SforceService();

// To authenticate Self-Service users, we need to set the OrganizationId
// in the LoginScopeHeader.
string orgId = "Your Org Id";
partnerBinding.LoginScopeHeaderValue = new LoginScopeHeader();
partnerBinding.LoginScopeHeaderValue.organizationId = orgId;

String uname = "Customer Community Username";
String pwd = "Customer Community Password";
    System.Net.ServicePointManager.SecurityProtocol = (System.Net.SecurityProtocolType)3072;
    Console.WriteLine("\nLogging in...\n");
    LoginResult lr1 = partnerBinding.login(uname, pwd);
    // Set the returned service endpoint URL
    partnerBinding.Url = lr1.serverUrl;
    // Set the SOAP header with the session ID returned by
    // the login result. This will be included in all
    // API calls.
    partnerBinding.SessionHeaderValue = new SessionHeader();
    partnerBinding.SessionHeaderValue.sessionId = lr1.sessionId;
    Console.WriteLine("lr1.sessionId:- " + lr1.sessionId);
catch (SoapException e)

// Return true to indicate that we are logged in, pointed  
// at the right URL and have our security token in place.     
return true;


Copy and paste above code and run C# application and you will receive sessionid related to customer community user.

C# Code references: LoginScopeHeader

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.