0

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 = "/_layouts/SignOut.aspx";
                         }

                     },"jsonp");
                 }
             } catch (err) { }
         },
         error: function () {
         }
     });
Richa Jain
  • 641
  • 6
  • 19
  • And when the user disables javascript? You should authenticate on the web server side. – Esko Jul 08 '14 at 07:00
  • on login it should check ip and user. i have done it by jquery. but now to get ip it is giving error "Blocked loading mixed active content "http://ipinfo.io" – Richa Jain Jul 08 '14 at 07:06

1 Answers1

0

I find hard to believe that jquery (that runs on PC) gives web server's ip. I suggest you make a html page on you pc and run it. Are you sure it doesn't give proxy ip?

XristosK
  • 266
  • 4
  • 16