SocketTools .NET Edition

FileTransfer.GetSecurityZone Method 

Returns the security zone identifier for the specified resource.

[Visual Basic]
Public Function GetSecurityZone( _
   ByVal fileUrl As String _
) As SecurityZone
[C#]
public SecurityZone GetSecurityZone(
   string fileUrl
);

Parameters

fileUrl
A string that specifies the resource URL to check. This parameter must be either a valid FTP or HTTP URL, or a local file URL. While this method does not verify that the resource exists, it does require the URL to be syntactically valid. If the host name cannot be resolved to an IPv4 or IPv6 address, the method will return SecurityZone.None. If the resource is a local file, it must be a regular file and cannot be the name of a folder or device.

Return Value

Returns a SecurityZone enumeration which identifies the origin of the local file.

Remarks

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.

See Also