Login SAP WebUI without opening browser

875 views Asked by At

I'm trying to do a little "performance Test" for SAP CRM WebUI. Therefore I have to sign in several times with different users from a C# programm. The HTTP-traffic will be tracked by fidllercore.dll.

Now, my problem is even after two days of research I am not able to automatically sign in to the SAP CRM WebUI. If I open a link via HttpWebRequest and submit my username and password, the response stream contains only the LogOn-Html.

I remember there should be way to sign in via SSO2-Cookies, but I couldn't find nothing in particular about this. That's pretty close to what i've done yet: How to make my web scraper log in to this website via C#

Request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), Request);

private static void GetRequestStreamCallback(IAsyncResult result)
{
    if (result != null)
    {
        //Removed password from code!
        String data = "&sap-user=******&sap-password=**********";
        HttpWebRequest request = (HttpWebRequest)result.AsyncState;

        // End the operation
        System.IO.Stream newStream = request.EndGetRequestStream(result);

        // Convert the string into a byte array.
        byte[] dataStream = Encoding.UTF8.GetBytes(data);

        // Write to the request stream.
        newStream.Write(dataStream, 0, dataStream.Length);
        newStream.Close();
        
        //Thread.Sleep(5000);
        request.BeginGetResponse(new AsyncCallback(FinishWebRequest), request);
    }
}
1

There are 1 answers

0
Tim_Staat On BEST ANSWER

Finally fount this.

I had to perform an GET-Request with the parameters &sap-user=****&sap-password=***. It is important to set them in the right order, as you can see following the link above.

Thanks!

Edit: Due to SAP-CRM-WEB-UI sends redirect and Cookies all in same request and HttpWebRequest ignores these Cookies for redirect, you have to handle this nanually (like explained here).