[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Basic Authentication - Windows Sharepoint server



Richard,

Actually there is nothing special with calling a web service with NTLM authentication because the interesting stuff happens under the cover.

The attached sample shows how to GET a web page. Just replace http_url_get() with http_url_post_xml() and you can call a web service.

Today using a persistent connection is not possible because there is no "persist" equivalent to http_url_post_xml(). Maybe I should add that to my patch or wait until Scott is back and discuss that with him.

Regards,

Thomas.


Am 13.02.2013 19:22, schrieb Richard Schoen:
Congrats Patrick.

In regards to authenticating every time.  I would think that would be necessary as HTTPAPI is doing a stateless transaction whereas a browser would hold session state on the MS Sharepoint server.

Would love to see your RPG sample code if you're will to post here or email me a sample.

We are starting to expose more and more Sharepoint and ASP.Net services to the web and currently we use REST most of the time, but a web service example with NTLM would be cool to see.

Regards,
Richard Schoen
RJS Software Systems Inc.
Where Information Meets Innovation
Document Management, Workflow, Report Delivery, Forms and Business Intelligence
Email: richard@xxxxxxxxxxxxxxx
Web Site: http://www.rjssoftware.com
Tel: (952) 736-5800
Fax: (952) 736-5801
Toll Free: (888) RJSSOFT

------------------------------

Message: 3
Date: Wed, 13 Feb 2013 16:02:12 +0000
From: Patrick Goovaerts <p.goovaerts@xxxxxxxxxxxxxxxxxxxxxx>
To: "ftpapi@xxxxxxxxxxxxxxxxxxxxxx" <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: SV: Basic Authentication - Windows Sharepoint server
	(solved)
Message-ID:
	<F821B9E810A4774F884929492CAA7CD32D5116FF@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
	
Content-Type: text/plain; charset="us-ascii"

Huraay, Huraay, It's a holi- holiday...

Problem solved.  As from now on, I'm able to connect our AS400 with Sharepoint with WebServices!
It seems that after a get, the connection is lost and I have to re-authenticate again.

So, in general the solution to my problem:

1) Install HTTPAPI 1.25beta
2) Install WSDL2RPG with NTLM fix fix HTTPAPI
3) take very good care with upper/lowercase on domain/userid/password
4) authenticate BEFORE EVERY connection attempt (request webpage or execute soaprequest)
     (or use http_persist_open(URL))

Thanks Thomas, thanks Scott!


Patrick Goovaerts
Systems & Development



