PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08/12/2015 2:31 PM by  Josue Molina
Lawson authentication and AGS call from Classic ASP for LSF9.0
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages
Samantha
developer
aviall
New Member
(5 points)
New Member
Posts:3


Send Message:

--
11/16/2010 8:26 PM
    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
    Private
    Private
    Basic Member
    (24 points)
    Basic Member
    Posts:8


    Send Message:

    --
    11/17/2010 1:55 PM
    You could post a URL to sign-in using the SSOServlet, then process the AGS call:

    https://WEB-SERVER/sso/SSOServlet?_action=LOGIN&_ssoUser=USER&_ssoPass=PASSWORD&_ssoOrigUrl=https%3%2f%2fWEB-SERVER%2fservlet%2fRouter%2fTransaction%2fErp.....
    Samantha
    developer
    aviall
    New Member
    (5 points)
    New Member
    Posts:3


    Send Message:

    --
    11/17/2010 2:50 PM
    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
    Private
    Private
    Basic Member
    (24 points)
    Basic Member
    Posts:8


    Send Message:

    --
    11/17/2010 4:44 PM
    Take a look at this thread for an example:

    https://www.lawsonguru.com/Forums/tabid/96/aft/2098/Default.aspx
    Josue Molina
    ERP
    Private
    New Member
    (5 points)
    New Member
    Posts:3


    Send Message:

    --
    08/12/2015 2:31 PM

    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());

    You are not authorized to post a reply.