I have an OL3 webmap that is attempting to access services from Geoserver that is running on a server on our internal network that uses LDAP logins using windows credentials. I found this link (Accessing secure Geoserver layer with username password) and this link (https://stackoverflow.com/questions/10950747/authenticate-in-geoserver-with-asp-net-and-iis/13123640#13123640) and tried both but it is not resolving the 401 error issue.
This is the code I have from the second link:
//login function
function login (options) {
// url del servlet del geoserver
var url = options.server + "/geoserver/j_spring_security_check";
// parametros para el login
params = "username=" + options["user"] + "&password="
+ options["password"];
var contentType = "application/x-www-form-urlencoded";
//se inicializa la petición ajax
var ajax = $.ajax({
data : params,
type : "POST",
contentType : contentType,
url : url
});
// se ejecuta cuando la peticion finaliza
ajax.done(function() {
if ($.cookie("JSESSIONID") != null && options && options.success) {
options.success();
}
});
// si ocurrio un error al realizar la peticion
ajax.fail(function(data) {
if (options && options.failure) {
options.failure(data);
}
});
// se ejecuta siempre al final de la petición, sin importar que esta
// haya fallado
ajax.always(function() {
if (options && options.always) {
options.always();
}
});
};
var un = prompt("enter your username","");
var pw = prompt("enter your password","");
login({
user: un, //geoserver user
password: pw,
server : "http://(host server here):8080", //geoserver host
success : function(){
alert("Login OK!");
},
failure : function(){
alert("Login fail!");
}
});
Also, if I log into the geoserver admin webpage in a separate tab, I can then open the webmapping application with no issue. I would like to ideally remove this step by putting in the geoserver login into the actual webpage (and preferably not store the login credentials anywhere for security purposes).