// // Make an interop call into UriMon // authModule and credential parameters are not considered // public virtual bool ShouldSendCredential(Uri challengeUri, WebRequest request, NetworkCredential credential, IAuthenticationModule authModule) { int pdwZone; _ManagerRef.MapUrlToZone(challengeUri.AbsoluteUri, out pdwZone, 0); return(pdwZone == URLZONE_INTRANET); }
public static bool IsDangerous(string filename) { try { // First check the zone, if they are not an untrusted zone, they aren't dangerous if (internetSecurityManager == null) { Type iismType = Type.GetTypeFromCLSID(new Guid(CLSID_InternetSecurityManager)); internetSecurityManager = (IInternetSecurityManager)Activator.CreateInstance(iismType); } int zone = 0; internetSecurityManager.MapUrlToZone(Path.GetFullPath(filename), out zone, 0); if (zone < ZoneInternet) { return(false); } // By default all file types that get here are considered dangerous return(true); } catch (COMException ex) when(ex.ErrorCode == REGDB_E_CLASSNOTREG) { // When the COM is missing(Class not registered error), it is in a locked down // version like Nano Server return(false); } }
public static bool IsDangerous(string filename) { // First check the zone, if they are not an untrusted zone, they aren't dangerous if (internetSecurityManager == null) { Type iismType = Type.GetTypeFromCLSID(new Guid(CLSID_InternetSecurityManager)); internetSecurityManager = (IInternetSecurityManager)Activator.CreateInstance(iismType); } int zone = 0; internetSecurityManager.MapUrlToZone(Path.GetFullPath(filename), out zone, 0); if (zone < ZoneInternet) { return(false); } // By default all file types that get here are considered dangerous return(true); }
public static string GetUrlZone(string url) { Type t = System.Type.GetTypeFromCLSID(_CLSID_SecurityManager); IInternetSecurityManager securityManager = (IInternetSecurityManager)System.Activator.CreateInstance(t); try { uint zone = 0; int hResult = securityManager.MapUrlToZone(url, ref zone, 0); if (hResult != 0) { throw new COMException("Error calling MapUrlToZone, HRESULT = " + hResult.ToString("x"), hResult); } if (zone < ZoneNames.Length) { return(ZoneNames[zone]); } return("Unknown - " + zone); } finally { Marshal.ReleaseComObject(securityManager); } }