1. Jim Reese
  2. PowerBuilder
  3. Monday, 28 November 2022 14:13 PM UTC

Preparing to migrate our app to PB 2022, rewriting code using the discontinued SOAPConnection to use HTTPClient object.  Existing code uses conn.useintegratedwindowsauthentication(true) to connect with integrated windows authentication.

How can this be implemented via HTTPClient, which according to the documentation, says: "PowerBuilder supports the Basic HTTP authentication theme (see Example 2 (using HTTPClient)), and does not support the following HTTP authentication themes: Digest, NTLM, Passport, and Negotiate." 

Is there a way to use integrated windows authentication with the HTTPClient object? If not, how can we migrate our code if that is the only way the service supports authentication?

Who is viewing this page
Accepted Answer
Jim Reese Accepted Answer Pending Moderation
  1. Wednesday, 8 February 2023 14:19 PM UTC
  2. PowerBuilder
  3. # Permalink

I have downloaded the 30 day trial of ChilKat, and successfully converted one of our existing SoapConnection methods. I found these examples from ChilKat helpful, used some code from both, along with code I already wrote using PBDOM to generate the Soap Request.

https://www.example-code.com/powerbuilder/http_windows_integrated_authentication.asp

https://www.example-code.com/powerbuilder/soap_webservice_requiring_auth.asp

Here is a snippet, in case anyone else is interested: ...

oleobject loo_Http //http://www.chilkatsoft.com/refdoc/xChilkatHttpRef.html

oleobject loo_Resp //http://www.chilkatsoft.com/refdoc/xChilkatHttpResponseRef.html

...

ls_XML_to_send = ldom_doc.savedocumentintostring( ) //get request xml string from PBDOM, built outside of this snippet

loo_Http = create oleobject

li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http") //used instead of HTTPClient since HTTPClient doesn't support windows integrated authentication

IF li_rc < 0 THEN

destroy loo_Http

ls_msg = "Connecting to COM object failed"

Exit

END IF

// Setting the HTTP Login equal to the empty string, and the Password equal to the keyword "default"

// will cause Chilkat to use the Microsoft SSPI w/ integrated authentication.

loo_Http.Login = ""

loo_Http.Password = "default"

//explicitly indicate that NTLM or Negotiate authentication is to be used:

loo_Http.NegotiateAuth = 1

// Set the Content-Type of the request.

loo_Http.SetRequestHeader("Content-Type","text/xml")

// Send the request...

loo_Resp = loo_Http.PostXml(ls_url,ls_XML_to_send,"utf-8")

IF loo_Http.LastMethodSuccess <> 1 THEN

ls_msg = loo_Http.LastErrorText

destroy loo_Http

EXIT

END IF

li_StatusCode = loo_Resp.StatusCode

IF li_StatusCode = 200 THEN

//good return code

ELSE

ls_msg = "Bad Status returned from the SSCT service: "+string(li_StatusCode)+": "+ loo_Resp.StatusText

Exit

END IF

ls_returned_XML = loo_Resp.BodyStr

//ls_returned_XML is the response back that needs to be parsed for content ...

//Use PBDOM to process the returned XML string

Comment
There are no comments made yet.
Tom Derutter Accepted Answer Pending Moderation
  1. Tuesday, 19 September 2023 14:17 PM UTC
  2. PowerBuilder
  3. # 1

We are having the same issue.

 

We're now migrating to PB2022 R2.

SOAPConnection is discontinued, so we rewrote all code that used this.

However, we have 1 webservice (that we made almost 10 years ago) where we also used conn.useintegratedwindowsauthentication(true)

 

As I understand, now we should be using https://docs.appeon.com/pb2022r2/powerscript_reference/setCredentials_func.html

Sets the authentication credentials. Assuming that an acceptable authentication scheme and credentials are already known or obtained (for example, via getsupportscheme), this function sends the authentication credential to the server or proxy before sending requests to the server.

 

I'm confused about how to use this.

Does anyone have a working example?

What are the parameters to simulate the exact same behaviour as useintegratedwindowsauthentication(true)?

 

If I read the description, I'm supposed to know the logged in user's name & password?

What's the difference with using scheme "0 -- Automatic authentication (Automatically use one of the following five authentication schemes)" and calling getsupportscheme to know what scheme to use?

 

(What's the expected 'OK' return value for this function? It's not described.

If I try this function with SetCredentials(false, 0, '', ''), it returns -1. What does this return value mean?)

Comment
  1. Logan Liu @Appeon
  2. Wednesday, 20 September 2023 05:05 AM UTC
Hi Tom, authentication using the Windows default credentials (don't need to enter user and password) in an HTTP request hasn't been supported.

If you want this feature, we suggest that you submit an enhancement ticket on our support portal (at https://www.appeon.com/standardsupport). This way, our product team will analyze this request when they plan to extend PB functions in the future.

Regards, Logan
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 28 November 2022 17:46 PM UTC
  2. PowerBuilder
  3. # 2

Hi Jim;

  I hope that this thread might help ...

https://community.appeon.com/index.php/qna/q-a/httpclient-authorization

Regards ... Chris 

Comment
  1. Chris Pollach @Appeon
  2. Wednesday, 30 November 2022 18:07 PM UTC
Hi Jim;

Thank you for sharing!

Regards ... Chris
  1. Helpful
  1. Shannon Axon
  2. Tuesday, 13 June 2023 13:52 PM UTC
Hi Armeen,

I've been trying to figure out if the new MR for PB has included a fix for this so that we do not need to get 3rd party software. Do you have any updates or suggestions in regards to this since what i see here from last November? Thanks!
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 13 June 2023 16:26 PM UTC
Hi Shannon;

Suggestion: I would give the PB2022 R2 beta a try & see if that works for your requirement ...

FYI: https://docs.appeon.com/pb2022r2/powerscript_reference/setCredentials_func.html

Regards ... Chris
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.