private bool CheckIP(int _answerid, int _ip1, int _ip2, int _ip3, int _ip4) { if (_ip1 > 0 && _ip1 < 256 && _ip2 > 0 && _ip2 < 256 && _ip3 > 0 && _ip3 < 256 && _ip4 > 0 && _ip4 < 256) { string strIP = _ip1.ToString() + "." + _ip2.ToString() + "." + _ip3.ToString() + "." + _ip4.ToString(); // Make sure PING times out (that it is not in use) Ping oPing = new Ping(); string strStatus = ""; try { PingReply oReply = oPing.Send(strIP); strStatus = oReply.Status.ToString().ToUpper(); } catch { } if (strStatus == "SUCCESS") { boolValidatePing = true; return(false); } // Make sure that this IP address does not exist in DNS (only if PNC) Classes oClass = new Classes(intProfile, dsn); int intClass = Int32.Parse(oForecast.GetAnswer(_answerid, "classid")); if (oClass.Get(intClass, "pnc") == "1") { Variables oVariableWS = new Variables(intEnvironment); System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariableWS.ADUser(), oVariableWS.ADPassword(), oVariableWS.Domain()); ClearViewWebServices oWS = new ClearViewWebServices(); oWS.Timeout = Int32.Parse(ConfigurationManager.AppSettings["WS_TIMEOUT"]); oWS.Credentials = oCredentials; oWS.Url = oVariableWS.WebServiceURL(); Settings oSetting = new Settings(0, dsn); bool boolDNS_QIP = oSetting.IsDNS_QIP(); bool boolDNS_Bluecat = oSetting.IsDNS_Bluecat(); if (boolDNS_QIP == true) { string strSearchName = oWS.SearchDNSforPNC(strIP, "", false, true); if (strSearchName.Trim().ToUpper() != "***NOTFOUND") { boolValidateDNS = true; return(false); } } if (boolDNS_Bluecat == true) { string strSearchName = oWS.SearchBluecatDNS(strIP, ""); if (strSearchName.Trim().ToUpper() != "***NOTFOUND") { boolValidateDNS = true; return(false); } } } // Make sure it is not already assigned in database IPAddresses oIPAddresses = new IPAddresses(intProfile, dsnIP, dsn); DataSet dsIP = oIPAddresses.Get(_ip1, _ip2, _ip3, _ip4); foreach (DataRow drIP in dsIP.Tables[0].Rows) { if (drIP["available"].ToString() == "0") { boolValidateDB = true; return(false); break; } } return(true); } else { boolValidateFormat = true; return(false); } }