-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------

      * EXAMPLE25:                                                                            RADDAT
      * ----------
      * This example shows how to GET a web page that is hosted                               RADDAT
      * by your IIS on your remote desktop PC. The authentication                             RADDAT
      * mechanism used is NTLM, which is the default for IIS                                  RADDAT
      * servers.                                                                              RADDAT
      *                                                                                       RADDAT
      * The HTTP APIs used by the program are:                                                RADDAT
      *    http_url_get()                                                                     RADDAT
      *    http_getauth()                                                                     RADDAT
      *    http_setauth()                                                                     RADDAT
      *
      *
     H DFTACTGRP(*NO) BNDDIR('HTTPAPI') ACTGRP(*NEW)                                          RADDAT

      /copy qrpglesrc,httpapi_h
                                                                                              RADDAT
     D Job_getTcpIpAddr...                                                                    RADDAT
     D                 PR            15A          varying                                     RADDAT

      * Note: The BNDDIR, above, tells ILE how to find the HTTPAPIR4
      *       service program which contains the routines.
      *       The /COPY directive provides prototypes and constants
      *       needed to call the routines.
                                                                                              RADDAT
     D example25       PR                  extpgm('EXAMPLE25')                                RADDAT
     D  i_user                       32A   const                                              RADDAT
     D  i_password                   32A   const                                              RADDAT
                                                                                              RADDAT
     D example25       PI                                                                     RADDAT
     D  i_user                       32A   const                                              RADDAT
     D  i_password                   32A   const                                              RADDAT

     D rc              s             10I 0
     D err             S             10I 0 inz                                                RADDAT
     D msg             s             52A
     D URL             S            300A    varying
     D IFS             S            256A    varying
                                                                                              RADDAT
     D Basic           S              1N    inz(*Off)                                         RADDAT
     D Digest          S              1N    inz(*Off)                                         RADDAT
     D Realm           S            124A    inz                                               RADDAT
     D user            S                    like(i_user     ) inz('Donald')                   RADDAT
     D password        S                    like(i_password ) inz('TheSecret')                RADDAT
      /free
                                                                                            //RADDAT
         if (%parms() >= 2);                                                                //RADDAT
            user = i_user;                                                                  //RADDAT
            password = i_password;                                                          //RADDAT
         endif;                                                                             //RADDAT

         // ********************************************************                        //RADDAT
         //  Turning on debugging.                                                          //RADDAT
         //                                                                                 //RADDAT
         //     Calling http_debug and passing *ON will turn on                             //RADDAT
         //     HTTPAPI's debugging support.  It will write a debug                         //RADDAT
         //     log file to the IFS in /tmp/httpapi_debug.txt                               //RADDAT
         //     with loads of tech info about the HTTP transaction.                         //RADDAT
         //                                                                                 //RADDAT
         //     The debug file is crucial if you have problems!                             //RADDAT
         // ********************************************************                        //RADDAT
         // http_debug(*ON);                                                                //RADDAT
         http_debug(*ON: '/home/raddatz/httpapi_example25.log');                            //RADDAT


         // ********************************************************                        //RADDAT
         //  Setting a proxy (if you need it|)                                              //RADDAT
         // ********************************************************                        //RADDAT
         // Some corporate networks require you to send HTTP requests                       //RADDAT
         // through a proxy server (and some do not!) If yours does,                        //RADDAT
         // you'll need to uncomment these lines and set the right                          //RADDAT
         // proxy for your network:                                                         //RADDAT
                                                                                            //RADDAT
         // http_setproxy( 'your.proxy.com': 8080);                                         //RADDAT

         //  If you use a corporate proxy, and it requires a userid/password                //RADDAT
         //  you'll have to uncomment the following and set the user/pass                   //RADDAT
         //  accordingly.                                                                   //RADDAT
         //                                                                                 //RADDAT
         //  http_proxy_setauth( HTTP_AUTH_BASIC: 'userid': 'password' );                   //RADDAT
         //                                                                                 //RADDAT

         // More proxy notes:                                                               //RADDAT
         //    -- proxy is only required if your network requires it.                       //RADDAT
         //    -- user/pass is only required if your network requires it,                   //RADDAT
         //         (you can use a proxy without a user/password by leaving                 //RADDAT
         //             http_proxy_setauth() commented out...)                              //RADDAT
         //    -- The parameters for the preceding routines can be set with                 //RADDAT
         //         variables in place of the constants if you prefer.                      //RADDAT
         //         it's up to you.                                                         //RADDAT


         // ********************************************************                        //RADDAT
         //   What do I want to get?   Where should I put it?                               //RADDAT
         // ********************************************************                        //RADDAT
         // The URL points to a place on the IIS on your remote                             //RADDAT
         //   desktop PC.                                                                   //RADDAT
         // The IFS variable tells HTTPAPI where to put it on your                          //RADDAT
         //   local i5 computer.                                                            //RADDAT

         URL = 'http://' + Job_getTcpIpAddr() + '/index.html';                              //RADDAT
                                                                                            //RADDAT
         IFS = '/home/raddatz/httpapi_example25.html';                                      //RADDAT

         // Now call HTTPAPI's "GET" routine.  Pass the above                               //RADDAT
         //  variables as parameters.  It'll download it to the IFS                         //RADDAT
         //                                                                                 //RADDAT
         rc = http_url_get(URL: IFS);                                                       //RADDAT
                                                                                            //RADDAT
         if (rc <> 1);                                                                      //RADDAT
            http_error(err);                                                                //RADDAT
            if (err = HTTP_NDAUTH);                                                         //RADDAT
               if (http_getauth(basic: digest: realm) = 0);                                 //RADDAT
                  http_setauth(HTTP_AUTH_NTLM: user: password);                             //RADDAT
                  rc = http_url_get(URL: IFS);                                              //RADDAT
               endif;                                                                       //RADDAT
                                                                                            //RADDAT
            endif;                                                                          //RADDAT
         endif;                                                                             //RADDAT

         // ********************************************************                        //RADDAT
         //  Error handling...                                                              //RADDAT
         //                                                                                 //RADDAT
         //  http_url_get() returns 1 when successful.                                      //RADDAT
         //                                                                                 //RADDAT
         //  if it's unsuccessful, you can call the http_error()                            //RADDAT
         //  routine to learn what went wrong.  In this example,                            //RADDAT
         //  the error is put in the 'msg' variable.  You would                             //RADDAT
         //  then add code to display it to a user, or write it                             //RADDAT
         //  to a log file, or whatever is appropriate.                                     //RADDAT
         // ********************************************************                        //RADDAT

         if (rc <> 1);                                                                      //RADDAT
            msg = http_error;                                                               //RADDAT
         endif;                                                                             //RADDAT
                                                                                            //RADDAT
         *inlr = *on;                                                                       //RADDAT
      /end-free
                                                                                              RADDAT
      *===============================================================*                       RADDAT
      *  Returns the IP address of the 5250 client of the                                     RADDAT
      *  specified job.                                                                       RADDAT
      *===============================================================*                       RADDAT
     P Job_getTcpIpAddr...                                                                    RADDAT
     P                 B                   export                                             RADDAT
     D                 PI            15A          varying                                     RADDAT
      *                                                                                       RADDAT
      *  Retrieve Job Information (QUSRJOBI) API                                              RADDAT
     D QUSRJOBI...                                                                            RADDAT
     D                 PR                  extpgm('QUSRJOBI')                                 RADDAT
     D  o_rcvVar                  65535A          options(*varsize)                           RADDAT
     D  i_rcvVarLen                  10I 0 const                                              RADDAT
     D  i_format                      8A   const                                              RADDAT
     D  i_qJob                       26A   const                                              RADDAT
     D  i_intJobID                   16A   const                                              RADDAT
     D  io_errCode                65535A          options(*nopass: *varsize)    OptGrp 1      RADDAT
     D  i_resPrfStat                  1A   const  options(*nopass)              OptGrp 2      RADDAT
      *                                                                                       RADDAT
     D qJob            DS                  qualified                                          RADDAT
     D  name                         10A   inz('*')                                           RADDAT
     D  user                         10A   inz                                                RADDAT
     D  nbr                           6A   inz                                                RADDAT
      *                                                                                       RADDAT
     D jobi0600        DS                  qualified                                          RADDAT
     D  jobType               61     61A                                                      RADDAT
     D  jobSubType            62     62A                                                      RADDAT
     D  device               127    136A                                                      RADDAT
      *                                                                                       RADDAT
      *  Retrieve Device Description (QDCRDEVD) API                                           RADDAT
     D QDCRDEVD...                                                                            RADDAT
     D                 PR                         extpgm('QDCRDEVD')                          RADDAT
     D  o_rcvVar                  65535A          options(*varsize)                           RADDAT
     D  i_lenRcvVar                  10I 0 const                                              RADDAT
     D  i_format                      8A   const                                              RADDAT
     D  i_devName                    10A   const                                              RADDAT
     D  io_errCode                65535A          options(*varsize)                           RADDAT
                                                                                              RADDAT
     D devd0600        DS          1024    qualified                                          RADDAT
     D  tcpIpDotAddr         878    892A                                                      RADDAT
                                                                                              RADDAT
     D errCode         DS                  inz                                                RADDAT
     D  bytPrv                       10I 0                                                    RADDAT
     D  bytAvl                       10I 0                                                    RADDAT
      * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -                         RADDAT
      /FREE
         QUSRJOBI(jobi0600:%size(jobi0600):'JOBI0600':qJob:'':errCode);                     //RADDAT
         QDCRDEVD(devd0600:%size(devd0600):'DEVD0600':jobi0600.device:errCode);             //RADDAT
         return %trim(devd0600.tcpIpDotAddr);                                               //RADDAT
      /END-FREE
     P                 E                                                                      RADDAT
                                                                                              RADDAT
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------