I am trying to create a web page using javscript that uses form based authentication to login to the sharepoint server but it keeps using NTLM which is windows based authentication. Is there anyway to allow form based authentication using javascript as this web page is for mobile and phonegap? Thanks in advance. Any help appreciated.
My code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
</head>
<body>
<div>
<script type="text/javascript">
$(document).ready(function () {
var soapEnv = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> \
<soap:Body> \
<Login xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<username>username1</username> \
<password>password</password> \
</Login> \
</soap:Body> \
</soap:Envelope>"
// Call web service
$.ajax({
url: "http://servername:serverport/_vti_bin/authentication.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processListAccessResult,
contentType: "text/xml; charset=\"utf-8\""
});
});
// Process result
function processListAccessResult(xData, status) {
alert(xData);
alert(status);
}
</script>
<ul id="data"></ul>
</div>
</body>
</html>
I had the same problem (401 unauthorized), took me ages to realize that it works like a charm once you downgrade your jQuery version. I now use jQuery 1.4.4. Maybe some higher version also works but I haven't tried this yet. Anyway, 1.4.4 should do the trick. Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With