Lawson authentication and AGS call from Classic ASP for LSF9.0

 4 Replies
 1 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
Samantha
New Member
Posts: 3
New Member
    We have the need to integrate one of our ASP applications with Lawson. and to do so we need to first authenticate to lawson portal and then make the AGS call. I was going thru the LSF9 document - "Doc for Developers: IOS Application Program Interfaces" chapter "Authenticating Programmatically to Lawson"... but it only explains how to do it for Java clients using lhc.jar. Since our app is a ASP app, we won't be able to use this method. Can anyone please share how to accomplish it in Classic ASP environment? Thanks.
    isln_boy
    Basic Member
    Posts: 8
    Basic Member
      You could post a URL to sign-in using the SSOServlet, then process the AGS call:

      https://WEB-SERVER/sso/SS...ansaction%2fErp.....
      Samantha
      New Member
      Posts: 3
      New Member
        Thanks for you reply. I believe we also need to get cookies from the server after call to SSO servet, correct? If you have already tried and if you have the entire code for the authentication and sample AGS call, if you could post it, that would really help. Thanks again.
        isln_boy
        Basic Member
        Posts: 8
        Basic Member
          Take a look at this thread for an example:

          https://www.lawsonguru.co...ft/2098/Default.aspx
          Josue Molina
          New Member
          Posts: 3
          New Member

            I was able to do it by parsing the VB code provided in the link above.

            Here's the C# (c sharp) version in case you need it. It works like a charm!

             

            HttpWebRequest LoginReq;
            HttpWebRequest mainReq;
            HttpWebResponse LoginResp;      
            HttpWebResponse mainResp; 
            NetworkCredential cred;
            CookieContainer cookies;
            StreamReader loginStream;
            StreamReader mainStream;
            StreamWriter postStream;
            XmlDocument xmlDoc; 
            string qryReturn;
            string postData;
            string LAWSON_UID = "xxxxxx";
            string LAWSON_PWD = "xxxxxx";

            cred = new NetworkCredential(LAWSON_UID, LAWSON_PWD); 
            LoginReq = (HttpWebRequest)WebRequest.Create("https://your-domain.com/lawson/portal/");
            LoginReq.Method = "GET";                
            LoginReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)";
            LoginResp = (HttpWebResponse)LoginReq.GetResponse();

            cookies = new CookieContainer();
            LoginReq.CookieContainer = cookies;
            LoginResp.Cookies = LoginReq.CookieContainer.GetCookies(LoginReq.RequestUri);                

            loginStream = new StreamReader(LoginResp.GetResponseStream());
            qryReturn = loginStream.ReadToEnd();

            mainReq = (HttpWebRequest)WebRequest.Create("https://your-domain.com/sso/SSOServlet");
            mainReq.Method = "POST";
            mainReq.ContentType = "application/x-www-form-urlencoded";
            mainReq.Credentials = cred;
            mainReq.PreAuthenticate = true;
            mainReq.Headers.Add(HttpRequestHeader.AcceptLanguage,"en-us"); 
            mainReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)";

            postData = "_ssoUser="+LAWSON_UID+"&_ssoPass="+LAWSON_PWD+"&_action=LOGIN&_ssoOrigUrl=your-url-encoded-ags-or-dme-call-full-path-including-http://...etc";
            mainReq.CookieContainer = cookies;
            mainReq.ContentLength = postData.Length;

            postStream = new StreamWriter(mainReq.GetRequestStream());
            postStream.Write(postData);
            postStream.Close();

            mainResp = (HttpWebResponse)mainReq.GetResponse();

            mainStream = new StreamReader(mainResp.GetResponseStream()); // load an XML doc with the returned data.
            qryReturn = mainStream.ReadToEnd();

            xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(qryReturn.ToString());