Jquery Get Local pc ip address and check administrator

Tuesday, July 8, 2014

in my organization all http sites are blocked and i want ip address and to check administrator if not then logout in sharepoint. I am using http://ipinfo.io to fetch ip address. but now this is blocked and when i am using https://ipinfo.io it is giving me server ip not my local pc ip. Any help would be appreciated.



var IPCollections = "192.168.1.29"; // Add ips here
$.ajax
({
url: "/_api/web/CurrentUser?$select=Title",
method: "GET",
async: false,
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data) {
try {
if (data.d.Title == "superuser" || data.d.Title == "Super Admin") {
$.get("http://ipinfo.io", function (response) {
var Ip = response.ip;
console.log(Ip);
var arrycoll = IPCollections.split(',');
var keeplogin = false;
for (var i = 0; i < arrycoll.length; i++) {

if (Ip == arrycoll[i]) {
keeplogin = true;
}
}
if (!keeplogin) {
window.location.href="http://ift.tt/1xKJyDO";
}

},"jsonp");
}
} catch (err) { }
},
error: function () {
}
});






http://ift.tt/1jjV320