function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JustinMcNally21JustinMcNally21 

INVALID_ID_FIELD: when running setPassword() after a new user is created.

I am trying to set the password of a newly created use via the API, I can create the user fine which returns the ID for the user record but when i run the SOAP call to set the user's password i get an invalid ID error. Any ideas?

 

 

SOAPAction: "setPassword", Content-Type: text/xml;charset=UTF-8
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:wsdl="urn:partner.soap.sforce.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ins0="urn:partner.soap.sforce.com"
 xmlns:ins1="urn:fault.partner.soap.sforce.com" xmlns:ins2="urn:sobject.partner.soap.sforce.com" xmlns:ns1="urn:partner.soap.sforce.com" xmlns:ns2="urn:partner.soap.sforce.com" x
mlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header><ns1:SessionHeader><ns2:sessionId>##REDACTED##</ns1:SessionHeader></env:Header><env:Body><ins0:setPassword><ins0:password
 xsi:nil="true"/><wsdl:userID>00530000004pWrD</wsdl:userID></ins0:setPassword></env:Body></env:Envelope>

SOAP response (status 500):
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.partner.soap.sforce.com" xmlns:xsi="http://w
ww.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>sf:INVALID_ID_FIELD</faultcode><faultstring>INVALID_ID_FIELD: invalid userId</faultstring><detail><sf:I
nvalidIdFault xsi:type="sf:InvalidIdFault"><sf:exceptionCode>INVALID_ID_FIELD</sf:exceptionCode><sf:exceptionMessage>invalid userId</sf:exceptionMessage></sf:InvalidIdFault></det
ail></soapenv:Fault></soapenv:Body></soapenv:Envelope>


JustinMcNally21JustinMcNally21

I found my issue i wasn't actually passing the password. Now its working yet the User cannot login with password after I create it. Logging in takes them to a change your password page. Is there a flag i can set so they can actually just login with the password.

dkadordkador

Does the user actually get a page that asks them to set their password is or is it a page asking them to reset their security question?

JustinMcNally21JustinMcNally21

So the page asks to reset password and security question. however the old password is the one i set with setPassword(). Basically i want to facilitate user account creation, because the app should be seemless (End user won't know about salesforce using the OAuth2 - Password flow).

dkadordkador

I believe if the user's never logged in before they're always going to be presented with the security question prompt.

 

Let me double check with some people.  I'll get back to you.

dkadordkador

Yes.  One improvement is to do an API login as the user you create.  Then when they log-in they'll only be asked to set their question / answer and not the password.  But that's still not seamless.

 

Have you looked into delegated auth?