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); } }
private void LoadServer(DataRow dr) { int intRequest = Int32.Parse(dr["requestid"].ToString()); int intItem = Int32.Parse(dr["itemid"].ToString()); int intNumber = Int32.Parse(dr["number"].ToString()); string strNameCurrent = dr["name_current"].ToString(); string strIPCurrent = dr["ip_current"].ToString(); string strAliasCurrent = dr["alias_current"].ToString(); string strNameNew = dr["name_new"].ToString(); string strIPNew = dr["ip_new"].ToString(); string strAliasNew = dr["alias_new"].ToString(); string strReason = dr["reason"].ToString(); txtSearchName.Text = strNameCurrent; txtSearchIP.Text = strIPCurrent; txtSearchAlias.Text = strAliasCurrent; if (strReason != "") { // Show Confirmation Page lblName.Text = strNameCurrent; lblIP.Text = strIPCurrent; lblAlias.Text = strAliasCurrent; panConfirm.Visible = true; strConfirm = oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment); btnNext.Attributes.Add("onclick", "return ValidateCheck('" + chkAgree.ClientID + "','Please check the box stating that you agree to the disclaimer notice')" + " && ProcessButton(this)" + ";"); btnDiscard.Attributes.Add("onclick", "return confirm('WARNING: Starting over will discard all the changes you have made.\\n\\nAre you sure you want to continue?') && ProcessButton(this);"); btnContinue.Visible = false; btnConfirm.Visible = false; } else { panSearch.Visible = true; btnNext.Visible = false; // Get Record from DNS System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain()); ClearViewWebServices oWebService = new ClearViewWebServices(); oWebService.Timeout = Int32.Parse(ConfigurationManager.AppSettings["WS_TIMEOUT"]); oWebService.Credentials = oCredentials; oWebService.Url = oVariable.WebServiceURL(); Settings oSetting = new Settings(0, dsn); bool boolDNS_QIP = oSetting.IsDNS_QIP(); bool boolDNS_Bluecat = oSetting.IsDNS_Bluecat(); // Get Values if (strNameCurrent != "") { if (boolDNS_QIP == true) { strIPCurrent = oWebService.SearchDNSforPNC("", strNameCurrent, false, true); if (strIPCurrent.StartsWith("***") == false) { strNameCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", false, true); strAliasCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", true, true); if (strAliasCurrent.StartsWith("***") == true) { strAliasCurrent = ""; } } else { strNameCurrent = ""; strIPCurrent = ""; } } if (boolDNS_Bluecat == true) { strIPCurrent = oWebService.SearchBluecatDNS("", strNameCurrent); if (strIPCurrent.StartsWith("***") == false) { strNameCurrent = oWebService.SearchBluecatDNS(strIPCurrent, ""); strAliasCurrent = ""; } else { strNameCurrent = ""; strIPCurrent = ""; } } } else if (strIPCurrent != "") { if (boolDNS_QIP == true) { strNameCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", false, true); if (strNameCurrent.StartsWith("***") == false) { strAliasCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", true, true); if (strAliasCurrent.StartsWith("***") == true) { strAliasCurrent = ""; } } else { strNameCurrent = ""; strIPCurrent = ""; } } if (boolDNS_Bluecat == true) { strNameCurrent = oWebService.SearchBluecatDNS(strIPCurrent, ""); if (strNameCurrent.StartsWith("***") == false) { strAliasCurrent = ""; } else { strNameCurrent = ""; strIPCurrent = ""; } } } else if (strAliasCurrent != "") { if (boolDNS_QIP == true) { strIPCurrent = oWebService.SearchDNSforPNC("", strAliasCurrent, true, true); if (strIPCurrent.StartsWith("***") == false) { strNameCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", false, true); strAliasCurrent = oWebService.SearchDNSforPNC(strIPCurrent, "", true, true); if (strAliasCurrent.StartsWith("***") == true) { strAliasCurrent = ""; } } else { strAliasCurrent = ""; strIPCurrent = ""; } } if (boolDNS_Bluecat == true) { strAliasCurrent = ""; strIPCurrent = ""; } } if (strNameCurrent.Contains(".") == true) { strDomain = strNameCurrent.Substring(strNameCurrent.IndexOf(".")); strNameCurrent = strNameCurrent.Substring(0, strNameCurrent.IndexOf(".")); } if (strNameCurrent != "" && strIPCurrent != "") { DataSet ds = oServer.GetDNS(strNameCurrent); if (ds.Tables[0].Rows.Count == 1) { bool boolPermit = false; int intServer = Int32.Parse(ds.Tables[0].Rows[0]["id"].ToString()); int intUser = (ds.Tables[0].Rows[0]["userid"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["userid"].ToString())); int intOwner = (ds.Tables[0].Rows[0]["appcontact"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["appcontact"].ToString())); int intPrimary = (ds.Tables[0].Rows[0]["admin1"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["admin1"].ToString())); int intSecondary = (ds.Tables[0].Rows[0]["admin2"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["admin2"].ToString())); int intRequestor = (ds.Tables[0].Rows[0]["requestor"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["requestor"].ToString())); int intClass = (ds.Tables[0].Rows[0]["classid"].ToString() == "" ? 0 : Int32.Parse(ds.Tables[0].Rows[0]["classid"].ToString())); int intProd = (intClass > 0 ? (oClass.IsProd(intClass) ? 1 : 0) : -1); panShow.Visible = true; panAlias.Visible = boolDNS_QIP; lblName.Text = strNameCurrent; lblIP.Text = strIPCurrent; lblAlias.Text = strAliasCurrent; lblDomain.Text = strDomain; // Load Values txtName.Text = strNameCurrent; char[] strIPSplit = { '.' }; string[] strIP = strIPCurrent.Split(strIPSplit); txtIP1.Text = strIP[0]; txtIP2.Text = strIP[1]; txtIP3.Text = strIP[2]; txtIP4.Text = strIP[3]; char[] strAliasSplit = { ';' }; string[] strAlias = strAliasCurrent.Split(strAliasSplit); for (int ii = 0; ii < strAlias.Length; ii++) { if (strAlias[ii].Trim() != "") { string strAliasName = strAlias[ii].Trim(); while (strAliasName.Contains(strDomain) == true) { strAliasName = strAliasName.Replace(strDomain, ""); } lstAlias.Items.Add(new ListItem(strAliasName, strAliasName)); } } // Check Permission and either show read only, or permit edit if (intProfile == intOwner || intProfile == intPrimary || intProfile == intSecondary || intProfile == intRequestor) { boolPermit = true; } if (oApplication.Get(intApplication, "dns") == "1" || oUser.IsAdmin(intProfile) || intProfile == intUser) { boolPermit = true; } if (boolPermit == true) { btnContinue.Visible = false; txtSearchName.Enabled = false; txtSearchIP.Enabled = false; txtSearchAlias.Enabled = false; chkName.Attributes.Add("onclick", "CheckChange3('" + chkName.ClientID + "','" + chkIP.ClientID + "','" + chkAlias.ClientID + "','" + txtName.ClientID + "');"); chkIP.Attributes.Add("onclick", "CheckChange3('" + chkIP.ClientID + "','" + chkName.ClientID + "','" + chkAlias.ClientID + "','" + txtIP1.ClientID + "','" + txtIP2.ClientID + "','" + txtIP3.ClientID + "','" + txtIP4.ClientID + "');"); chkAlias.Attributes.Add("onclick", "CheckChange3('" + chkAlias.ClientID + "','" + chkName.ClientID + "','" + chkIP.ClientID + "','" + lstAlias.ClientID + "','" + btnAdd.ClientID + "','" + btnEdit.ClientID + "','" + btnRemove.ClientID + "','" + txtAlias.ClientID + "');"); btnAdd.Attributes.Add("onclick", "return AddDNS('" + lstAlias.ClientID + "','" + txtAlias.ClientID + "','" + hdnAlias.ClientID + "');"); btnEdit.Attributes.Add("onclick", "return EditDNS('" + lstAlias.ClientID + "','" + txtAlias.ClientID + "','" + hdnAlias.ClientID + "');"); btnRemove.Attributes.Add("onclick", "return RemoveDNS('" + lstAlias.ClientID + "','" + hdnAlias.ClientID + "');"); string strChange = ""; if (intProd != 0 || oServer.Get(intServer, "infrastructure") == "1") { panChange.Visible = true; strChange = " && ValidateTextLength('" + txtChange.ClientID + "', 'Please enter a valid change control number\\n\\n - Must start with either \"CHG\" or \"PTM\"\\n - Must be exactly 10 characters in length', 10, ['CHG','PTM'], ['CHG0000000','PTM0000000','CHG1111111','PTM1111111','CHG9999999','PTM9999999','CHGXXXXXXX','PTMXXXXXXX'])"; } btnConfirm.Attributes.Add("onclick", "return EnsureDNSCheck('" + chkName.ClientID + "','" + chkIP.ClientID + "','" + chkAlias.ClientID + "')" + " && (document.getElementById('" + chkName.ClientID + "').checked == false || (document.getElementById('" + chkName.ClientID + "').checked == true" + " && ValidateText('" + txtName.ClientID + "','Please enter a valid name')" + "))" + " && (document.getElementById('" + chkIP.ClientID + "').checked == false || (document.getElementById('" + chkIP.ClientID + "').checked == true" + " && ValidateNumberBetween('" + txtIP1.ClientID + "',1,255,'Please enter a valid IP Address')" + " && ValidateNumberBetween('" + txtIP2.ClientID + "',1,255,'Please enter a valid IP Address')" + " && ValidateNumberBetween('" + txtIP3.ClientID + "',1,255,'Please enter a valid IP Address')" + " && ValidateNumberBetween('" + txtIP4.ClientID + "',1,255,'Please enter a valid IP Address')" + "))" + strChange + " && ValidateText('" + txtReason.ClientID + "','Please enter a reason')" + " && ProcessButton(this)" + ";"); } else { btnConfirm.Visible = false; panAccess.Visible = true; chkName.Enabled = false; chkIP.Enabled = false; chkAlias.Enabled = false; btnAdd.Enabled = false; btnEdit.Enabled = false; btnRemove.Enabled = false; if (intUser > 0) { strContacts += "<tr><td>Device Owner:</td><td>" + oUser.GetFullName(intUser) + " (" + oUser.GetName(intUser) + ")" + "</td></tr>"; } if (intOwner > 0) { strContacts += "<tr><td>Departmental Manager:</td><td>" + oUser.GetFullName(intOwner) + " (" + oUser.GetName(intOwner) + ")" + "</td></tr>"; } if (intPrimary > 0) { strContacts += "<tr><td>Application Technical Lead:</td><td>" + oUser.GetFullName(intPrimary) + " (" + oUser.GetName(intPrimary) + ")" + "</td></tr>"; } if (intSecondary > 0) { strContacts += "<tr><td>Administrative Contact:</td><td>" + oUser.GetFullName(intSecondary) + " (" + oUser.GetName(intSecondary) + ")" + "</td></tr>"; } if (intRequestor > 0) { strContacts += "<tr><td>Design Initiated By:</td><td>" + oUser.GetFullName(intRequestor) + " (" + oUser.GetName(intRequestor) + ")" + "</td></tr>"; } DataSet dsDecoms = oApplication.GetDecoms(); if (dsDecoms.Tables[0].Rows.Count > 0) { strContacts += "<tr><td colspan=\"2\">Alternatively, you can contact a resource from one of the following departments:</td></tr>"; foreach (DataRow drDecom in dsDecoms.Tables[0].Rows) { strContacts += "<tr><td></td><td>" + drDecom["name"].ToString() + "</td></tr>"; } } } } else { btnReset.Enabled = false; btnConfirm.Visible = false; panExist.Visible = true; lblExist.Text = "This device does not exist in the database. Please try again..."; } } else { btnReset.Enabled = false; btnConfirm.Visible = false; panExist.Visible = true; lblExist.Text = "This device does not exist in DNS. Please try again..."; } } }
private void LoadServer(DataRow dr) { int intRequest = Int32.Parse(dr["requestid"].ToString()); int intItem = Int32.Parse(dr["itemid"].ToString()); int intNumber = Int32.Parse(dr["number"].ToString()); string strNameNew = dr["name_new"].ToString(); string strIPNew = dr["ip_new"].ToString(); string strAliasNew = dr["alias_new"].ToString(); ddlType.SelectedValue = dr["typeid"].ToString(); txtName.Text = strNameNew; char[] strIPSplit = { '.' }; string[] strIP = strIPNew.Split(strIPSplit); txtIP1.Text = strIP[0]; txtIP2.Text = strIP[1]; txtIP3.Text = strIP[2]; txtIP4.Text = strIP[3]; if (strAliasNew != "NONE") { // Show Confirmation Page lblName.Text = strNameNew; lblIP.Text = strIPNew; lblAlias.Text = strAliasNew; panConfirm.Visible = true; strConfirm = oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment); btnNext.Attributes.Add("onclick", "return ValidateCheck('" + chkAgree.ClientID + "','Please check the box stating that you agree to the disclaimer notice')" + " && ProcessButton(this)" + ";"); btnDiscard.Attributes.Add("onclick", "return confirm('WARNING: Starting over will discard all the changes you have made.\\n\\nAre you sure you want to continue?') && ProcessButton(this);"); btnContinue.Visible = false; btnConfirm.Visible = false; } else { panSearch.Visible = true; btnNext.Visible = false; // Get Record from DNS System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain()); ClearViewWebServices oWebService = new ClearViewWebServices(); oWebService.Timeout = Int32.Parse(ConfigurationManager.AppSettings["WS_TIMEOUT"]); oWebService.Credentials = oCredentials; oWebService.Url = oVariable.WebServiceURL(); bool boolFoundName = false; bool boolFoundIP = false; // Get Values if (strNameNew != "") { string strTemp = ""; if (boolDNS_QIP == true) { strTemp = oWebService.SearchDNSforPNC("", strNameNew, false, true); if (strTemp.StartsWith("***") == false) { boolFoundName = true; } } if (boolDNS_Bluecat == true) { strTemp = oWebService.SearchBluecatDNS("", strNameNew); if (strTemp.StartsWith("***") == false) { boolFoundName = true; } } } if (strIPNew != "") { string strTemp = ""; if (boolDNS_QIP == true) { strTemp = oWebService.SearchDNSforPNC(strIPNew, "", false, true); if (strTemp.StartsWith("***") == false) { boolFoundIP = true; } } if (boolDNS_Bluecat == true) { strTemp = oWebService.SearchBluecatDNS(strIPNew, ""); if (strTemp.StartsWith("***") == false) { boolFoundIP = true; } } } //DataSet ds = oServer.GetDNS(strNameNew); //if (ds.Tables[0].Rows.Count == 0) if (boolFoundName == false && boolFoundIP == false) { //if (boolFound == true) //{ // btnReset.Enabled = false; // btnConfirm.Visible = false; // panExist.Visible = true; // lblExist.Text = "This device already exists in DNS. Please try again..."; //} //else //{ bool boolPermit = true; panAlias.Visible = boolDNS_QIP; panShow.Visible = true; lblName.Text = strNameNew; lblIP.Text = strIPNew; lblAlias.Text = strAliasNew; // Check Permission and either show read only, or permit edit if (oApplication.Get(intApplication, "dns") == "1" || oUser.IsAdmin(intProfile)) { boolPermit = true; } if (boolPermit == true) { btnContinue.Visible = false; ddlType.Enabled = false; txtName.Enabled = false; txtIP1.Enabled = false; txtIP2.Enabled = false; txtIP3.Enabled = false; txtIP4.Enabled = false; txtAlias.Enabled = true; lstAlias.Enabled = true; txtContact1.Enabled = true; txtContact2.Enabled = true; btnAdd.Attributes.Add("onclick", "return AddDNS('" + lstAlias.ClientID + "','" + txtAlias.ClientID + "','" + hdnAlias.ClientID + "');"); btnEdit.Attributes.Add("onclick", "return EditDNS('" + lstAlias.ClientID + "','" + txtAlias.ClientID + "','" + hdnAlias.ClientID + "');"); btnRemove.Attributes.Add("onclick", "return RemoveDNS('" + lstAlias.ClientID + "','" + hdnAlias.ClientID + "');"); string strChange = ""; if (boolChange == true) { panChange.Visible = true; strChange = " && ValidateTextLength('" + txtChange.ClientID + "', 'Please enter a valid change control number\\n\\n - Must start with either \"CHG\" or \"PTM\"\\n - Must be exactly 10 characters in length', 10, ['CHG','PTM'], ['CHG0000000','PTM0000000','CHG1111111','PTM1111111','CHG9999999','PTM9999999','CHGXXXXXXX','PTMXXXXXXX'])"; } btnConfirm.Attributes.Add("onclick", "return ValidateHidden0('" + hdnContact1.ClientID + "','" + txtContact1.ClientID + "','Please enter the LAN ID of your contact # 1')" + " && ValidateHidden0('" + hdnContact2.ClientID + "','" + txtContact2.ClientID + "','Please enter the LAN ID of your contact # 2')" + strChange + " && ValidateText('" + txtReason.ClientID + "','Please enter a reason')" + " && ProcessButton(this)" + ";"); } else { btnConfirm.Visible = false; panAccess.Visible = true; btnAdd.Enabled = false; btnEdit.Enabled = false; btnRemove.Enabled = false; DataSet dsDecoms = oApplication.GetDecoms(); if (dsDecoms.Tables[0].Rows.Count > 0) { strContacts += "<tr><td colspan=\"2\">Alternatively, you can contact a resource from one of the following departments:</td></tr>"; foreach (DataRow drDecom in dsDecoms.Tables[0].Rows) { strContacts += "<tr><td></td><td>" + drDecom["name"].ToString() + "</td></tr>"; } } } //} } else { btnReset.Enabled = false; btnConfirm.Visible = false; panExist.Visible = true; lblExist.Text = "The " + (boolFoundName ? "device name" : "IP address") + " is already registered in DNS. Please try again..."; //lblExist.Text = "This device already exists in the database. Please try again..."; } } }