Internet Explorer authentication of a REST with domain\username

1k Views Asked by At

I have a working javascript/jQuery REST app with the webtrends' exctraction API, with the exception of IE.

I am sending authentication via SSL - https://[domainname]\[username]:[password]@ws.webtrends.com/v3/Reporting/profiles/10609/Keymetrics/?start_period=current_day-1&end_period=current_day&period_type=agg&format=json

When I look inside of Developer Tools (F12) > under the Network tab, Internet Explorer changes the backslash('\') to a forward slash ('/'), which results in the browser looking for a web site with the value of the domainname.

All other browsers do NOT change the backslash.

    $.ajaxSetup({
        crossDomain: true,
        async: false,
        contentType: "application/jsonp",
        dataType: "jsonp",
        type: "POST",
        cache: false,
        beforeSend: function(xhr) {
          xhr.overrideMimeType("application/jsonp; charset=UTF-8");
        },
        headers: {
            "Authorization": mBaseSixtyFourVar
        },
        url: mXferObj.mUrl
    });

    $.ajax({ 
        success: function(mInfo){        
            mRecvObj = mInfo;
            alert(mRecvObj.data[0].measures.NewVisitors+"");
        },
        error: function (xmlHttpRequest, textStatus, errorThrown) {
            alert("xmlHttpRequest.readyState: "+xmlHttpRequest.readyState+", textStatus: "+textStatus+", errorThrown: "+errorThrown+", mXferObj.mUrl: "+mXferObj.mUrl);
        }
    });

I have tried the following:

Inserting this into the ajaxsetup

data: "{'domain':'domainname','username':'blabla','password':'blabla'}",

With PHP, I have tried using curl, but nothing returned except bool(false):

I tried file_get_contents() but I received open stream errors.

I have this working in FireFox, Opera, Safari, Chrome - why is IE always the hold up to perfection?

Any help would be appreciated and thanks in advance

As requested, here is ONE of the curL codes that I have tried:

if (!function_exists('curl_init')){ 
    die('CURL is not installed!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $Url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
var_dump $output;

I have tried the options:

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt(CURLOPT_USERPWD, '[username]:[password]') 

So many different things that I have tried, that was the last

1

There are 1 best solutions below

3
On

UPDATE

Given your comment about supplying username and password in an XMLHTTPRequest, I did some research and found that jQuery does support this functionality. All you should have to do is add the username and password parameters to your request:

$.ajaxSetup({
    crossDomain: true,
    async: false,
    contentType: "application/jsonp",
    dataType: "jsonp",
    type: "POST",
    cache: false,
    beforeSend: function(xhr) {
      xhr.overrideMimeType("application/jsonp; charset=UTF-8");
    },
    headers: {
        "Authorization": mBaseSixtyFourVar
    },
    url: mXferObj.mUrl,
    username: "yourUsername",
    password: "yourPassword"
});

Original Answer

Simply put, Internet Explorer does NOT support this functionality. It was removed in a previous security update released in 2004:

http://support.microsoft.com/kb/834489

By default, versions of Windows Internet Explorer that were released starting with the release of security update 832894 do not support handling user names and passwords in HTTP and HTTP with Secure Sockets Layer (SSL) or HTTPS URLs. The following URL syntax is not supported in Internet Explorer or in Windows Explorer: http(s)://username:password@server/resource.ext

Alternatives may include making an AJAX request to your own server, and then once on the server side, perform the request in managed code. For example, if your language of choice is C#, you can use an HttpWebRequest and provide the proper NetworkCredentials information to complete the request.