Use Javascript to check if client has added the domain as a Trusted Site

I need a way to check, using Javascript, if the user has added the domain as a Trusted Site.

We sell different kinds of content management tools and similar products to our customers. To be able to guarantee it's functionality, we require, among other things, that the domain that the CMS is installed on, has been added as a trusted site. At the login prompt we need a way to check if it has been added as a trusted site and if not, display a warning.

I haven't been able to come up with a good solution to this yet. Anyone know if it can be done



Answer this question

Use Javascript to check if client has added the domain as a Trusted Site

  • Jim CaJacob

    I'm also looking for something similar. I want to be able to check if someone has already added a domain to the trusted sites list. If it doesn't exist then the site would be added automatically. Has anyone found something for this
  • Camilo Andres Soto Montoya

    <script type="text/javascript">
    var protocoltxt = document.location.protocol.substring(0,document.location.protocol.length -1);
    var TrustSiteStatus="Untrusted site";
    if (isValidIPAddress(document.location.host))
    {
    var WRT = new ActiveXObject("WScript.Shell");
    var tmpcheck=1;
    var bKey;
    for (tmpi=1;tmpcheck;tmpi++ )
    {
    try{
    bKey = WRT.RegRead("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range" + tmpi + "\\:Range");

    if (document.location.host == bKey)
    {
    try{
    bKey = WRT.RegRead("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range" + tmpi + "\\" + protocoltxt );
    TrustSiteStatus = "Already in Tursted site";
    } catch(Exception) {
    tmpcheck = 0;
    }
    tmpcheck = 0;
    }
    } catch(Exception) {
    tmpcheck = 0;
    }
    }
    }else{
    var splithosttxt = document.location.host.split(".");
    if (splithosttxt.length > 3)
    {
    var domaintxt = splithosttxt[splithosttxt.length -2] + "." + splithosttxt[splithosttxt.length -1] ;
    var subdomaintxt = splithosttxt[0];
    for(tmpi=1;tmpi < (splithosttxt.length - 2);tmpi++)
    subdomaintxt += "." + splithosttxt[tmpi];

    var WRT = new ActiveXObject("WScript.Shell");
    try{
    var bKey = WRT.RegRead("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\" +domaintxt + "\\" + subdomaintxt + "\\" + protocoltxt);
    TrustSiteStatus = "Already in Tursted site";
    } catch(Exception) {
    }
    }
    }
    document.write("Site: " + document.location.protocol+"//"+document.location.host + " " + TrustSiteStatus);

    function isValidIPAddress(ipaddr) {
    var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
    if (re.test(ipaddr)) {
    var parts = ipaddr.split(".");
    if (parseInt(parseFloat(parts[0])) == 0) { return false; }
    for (var i=0; i<parts.length; i++) {
    if (parseInt(parseFloat(partsIdea)) > 255) { return false; }
    }
    return true;
    } else {
    return false;
    }
    }

    </script>



  • Haero

    Hi:

    I need to get client PC's camera and sound driver, which can help me to stream contents on web using ASP.Net.

    Can you provide me some info regarding that

    Regards,
    Rajat Dasgupta
    MarketRaise Corp.



  • Rabinarayan

    Indeed I am having a very similar problem. Upon login I would like to find out if the domain is in the clients trusted sites (I don't need to be able to add it, just detect it) and also check if their IE settings contain Check For Newer Version of Stored Pages - On Every Visit to the Page.

    Either Javascript or VBScript will be fine, I just need to find some way of doing it. Without getting the settings correct, the client side application performs pretty bizarrely; but with potentially 100's of users it's impossible to to make sure they all have the correct IE settings.


  • Use Javascript to check if client has added the domain as a Trusted Site