コード例 #1
0
ファイル: Zone.cs プロジェクト: sethuit/MSDNSWebAdmin
        /// <summary>
        /// changes the type of a zone.
        /// </summary>
        /// <param name="zoneType">Type of zone</param>
        /// <param name="dataFileName">Optional - Name of the data file associated with the zone.</param>
        /// <param name="ipAddr">Optional - IP address of the mater DNS Server for the zone.</param>
        /// <param name="adminEmailName">Optional - Email address of the administrator responsible for the zone.</param>
        public Zone ChangeZoneType(ZoneTypeCreate zoneType, string dataFileName, string[] ipAddr,
                                   string adminEmailName)
        {
            ManagementBaseObject inParams = m_mo.GetMethodParameters("ChangeZoneType");

            inParams["ZoneType"] = (UInt32)zoneType;

            if (!string.IsNullOrEmpty(dataFileName))
            {
                inParams["DataFileName"] = dataFileName;
            }

            if (ipAddr != null)
            {
                inParams["IpAddr"] = ipAddr;
            }
            else if (((ipAddr == null) || (ipAddr.Length == 0)) && (zoneType != ZoneTypeCreate.Primary))
            {
                throw new ArgumentException("ipAddr must contain at least one address");
            }

            if ((this.ZoneType == ZoneTypeEnum.Stub) && (zoneType == ZoneTypeCreate.Primary))
            {
                throw new ArgumentException("Unable to change from Stub to Primary, change to secondary first");
            }

            if ((zoneType == ZoneTypeCreate.Primary) && (string.IsNullOrEmpty(this.DataFile)) && (string.IsNullOrEmpty(dataFileName)))
            {
                throw new ArgumentException("Primary zone needs a filename");
            }

            if (!string.IsNullOrEmpty(adminEmailName))
            {
                inParams["AdminEmailName"] = adminEmailName;
            }

            //ChangeZoneType not acting as documented in
            //http://msdn.microsoft.com/en-us/library/windows/desktop/ms682759(v=vs.85).aspx
            try
            {
                m_mo.InvokeMethod("ChangeZoneType", inParams, null);//["RR"].ToString()

                return(new Zone(new ManagementObject(m_mo.Scope, new ManagementPath(m_mo.ToString()), null)));
            }
            catch (ManagementException me)
            {
                throw new WMIException(me);
            }
        }
コード例 #2
0
ファイル: Zone.cs プロジェクト: sethuit/MSDNSWebAdmin
        /// <summary>
        /// creates a DNS zone.
        /// </summary>
        /// <param name="server">a Server instance</param>
        /// <param name="zoneName">String representing the name of the zone.</param>
        /// <param name="zoneType">Type of zone.</param>
        /// <param name="dsIntegrated">Indicates whether zone data is stored in the Active Directory or in files. If TRUE, the data is stored in the Active Directory; if FALSE, the data is stored in files.</param>
        /// <param name="dataFileName">Optional - Name of the data file associated with the zone.</param>
        /// <param name="ipAddr">Optional - IP address of the master DNS Server for the zone.</param>
        /// <param name="adminEmail">Optional - Email address of the administrator responsible for the zone.</param>
        /// <returns>the new Zone created</returns>
        public static Zone CreateZone(Server server,
                                      string zoneName,
                                      ZoneTypeCreate zoneType,
                                      bool dsIntegrated,
                                      string dataFileName,
                                      string[] ipAddr,
                                      string adminEmail)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server is required");
            }

            try
            {
                ManagementObject mc = new ManagementClass(server.m_scope, new ManagementPath("MicrosoftDNS_Zone"), null);
                mc.Get();
                ManagementBaseObject parameters = mc.GetMethodParameters("CreateZone");
                parameters["ZoneName"]     = zoneName;
                parameters["ZoneType"]     = (UInt32)zoneType;
                parameters["DsIntegrated"] = dsIntegrated;
                if (!string.IsNullOrEmpty(dataFileName))
                {
                    parameters["DataFileName"] = dataFileName;
                }
                //if (!string.IsNullOrEmpty(ipAddr))
                parameters["IpAddr"] = ipAddr;
                if (!string.IsNullOrEmpty(adminEmail))
                {
                    parameters["AdminEmailName"] = adminEmail;
                }

                return(new Zone(new ManagementObject(server.m_scope, new ManagementPath(mc.InvokeMethod("CreateZone", parameters, null)["RR"].ToString()), null)));
            }
            catch (ManagementException me)
            {
                throw new WMIException(me);
            }
        }
