CFtpClient::SetDefaultZoneId Method  
 
BOOL SetDefaultZoneId(
  DWORD dwZoneId  
);

The SetDefaultZoneId method sets the default security zone for downloaded files.

Parameters

dwZoneId
An unsigned integer which specifies the default security zone identifier. It may be one of the following values:
Value Description
SECURITY_ZONE_NONE The file does not have a zone identifier associated with it. This typically indicates that the file was created locally or has not been marked by Windows as originating from another zone. This is the default behavior if the application does not explicitly set a default security zone.
SECURITY_ZONE_LOCAL The file is considered to be part of the Local Machine zone, which includes files stored on the user's local system or removable media. This zone has the least restrictive security settings, and files are typically allowed to run without prompting or limitation. This zone should not be assigned to downloaded files, as doing so can bypass security mechanisms designed to protect against potentially harmful content. Only use this setting for files that are created locally by the application itself and are known to be safe. Misuse of this setting can result in a significant security risk, especially if the file contains scripts, executables, or other active content.
SECURITY_ZONE_INTRANET The file originates from the Local Intranet zone, which includes content served from internal network resources, such as shared drives, file servers, and internal web applications. This zone typically has fewer security restrictions than the Internet zone but more than the Local Machine zone. It is commonly used in enterprise environments where network resources are managed and considered relatively safe. This zone should not be used for files downloaded from the public Internet, as doing so may incorrectly signal that the file is trusted within the organization. Assign this zone only to files that are retrieved from authenticated internal sources or known secure locations on the local network.
SECURITY_ZONE_TRUSTED The file is from a site or source explicitly added to the Trusted Sites zone in Internet Explorer or Windows security settings. This zone is intended for domains or locations that the user or system administrator considers to be safe, such as internal applications hosted on the public Internet or third-party services with a strong reputation for safety. Files marked with this zone typically bypass certain security checks, and applications may allow active content (such as scripts or macros) to run without prompting. Use caution when assigning this zone to downloaded files, as it may override protections that would otherwise apply to untrusted content.
SECURITY_ZONE_INTERNET The file was downloaded from the Internet zone, which represents untrusted or unknown sources outside the local network. This is the standard zone identifier automatically applied by web browsers, email clients, and many applications when a file is downloaded from a public website or external server. Windows uses this zone to enforce security restrictions, such as prompting the user before executing scripts, blocking active content, or displaying a warning when the file is opened. This is typically the appropriate zone to assign for any file obtained over FTP from an external site. Assigning this zone helps ensure that users are notified before opening potentially unsafe content, in accordance with Windows Attachment Manager and Group Policy settings.
SECURITY_ZONE_RESTRICTED The file is associated with the Restricted Sites zone, which enforces the strictest security policies. This zone is used for content that is explicitly marked as untrusted or potentially harmful. Files tagged with this zone may be blocked from execution, prevent active content from running, or trigger warnings when accessed. Assigning this zone can be useful for sandboxing unverified downloads or limiting the risk from files obtained from questionable sources. However, it may also cause legitimate files to fail to open or operate with reduced functionality depending on system policy and application behavior.

Return Value

If the method succeeds, the return value is non-zero. If the method fails it will return zero. To get extended error information, call the GetLastError method.

Remarks

The SetDefaultZoneId method sets the default security zone identifier that will be applied to all files downloaded during the client session. This setting controls how Windows treats downloaded files with respect to security prompts and content execution restrictions. Once the default zone ID is set, it will be automatically applied to all subsequent file downloads performed by the client session. This eliminates the need to manually set the security zone for each individual file, ensuring consistent zone tagging across the session.

When SECURITY_ZONE_NONE is specified, no Zone.Identifier alternate data stream is created. This causes the file to be treated as if it originated from the local system, and Windows will not apply zone-based security restrictions. This is the default behavior which maintains backwards compatibility with previous versions of the library that did not create the security zone metadata for files.

The zone ID metadata is interpreted by Windows components such as Attachment Execution Services and SmartScreen to determine whether the user should be warned when opening a file. In enterprise environments, Group Policy settings may alter how different zone IDs are handled, such as blocking scripts, macros, or unsigned executables. Developers should test zone assignment behavior in target environments when distributing files to end users.

Note that this method does not retroactively modify existing files. The default zone identifier is applied only at the time a file is downloaded using methods such as DownloadFile.

If your application is distributed in a controlled environment, such as a corporate network with endpoint protection or user access controls, consult your organization's security policy before modifying default zone behavior. Improper zone tagging can impact file access, generate security prompts, or interfere with digital signature enforcement.

Be aware that some file operations (such as extracting from a ZIP archive, or copying files to non-NTFS volumes or across certain network shares) may strip the Zone.Identifier metadata. Developers should not rely solely on zone tagging as a persistent trust mechanism outside of the initial download context.

To get the security zone identifier for a local file, use the GetFileZoneInfo method. To change or remove the security zone information for a file, use the SetFileZoneInfo method.

Caution Assigning SECURITY_ZONE_LOCAL as the default security zone identifier for downloaded files is strongly discouraged. This zone disables key Windows security features and can expose users to significant risk. This security zone should only be used with files that are generated locally by the application and are guaranteed to be safe. Never assign this zone to content obtained from the Internet or other untrusted sources.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csftpv12.lib

See Also