4.3 Creating a New Zone

The following example specifies how to create a new primary zone named "example.com". This zone will be stored in a file (and not in the directory).

The client formats a DNSSRV_RPC_UNION structure to represent the request:

  • The ZoneCreate member of the DNSSRV_RPC_UNION is set to point to a DNS_RPC_ZONE_CREATE_INFO (section 2.2.5.2.7) structure (stored on the stack or elsewhere). The entire structure is zeroed out prior to use.

  • The pszZoneName of this DNS_RPC_ZONE_CREATE_INFO structure is set to "example.com".

  • The dwZoneType member of this DNS_RPC_ZONE_CREATE_INFO structure is set to DNS_ZONE_TYPE_PRIMARY.

The client calls R_DnssrvOperation2 and provides the following parameters:

  • DNS_RPC_CURRENT_CLIENT_VER (section 2.2.1.2.1) as the client version.

  • Zero as the settings flag.

  • A Unicode string containing the FQDN of the DNS server on which the zone is to be created.

  • NULL as the zone name.

  • Zero as the context.

  •  "ZoneCreate" as the operation.

  • DNSSRV_TYPEID_ZONE_CREATE as the type ID.

  • A pointer to the DNSSRV_RPC_UNION structure created above as the RPC data.

The DNS server will return ERROR_SUCCESS if the operation was successful or a Windows 32 error code if the operation failed.