Returns the security zone identifier for the specified resource.
Returns a SecurityZone enumeration which identifies the origin of the local file.
This method is used to determine how a resource should be handled in terms of local security policy before performing a file transfer. For example, you may want to determine whether a resource originates from the Internet or local intranet before deciding whether to attach zone metadata, prompt the user, or apply additional security restrictions. It can also be used to implement policy-based rules for accepting or rejecting downloads based on their origin.
If the resource is specified using a file:// URL that refers to a file on a network share (e.g.: file://server/share/file.txt), the method will attempt to access that file across the network. This may cause the application to block while Windows resolves the hostname and establishes a connection to the shared volume. If the network share is unavailable or slow to respond, the method may block until the connection succeeds or the attempt times out.
If this method returns SecurityZone.None, this indicates either the resource type is not supported or there was an internal failure when the Internet Security Manager attempted to map the resource URL to a security zone. In most default configurations, this method will return the zone SecurityZone.Internet for valid URLs unless the host has been explicitly added to the Intranet Zone or Trusted Sites list on the local system.
It is important to note that this method is used to determine what security zone would be appropriate for a given resource, and it only performs syntactic checks and classification of the URL using the IInternetSecurityManager COM interface. The security zone this method returns is based on the current system and user policy, using zone assignments stored in the registry. Typically this information is managed using Windows settings or Internet options in the control panel. This method does not read the zone identifier metadata which has been assigned to a file.