コード例 #3
0
ファイル: Zone.cs プロジェクト: drorgl/MSDNSWebAdmin
        /// <summary>
        /// changes the type of a zone.
        /// </summary>
        /// <param name="zoneType">Type of zone</param>
        /// <param name="dataFileName">Optional - Name of the data file associated with the zone.</param>
        /// <param name="ipAddr">Optional - IP address of the mater DNS Server for the zone.</param>
        /// <param name="adminEmailName">Optional - Email address of the administrator responsible for the zone.</param>
        public Zone ChangeZoneType(ZoneTypeCreate zoneType, string dataFileName, string[] ipAddr, 
                                    string adminEmailName)
        {
            ManagementBaseObject inParams = m_mo.GetMethodParameters("ChangeZoneType");
            inParams["ZoneType"] = (UInt32)zoneType ;

            if (!string.IsNullOrEmpty(dataFileName))
                inParams["DataFileName"] = dataFileName;

            if (ipAddr != null)
                inParams["IpAddr"] = ipAddr;
            else if (((ipAddr == null) || (ipAddr.Length == 0)) && (zoneType != ZoneTypeCreate.Primary))
                throw new ArgumentException("ipAddr must contain at least one address");

            if ((this.ZoneType == ZoneTypeEnum.Stub) && (zoneType == ZoneTypeCreate.Primary))
                throw new ArgumentException("Unable to change from Stub to Primary, change to secondary first");

            if ((zoneType == ZoneTypeCreate.Primary) && (string.IsNullOrEmpty(this.DataFile)) && (string.IsNullOrEmpty(dataFileName)))
                throw new ArgumentException("Primary zone needs a filename");

            if (!string.IsNullOrEmpty(adminEmailName))
                inParams["AdminEmailName"] = adminEmailName;

            //ChangeZoneType not acting as documented in
            //http://msdn.microsoft.com/en-us/library/windows/desktop/ms682759(v=vs.85).aspx
            try
            {
                m_mo.InvokeMethod("ChangeZoneType", inParams, null);//["RR"].ToString()

                return new Zone(new ManagementObject(m_mo.Scope, new ManagementPath(m_mo.ToString()), null));
            }
            catch (ManagementException me)
            {
                throw new WMIException(me);
            }
        }
コード例 #4
0
ファイル: Zone.cs プロジェクト: drorgl/MSDNSWebAdmin
        /// <summary>
        /// creates a DNS zone. 
        /// </summary>
        /// <param name="server">a Server instance</param>
        /// <param name="zoneName">String representing the name of the zone.</param>
        /// <param name="zoneType">Type of zone.</param>
        /// <param name="dsIntegrated">Indicates whether zone data is stored in the Active Directory or in files. If TRUE, the data is stored in the Active Directory; if FALSE, the data is stored in files.</param>
        /// <param name="dataFileName">Optional - Name of the data file associated with the zone.</param>
        /// <param name="ipAddr">Optional - IP address of the master DNS Server for the zone.</param>
        /// <param name="adminEmail">Optional - Email address of the administrator responsible for the zone.</param>
        /// <returns>the new Zone created</returns>
        public static Zone CreateZone(Server server,
                                string zoneName,
                                ZoneTypeCreate zoneType,
                                bool dsIntegrated,
                                string dataFileName,
                                string[] ipAddr,
                                string adminEmail)
        {
            if (server == null)
                throw new ArgumentNullException("server is required");

            try
            {
                ManagementObject mc = new ManagementClass(server.m_scope, new ManagementPath("MicrosoftDNS_Zone"), null);
                mc.Get();
                ManagementBaseObject parameters = mc.GetMethodParameters("CreateZone");
                parameters["ZoneName"] = zoneName;
                parameters["ZoneType"] = (UInt32)zoneType;
                parameters["DsIntegrated"] = dsIntegrated;
                if (!string.IsNullOrEmpty(dataFileName))
                    parameters["DataFileName"] = dataFileName;
                //if (!string.IsNullOrEmpty(ipAddr))
                parameters["IpAddr"] = ipAddr;
                if (!string.IsNullOrEmpty(adminEmail))
                    parameters["AdminEmailName"] = adminEmail;

                return new Zone(new ManagementObject(server.m_scope, new ManagementPath(mc.InvokeMethod("CreateZone", parameters, null)["RR"].ToString()), null));
            }
            catch (ManagementException me)
            {
                throw new WMIException(me);
            }
        }