I have created a Web Service and made an Ajax call to verify that user has access to Active Directory. It is working when we access through intranet but i am getting an error when the site is accessed through web. Here is my code snippet:
jQuery.support.cors = true;
$("#dialog-form").dialog({
autoOpen: false,
height: 330,
width: 380,
cache: false,
modal: true,
buttons: {
"Authenticate": function () {
var bValid = true;
allFields.removeClass("ui-state-error");
bValid = bValid && checkLength(name, "Username", 1, 30);
if (!LoginUserCheck(name.val()) && bValid) {
updateTips("The Username entered here should match with Username used for logging into the system");
}
bValid = bValid && checkLength(password, "Password", 1, 30);
bValid = bValid && LoginUserCheck(name.val());
if (bValid) {
var dataString = "{'username':'" + name.val() + "' ,password: '" + password.val() + "'}";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://192.168.12.186:5327/LDAPService.asmx/LADPAuthenticationCheck",
data: dataString,
dataType: "json",
beforeSend: function (xhr) { xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); },
success: function (msg) {
if (msg.d) {
$("#dialog-form").dialog("close");
$("#dialog").dialog("open");
// alert("MSG :" + msg.d);
}
else {
updateTips("Incorrect Username/Password");
}
},
error: function (jqXHR, textStatus, errorThrown) {
// $("#dialog").dialog("open");
alert("Error: " + errorThrown + " Please try to login with some other's system.");
}
});
}
},
Cancel: function () {
$("#dialog-form").dialog("close");
$('#<%= hdnCancel.ClientID %>').trigger("click");
}
},
close: function () {
allFields.val("").removeClass("ui-state-error");
}
});
$('#<%= hdnTriggerDialog.ClientID %>').click(function () {
$("#dialog-form").dialog("open");
});
});
I am doubting that cross domain fails when the site is accessed via Web. Can Anyone please help me to fix it?
Thanks - Ragu