예제 #1
0
        protected void btnPSEXEC_Click(object sender, EventArgs e)
        {
            Variables oVariable    = new Variables(999);
            string    strAdminUser = oVariable.Domain() + "\\" + oVariable.ADUser();
            string    strAdminPass = oVariable.ADPassword();

            PowerShell(Request.PhysicalApplicationPath + "scripts\\", "test.ps1", "-path C:", 1);
        }
예제 #2
0
        private DateTime CheckDomain(int _domain, int _search_domain, string _xid, int _days)
        {
            DateTime       _return   = DateTime.Today;
            Variables      oVariable = new Variables(_search_domain);
            DirectoryEntry oEntry    = new DirectoryEntry();

            if (_domain == 1)
            {
                oEntry = new DirectoryEntry(oVariable.primaryDC(dsn), oVariable.ADUser(), oVariable.ADPassword());
            }
            if (_domain == 2)
            {
                oEntry = new DirectoryEntry(oVariable.secondaryDC(), oVariable.ADUser(), oVariable.ADPassword());
            }
            DirectorySearcher oSearcher = new DirectorySearcher(oEntry);

            oSearcher.Filter = "(&(objectCategory=user)(sAMAccountName=" + _xid + "))";
            SearchResult oResult = oSearcher.FindOne();

            if (oResult != null)
            {
                if (oResult.Properties.Contains("sAMAccountName") == true)
                {
                    ActiveDs.LargeInteger oLarge;
                    if (oResult.GetDirectoryEntry().Properties.Contains("lastlogon") == true)
                    {
                        oLarge = (ActiveDs.LargeInteger)oResult.GetDirectoryEntry().Properties["lastlogon"].Value;
                        long     _date  = (long)oLarge.HighPart << 32 | (uint)oLarge.LowPart;
                        DateTime _logon = DateTime.FromFileTime(_date);
                        TimeSpan oSpan  = DateTime.Today.Subtract(_logon);
                        if (_date > 0.00 && oSpan.Days > _days)
                        {
                            _return = _logon;
                        }
                    }
                }
            }
            return(_return);
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["adminid"] != null && Request.Cookies["adminid"].Value != "")
            {
                intProfile = Int32.Parse(Request.Cookies["adminid"].Value);
            }
            else
            {
                Reload();
            }
            Variables oVariable = new Variables(intEnvironment);
            Functions oFunction = new Functions(0, dsn, intEnvironment);
            string    strURL    = "";
            DataSet   dsKey     = oFunction.GetSetupValuesByKey(Environment.MachineName + "_REPORTING");

            if (dsKey.Tables[0].Rows.Count > 0)
            {
                strURL = dsKey.Tables[0].Rows[0]["Value"].ToString();
            }
            if (strURL != "")
            {
                System.Net.NetworkCredential oNetwork = new NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
                rs2005             = new NCC.ClearView.Application.Core.RSDev.ReportingService2005();
                rs2005.Credentials = oNetwork;
                rs2005.Url         = strURL + oVariable.ReportServiceASMX();
                //NCC.ClearView.Application.Core.RSDev.CatalogItem[] oCatalog = rs2005.ListChildren("/", false);
                LoadReports("/", oTreeview, null);
                oTreeview.ExpandDepth = 0;
                oTreeview.Attributes.Add("oncontextmenu", "return false;");
                btnClose.Attributes.Add("onclick", "return window.top.HidePanel();");
                string strControl = "";
                if (Request.QueryString["control"] != null)
                {
                    strControl = Request.QueryString["control"];
                }
                btnSave.Attributes.Add("onclick", "return Update('" + hdnId.ClientID + "','" + strControl + "');");
            }
            else
            {
                Response.Write("Invalid Reporting URL ~ " + Environment.MachineName + "_REPORTING");
                btnSave.Enabled = false;
            }
        }
예제 #4
0
        protected void Page_Load()
        {
            Int32.TryParse(Request.QueryString["id"], out intAsset);
            if (intAsset > 0)
            {
                int   intModelProperty = 0;
                Asset oAsset           = new Asset(0, dsnAsset, dsn);
                if (Int32.TryParse(oAsset.Get(intAsset, "modelid"), out intModelProperty) == true)
                {
                    ModelsProperties oModelsProperties = new ModelsProperties(0, dsn);
                    if (oModelsProperties.IsDell(intModelProperty) == true)
                    {
                        int intDellConfig = 0;
                        Int32.TryParse(oModelsProperties.Get(intModelProperty, "dellconfigid"), out intDellConfig);
                        Dells   oDell  = new Dells(0, dsn);
                        DataSet dsDell = oDell.Get(intDellConfig);
                        if (dsDell.Tables[0].Rows.Count == 1)
                        {
                            DataRow drDell = dsDell.Tables[0].Rows[0];
                            strUser = drDell["username"].ToString();
                            strPass = drDell["password"].ToString();
                            strILO  = oAsset.GetServerOrBlade(intAsset, "ilo");

                            Functions oFunction = new Functions(0, dsn, intEnvironment);
                            Variables oVariable = new Variables(intEnvironment);

                            if (Request.QueryString["showimage"] != null)
                            {
                                Response.Redirect("/ondemand/ondemand_dell_image.aspx?showimage=https://" + strILO + Request.QueryString["showimage"]);
                            }
                            else if (Request.QueryString["bypass"] != null)
                            {
                                if (strUser == "" || strPass == "")
                                {
                                    strUser = oVariable.ADUser() + "@" + oVariable.FullyQualified();
                                    strPass = oFunction.AddPassword(50);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Variables oVariable = new Variables(999);
            Functions oFunction = new Functions(0, dsn, intEnvironment);
            string    strServer = "WDCLV101W";

            string _location_of_psexec = @"C:\Temp\";
            int    intTimeoutDefault   = (1 * 20 * 1000); // 20 seconds

            string strAdminUser = oVariable.Domain() + "\\" + oVariable.ADUser();;
            string strAdminPass = oVariable.ADPassword();

            ProcessStartInfo infoAudit = new ProcessStartInfo(_location_of_psexec + "psexec");

            infoAudit.WorkingDirectory = _location_of_psexec;
            // Windows 2008: Have to remove the "-i" parameter or else the script won't run (will come up with "the following helper dll cannot be loaded...XXXX.DLL" error)
            string strAuditArguments = "\\\\" + strServer + " -u " + strAdminUser + " -p " + strAdminPass + " -h cmd.exe /c hostname.exe";

            infoAudit.Arguments              = strAuditArguments;
            infoAudit.UseShellExecute        = false;
            infoAudit.RedirectStandardOutput = true;
            infoAudit.RedirectStandardError  = true;

            Process procAudit = Process.Start(infoAudit);

            procAudit.WaitForExit(intTimeoutDefault);
            if (procAudit.HasExited == false)
            {
                procAudit.Kill();
            }
            Response.Write("PSEXEC Exited (" + procAudit.ExitCode.ToString() + ")" + "<br/>");

            string output = procAudit.StandardOutput.ReadToEnd();

            Response.Write("Result (" + output.Replace(Environment.NewLine, "") + ")");

            string error = procAudit.StandardError.ReadToEnd();

            procAudit.Close();
        }
예제 #6
0
        protected void btnSubmit_Click(Object Sender, EventArgs e)
        {
            int    intUser   = 0;
            string strAssets = "";

            if (Int32.TryParse(Request.Form["hdnAJAXValue"], out intUser) == true && intUser > 0)
            {
                foreach (RepeaterItem ri in rptDevices.Items)
                {
                    CheckBox chkDevice    = (CheckBox)ri.FindControl("chkDevice");
                    Label    lblName      = (Label)ri.FindControl("lblName");
                    Label    lblSerial    = (Label)ri.FindControl("lblSerial");
                    Label    lblStatus    = (Label)ri.FindControl("lblStatus");
                    bool     boolComplete = lblStatus.Text.ToUpper().Contains("COMPLETED");
                    oLog.AddEvent(lblName.Text, lblSerial.Text, "RECOMMISSION: Started by " + oUser.GetFullNameWithLanID(intProfile), LoggingType.Information);

                    if (chkDevice.Checked == true)
                    {
                        if (chkDevice.ToolTip[0].ToString() == "S")
                        {
                            int     intServer = Int32.Parse(chkDevice.ToolTip.Substring(1));
                            DataSet dsServers = oServer.GetAssetsServer(intServer);
                            foreach (DataRow drServer in dsServers.Tables[0].Rows)
                            {
                                int    intAsset = Int32.Parse(drServer["assetid"].ToString());
                                string strName  = lblName.Text;
                                if (drServer["dr"].ToString() == "1")
                                {
                                    strName += "-DR";
                                }
                                // Update Recommission Reason
                                oAsset.UpdateDecommissionRecommission(intAsset, intUser, txtReason.Text);
                                // Set status to InUse
                                oAsset.AddStatus(intAsset, strName, (int)AssetStatus.InUse, intUser, DateTime.Now);
                                // Clear cv_servers_assets DECOM field
                                oServer.UpdateAssetDecom(intServer, intAsset, "");
                                if (boolComplete == true)
                                {
                                    DataSet dsOrders = oAssetOrder.GetByAsset(intAsset, false);
                                    foreach (DataRow drOrders in dsOrders.Tables[0].Rows)
                                    {
                                        int intOrder = Int32.Parse(drOrders["orderid"].ToString());
                                        // Cancel Resource Requests
                                        int intResource = 0;
                                        if (Int32.TryParse(drOrders["resourceid"].ToString(), out intResource) == true)
                                        {
                                            oResourceRequest.UpdateStatusOverallWorkflow(intResource, (int)ResourceRequestStatus.Cancelled);
                                        }
                                        // Delete Order
                                        oAssetOrder.DeleteOrder(intOrder);
                                        // Delete Asset Order Asset Selection
                                        oAssetOrder.DeleteAssetOrderAssetSelection(intOrder, intAsset);
                                    }
                                    // Set NewOrderID = 0
                                    oAsset.updateNewOrderId(0, intAsset);
                                }
                                // Set strAssets to assets recommissioned (for status message on postback)
                                if (strAssets != "")
                                {
                                    strAssets += strSplit[0].ToString();
                                }
                                strAssets += intAsset.ToString();
                            }
                            // Remove previous decom records
                            if (boolComplete == true)
                            {
                                bool boolPNC = (oServer.Get(intServer, "pnc") == "1");
                                // Update Server Name Record
                                int intName = Int32.Parse(oServer.Get(intServer, "nameid"));
                                if (boolPNC)
                                {
                                    oServerName.UpdateFactory(intName, 0);
                                }
                                else
                                {
                                    oServerName.Update(intName, 0);
                                }
                            }
                            // Clear cv_servers DECOM field
                            oServer.UpdateDecommissioned(intServer, "");
                            // Update IP Address(es) availability
                            DataSet dsIP = oServer.GetIP(intServer, 0, 0, 0, 0);
                            foreach (DataRow drIP in dsIP.Tables[0].Rows)
                            {
                                int intIP = Int32.Parse(drIP["ipaddressid"].ToString());
                                oIPAddresses.UpdateAvailable(intIP, 0);
                            }
                            // Restore Avamar Group(s)
                            if (chkAvamar.Checked)
                            {
                                Avamar                       oAvamar             = new Avamar(0, dsn);
                                AvamarRegistration           oAvamarRegistration = new AvamarRegistration(0, dsn);
                                ClearViewWebServices         oWebService         = new ClearViewWebServices();
                                System.Net.NetworkCredential oCredentialsDNS     = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
                                oWebService.Credentials = oCredentialsDNS;
                                oWebService.Url         = oVariable.WebServiceURL();
                                string strError = "";

                                // First, query for groups.
                                DataSet dsGroups = oAvamar.GetDecoms(lblName.Text);
                                if (dsGroups.Tables[0].Rows.Count > 0)
                                {
                                    string client = dsGroups.Tables[0].Rows[0]["client"].ToString();
                                    string grid   = dsGroups.Tables[0].Rows[0]["grid"].ToString();
                                    string domain = dsGroups.Tables[0].Rows[0]["domain"].ToString();
                                    // Second, add the groups.
                                    foreach (DataRow drGroup in dsGroups.Tables[0].Rows)
                                    {
                                        if (String.IsNullOrEmpty(strError) == false)
                                        {
                                            break;
                                        }
                                        AvamarReturnType restore = oAvamarRegistration.API(oWebService.AddAvamarGroup(grid, domain, client, drGroup["group"].ToString()));
                                        if (restore.Error == true)
                                        {
                                            strError = restore.Message;
                                        }
                                    }
                                    // Third, remove the /Decom group
                                    AvamarReturnType decom = oAvamarRegistration.API(oWebService.DeleteAvamarGroup(grid, domain, client, oAvamar.DecomGroup));
                                    if (decom.Error == false)
                                    {
                                        // Fourth, recommission the saved decom groups.
                                        oAvamar.UpdateDecom(client);
                                    }
                                    else
                                    {
                                        strError = decom.Message;
                                    }
                                }
                                if (String.IsNullOrEmpty(strError))
                                {
                                    oLog.AddEvent(lblName.Text, lblSerial.Text, "RECOMMISSION: Avamar completed.", LoggingType.Information);
                                }
                                else
                                {
                                    oLog.AddEvent(lblName.Text, lblSerial.Text, "RECOMMISSION: Avamar encountered an error = " + strError, LoggingType.Error);
                                }
                            }
                            // Add log entry
                            oLog.AddEvent(lblName.Text, lblSerial.Text, "Asset Recommissioned (Client = " + oUser.GetFullName(intUser) + ")", LoggingType.Information);
                        }
                        else
                        {
                            // Manual recommission - just delete the resource request to get out of the person's queue
                            int intResource = Int32.Parse(chkDevice.ToolTip.Substring(1));
                            oResourceRequest.UpdateStatusOverall(intResource, -2);
                        }
                    }
                }
            }
            Response.Redirect(Request.Path + "?assets=" + strAssets);
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RequestItems    oRequestItem    = new RequestItems(intProfile, dsn);
            RequestFields   oRequestField   = new RequestFields(intProfile, dsn);
            ServiceRequests oServiceRequest = new ServiceRequests(intProfile, dsn);
            Services        oService        = new Services(intProfile, dsn);
            int             intRequest      = Int32.Parse(Request.QueryString["rid"]);
            string          strStatus       = oServiceRequest.Get(intRequest, "checkout");
            DataSet         dsItems         = oRequestItem.GetForms(intRequest);
            int             intItem         = 0;
            int             intService      = 0;
            int             intNumber       = 0;

            if (dsItems.Tables[0].Rows.Count > 0)
            {
                bool boolBreak = false;
                foreach (DataRow drItem in dsItems.Tables[0].Rows)
                {
                    if (boolBreak == true)
                    {
                        break;
                    }
                    if (drItem["done"].ToString() == "0")
                    {
                        intItem    = Int32.Parse(drItem["itemid"].ToString());
                        intService = Int32.Parse(drItem["serviceid"].ToString());
                        intNumber  = Int32.Parse(drItem["number"].ToString());
                        boolBreak  = true;
                    }
                    if (intItem > 0 && (strStatus == "1" || strStatus == "2"))
                    {
                        bool   boolSuccess = true;
                        string strResult   = oService.GetName(intService) + " Completed";
                        string strError    = oService.GetName(intService) + " Error";
                        // ********* BEGIN PROCESSING **************
                        DNS oDNS = new DNS(intProfile, dsn);
                        strResult = "";
                        strError  = "";
                        if (intEnvironment < 3)
                        {
                            intEnvironment = 3;
                        }
                        Variables oVariable = new Variables(intEnvironment);
                        Requests  oRequest  = new Requests(intProfile, dsn);
                        Users     oUser     = new Users(intProfile, dsn);
                        DataSet   ds        = oDNS.GetDNS(intRequest, intItem, intNumber);
                        Domains   oDomain   = new Domains(intProfile, dsn);
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            string strAction       = ds.Tables[0].Rows[0]["action"].ToString();
                            string strNameCurrent  = ds.Tables[0].Rows[0]["name_current"].ToString();
                            string strIPCurrent    = ds.Tables[0].Rows[0]["ip_current"].ToString();
                            string strAliasCurrent = ds.Tables[0].Rows[0]["alias_current"].ToString();
                            string strNameNew      = ds.Tables[0].Rows[0]["name_new"].ToString();
                            string strIPNew        = ds.Tables[0].Rows[0]["ip_new"].ToString();
                            string strAliasNew     = ds.Tables[0].Rows[0]["alias_new"].ToString();
                            string strDomain       = ds.Tables[0].Rows[0]["domain"].ToString();
                            string strObject       = ds.Tables[0].Rows[0]["value"].ToString();
                            int    intUser         = oRequest.GetUser(intRequest);

                            // Connect to DNS to process the request
                            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();

                            string strWebServiceResult = "";

                            switch (strAction)
                            {
                            case "CREATE":
                                if (strIPNew != "" && strNameNew != "")
                                {
                                    if (boolDNS_QIP == true)
                                    {
                                        strWebServiceResult = oWebService.CreateDNSforPNC(strIPNew, strNameNew, strObject, strAliasNew, oVariable.DNS_Domain(), oVariable.DNS_NameService(), oVariable.DNS_DynamicDNSUpdate(), intProfile, 0, true);
                                        if (strWebServiceResult == "SUCCESS")
                                        {
                                            strResult += "<p>The following record was successfully created in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                        }
                                        else if (strWebServiceResult.StartsWith("***DUPLICATE") == true)
                                        {
                                            strResult += "<p>The following record was already created in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                        }
                                        else if (strWebServiceResult.StartsWith("***CONFLICT") == true)
                                        {
                                            strError += "<p>A CONFLICT occurred when attempting to create the following record in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Conflict Message:</p><p>" + strWebServiceResult + "</p>";
                                        }
                                        else
                                        {
                                            strError += "<p>An ERROR occurred when attempting to create the following record in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Error Message:</p><p>" + strWebServiceResult + "</p>";
                                        }
                                    }
                                    if (boolDNS_Bluecat == true)
                                    {
                                        strWebServiceResult = oWebService.CreateBluecatDNS(strIPNew, strNameNew, strNameNew, "");
                                        if (strWebServiceResult == "SUCCESS")
                                        {
                                            strResult += "<p>The following record was successfully created in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                        }
                                        else if (strWebServiceResult.StartsWith("***DUPLICATE") == true)
                                        {
                                            strResult += "<p>The following record was already created in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                        }
                                        else if (strWebServiceResult.StartsWith("***CONFLICT") == true)
                                        {
                                            strError += "<p>A CONFLICT occurred when attempting to create the following record in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Conflict Message:</p><p>" + strWebServiceResult + "</p>";
                                        }
                                        else
                                        {
                                            strError += "<p>An ERROR occurred when attempting to create the following record in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Error Message:</p><p>" + strWebServiceResult + "</p>";
                                        }
                                    }
                                }
                                else
                                {
                                    strError = "<p>Invalid Parameters...</p>";
                                }

                                break;

                            case "UPDATE":
                                string strIP    = (strIPNew != "" ? strIPNew : strIPCurrent);
                                string strName  = (strNameNew != "" ? strNameNew : strNameCurrent);
                                string strAlias = (((strAliasCurrent != "" && strAliasNew == "") || strAliasNew != "") ? strAliasNew : strAliasCurrent);
                                if (strObject == "")
                                {
                                    strObject = "Server";
                                }
                                if (boolDNS_QIP == true)
                                {
                                    strWebServiceResult = oWebService.UpdateDNSforPNC(strIP, strName, strObject, strAlias, oVariable.DNS_Domain(), oVariable.DNS_NameService(), oVariable.DNS_DynamicDNSUpdate(), intProfile, 0, true);
                                    if (strWebServiceResult == "SUCCESS")
                                    {
                                        strResult += "<p>The following record was successfully updated in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                    }
                                    else if (strWebServiceResult.StartsWith("***DUPLICATE") == true)
                                    {
                                        strResult += "<p>The following record was already updated in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                    }
                                    else if (strWebServiceResult.StartsWith("***CONFLICT") == true)
                                    {
                                        strError += "<p>A CONFLICT occurred when attempting to update the following record in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Conflict Message:</p><p>" + strWebServiceResult + "</p>";
                                    }
                                    else
                                    {
                                        strError += "<p>An ERROR occurred when attempting to update the following record in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Error Message:</p><p>" + strWebServiceResult + "</p>";
                                    }
                                }
                                if (boolDNS_Bluecat == true)
                                {
                                    strWebServiceResult = oWebService.UpdateBluecatDNS(strIP, strName, strNameNew, "");
                                    if (strWebServiceResult == "SUCCESS")
                                    {
                                        strResult += "<p>The following record was successfully updated in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                    }
                                    else if (strWebServiceResult.StartsWith("***DUPLICATE") == true)
                                    {
                                        strResult += "<p>The following record was already updated in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                    }
                                    else if (strWebServiceResult.StartsWith("***CONFLICT") == true)
                                    {
                                        strError += "<p>A CONFLICT occurred when attempting to update the following record in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Conflict Message:</p><p>" + strWebServiceResult + "</p>";
                                    }
                                    else
                                    {
                                        strError += "<p>An ERROR occurred when attempting to update the following record in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Error Message:</p><p>" + strWebServiceResult + "</p>";
                                    }
                                }
                                break;

                            case "DELETE":
                                if (boolDNS_QIP == true)
                                {
                                    if (strIPCurrent != "")
                                    {
                                        strWebServiceResult = oWebService.DeleteDNSforPNC(strIPCurrent, "", intProfile, true);
                                    }
                                    else if (strNameCurrent != "")
                                    {
                                        strWebServiceResult = oWebService.DeleteDNSforPNC("", strNameCurrent, intProfile, true);
                                    }

                                    if (strWebServiceResult == "SUCCESS")
                                    {
                                        strResult += "<p>The following record was successfully deleted in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                    }
                                    else
                                    {
                                        strError += "<p>An ERROR occurred when attempting to delete the following record in QIP DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Error Message:</p><p>" + strWebServiceResult + "</p>";
                                    }
                                }
                                if (boolDNS_Bluecat == true)
                                {
                                    if (strIPCurrent != "")
                                    {
                                        strWebServiceResult = oWebService.DeleteBluecatDNS(strIPCurrent, "", false, false);
                                    }
                                    else if (strNameCurrent != "")
                                    {
                                        strWebServiceResult = oWebService.DeleteBluecatDNS("", strNameCurrent, false, false);
                                    }

                                    if (strWebServiceResult == "SUCCESS")
                                    {
                                        strResult += "<p>The following record was successfully deleted in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p>";
                                    }
                                    else
                                    {
                                        strError += "<p>An ERROR occurred when attempting to delete the following record in BlueCat DNS...</p><p>" + oDNS.GetDNSBody(intRequest, intItem, intNumber, true, intEnvironment) + "</p><p>Error Message:</p><p>" + strWebServiceResult + "</p>";
                                    }
                                }
                                break;
                            }
                            if (strResult != "")
                            {
                                oRequest.AddResult(intRequest, intItem, intNumber, oService.GetName(intService), "", strResult, intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intUser));
                            }
                            else if (strError != "")
                            {
                                oRequest.AddResult(intRequest, intItem, intNumber, oService.GetName(intService), strError, "", intEnvironment, (oService.Get(intService, "notify_client") == "1"), oUser.GetName(intUser));
                            }
                            oDNS.UpdateDNSCompleted(intRequest, intItem, intNumber);
                        }
                        if (strResult == "")
                        {
                            boolSuccess = false;
                        }
                        // ******** END PROCESSING **************
                        if (oService.Get(intService, "automate") == "1" && boolSuccess == true)
                        {
                            strDone += "<table border=\"0\"><tr><td><img src=\"/images/bigCheck.gif\" border=\"0\" align=\"absmiddle\"/></td><td class=\"biggerbold\">" + strResult + "</td></tr></table>";
                        }
                        else
                        {
                            if (boolSuccess == false)
                            {
                                strDone += "<table border=\"0\"><tr><td><img src=\"/images/bigError.gif\" border=\"0\" align=\"absmiddle\"/></td><td class=\"biggerbold\">" + strError + "</td></tr></table>";
                            }
                            else
                            {
                                strDone += "<table border=\"0\"><tr><td><img src=\"/images/bigCheck.gif\" border=\"0\" align=\"absmiddle\"/></td><td class=\"biggerbold\">" + oService.GetName(intService) + " Submitted</td></tr></table>";
                            }
                        }
                        oRequestItem.UpdateFormDone(intRequest, intItem, intNumber, 1);
                    }
                }
            }
        }
예제 #8
0
        private void LoadObjects()
        {
            string strUser = oFunction.decryptQueryString(Request.QueryString["u"]);

            txtFrom.Text = strUser;
            int intDomain = Int32.Parse(oFunction.decryptQueryString(Request.QueryString["d"]));

            ddlDomain.SelectedValue = intDomain.ToString();
            intDomain = Int32.Parse(oDomain.Get(intDomain, "environment"));
            AD oAD = new AD(intProfile, dsn, intDomain);

            lblUser.Text = oAD.GetUserFullName(strUser);
            DirectoryEntry oEntry    = oAD.UserSearch(strUser);
            Variables      oVariable = new Variables(intDomain);

            if (oEntry != null)
            {
                if (oEntry.Properties.Contains("memberof") == true)
                {
                    foreach (string strGroup in oEntry.Properties["memberof"])
                    {
                        DirectoryEntry oEntry2 = new DirectoryEntry("LDAP://" + oVariable.primaryDCName(dsn) + "/" + strGroup, oVariable.Domain() + "\\" + oVariable.ADUser(), oVariable.ADPassword());
                        ListItem       oList   = new ListItem(oEntry2.Properties["name"].Value.ToString());
                        chkGroups.Items.Add(oList);
                        oList.Selected = true;
                    }
                }
                panContinue.Visible = true;
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "saved", "<script type=\"text/javascript\">alert('The user account could not be found.\\n\\nPlease enter a valid account to continue.');<" + "/" + "script>");
                btnNext.Enabled = false;
            }
        }
예제 #9
0
        public void Process(int _requestid, int _itemid, int _number, int _id, string _server, string _password, int _environment)
        {
            Requests  oRequest  = new Requests(user, dsn);
            Variables oVariable = new Variables(_environment);
            Users     oUser     = new Users(user, dsn);
            DataSet   ds        = Get(_id);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DateTime _now      = DateTime.Now;
                string   strUnique = _now.Day.ToString() + _now.Month.ToString() + _now.Year.ToString() + _now.Hour.ToString() + _now.Minute.ToString() + _now.Second.ToString() + _now.Millisecond.ToString();
                string   strXID    = ds.Tables[0].Rows[0]["xid"].ToString().ToUpper();
                int      intUser   = oUser.GetId(strXID);
                int      intDomain = Int32.Parse(ds.Tables[0].Rows[0]["domain"].ToString());
                Domains  oDomain   = new Domains(user, dsn);
                if (oDomain.Get(intDomain, "account_setup") == "1" || oDomain.Get(intDomain, "account_maintenance") == "1")
                {
                    intDomain = Int32.Parse(oDomain.Get(intDomain, "environment"));
                    Variables oVar      = new Variables(intDomain);
                    AD        oAD       = new AD(user, dsn, intDomain);
                    string    strFName  = oUser.Get(intUser, "fname");
                    string    strLName  = oUser.Get(intUser, "lname");
                    string    strResult = "";
                    string    strID     = strXID;
                    string    strAction = "";
                    //string strNotify = "<p><a href=\"javascript:void(0);\" class=\"bold\" onclick=\"ShowAccountDetail('divAccount_" + strUnique + "');\">Account " + strXID.ToUpper() + " in " + oVar.Name() + "</a><br/>";
                    //strNotify += "<div id=\"divAccount_" + strUnique + "\" style=\"display:none\"><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" style=\"" + oVariable.DefaultFontStyle() + "\">";
                    string strNotify = "<p><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" style=\"" + oVariable.DefaultFontStyle() + "\">";
                    strNotify += "<tr><td><b><u>Account &quot;" + strXID.ToUpper() + "&quot; in " + oVar.Name() + "</u></b></td></tr>";
                    // Add User
                    if (intDomain != (int)CurrentEnvironment.CORPDMN && intDomain != (int)CurrentEnvironment.PNCNT_PROD)
                    {
                        strID = "E" + strID.Substring(1);
                        if (oAD.Search(strID, false) != null)
                        {
                            strAction = " already existed";
                        }
                        else
                        {
                            strID = "T" + strID.Substring(1);
                            if (oAD.Search(strID, false) != null)
                            {
                                strAction = " already existed";
                            }
                            else if (oDomain.Get(intDomain, "account_maintenance") == "1")
                            {
                                strResult = oAD.CreateUser(strID, strFName, strLName, _password, "", "Created by ClearView - " + DateTime.Now.ToShortDateString(), "");
                                strAction = " was created";
                            }
                            else
                            {
                                strResult = "Cannot create accounts in this domain";
                            }
                        }
                    }
                    else
                    {
                        if (oAD.Search(strID, false) != null)
                        {
                            strAction = " already existed";
                        }
                        else if (oDomain.Get(intDomain, "account_maintenance") == "1")
                        {
                            strResult = oAD.CreateUser(strID, strFName, strLName, _password, "", "Created by ClearView - " + DateTime.Now.ToShortDateString(), "");
                            strAction = " was created";
                        }
                        else
                        {
                            strResult = "Cannot create accounts in this domain";
                        }
                    }
                    if (strResult == "")
                    {
                        strNotify += "<tr><td>The account " + strID + strAction + " for " + strFName + " " + strLName + " in " + oVar.Name() + "</td></tr>";
                        // Local Groups
                        string strLocal = ds.Tables[0].Rows[0]["localgroups"].ToString();
                        if (strLocal != "")
                        {
                            string[] strGroups;
                            char[]   strSplit = { ';' };
                            strGroups = strLocal.Split(strSplit);
                            DirectoryEntry oAccount = new DirectoryEntry("WinNT://" + oVar.Domain() + "/" + strID + ",user", oVar.Domain() + "\\" + oVar.ADUser(), oVar.ADPassword());
                            DirectoryEntry oServer  = new DirectoryEntry("WinNT://" + oVar.Domain() + "/" + _server + ",computer", oVar.Domain() + "\\" + oVar.ADUser(), oVar.ADPassword());
                            for (int ii = 0; ii < strGroups.Length; ii++)
                            {
                                if (strGroups[ii].Trim() != "")
                                {
                                    try
                                    {
                                        DirectoryEntry oGroup = oServer.Children.Find(strGroups[ii]);
                                        oGroup.Invoke("Add", new object[] { oAccount.Path });
                                        strNotify += "<tr><td>The account " + strID + " was successfully added to the local group " + strGroups[ii] + "</td></tr>";
                                    }
                                    catch
                                    {
                                        strNotify += "<tr><td>There was a problem adding the account " + strID + " to the local group " + strGroups[ii] + "</td></tr>";
                                    }
                                }
                            }
                        }
                        // Global Groups
                        string strGlobal = ds.Tables[0].Rows[0]["adgroups"].ToString();
                        if (strGlobal != "")
                        {
                            string[] strGroups;
                            char[]   strSplit = { ';' };
                            strGroups = strGlobal.Split(strSplit);
                            for (int ii = 0; ii < strGroups.Length; ii++)
                            {
                                if (strGroups[ii].Trim() != "")
                                {
                                    if (oAD.Search(strGroups[ii], false) == null)
                                    {
                                        strResult = oAD.CreateGroup(strGroups[ii], "", "Created by ClearView - " + DateTime.Now.ToShortDateString(), "", "GG", "S");
                                        if (strResult == "")
                                        {
                                            strNotify += "<tr><td>The group " + strGroups[ii] + " was successfully created in " + oVar.Name() + "</td></tr>";
                                        }
                                        else
                                        {
                                            strNotify += "<tr><td>There was a problem creating the group " + strGroups[ii] + " in " + oVar.Name() + "</td></tr>";
                                        }
                                    }
                                    else
                                    {
                                        strResult  = "";
                                        strNotify += "<tr><td>The group " + strGroups[ii] + " already exists in " + oVar.Name() + "</td></tr>";
                                    }
                                    if (strResult == "")
                                    {
                                        strResult = oAD.JoinGroup(strID, strGroups[ii], 0);
                                        if (strResult == "")
                                        {
                                            strNotify += "<tr><td>The account " + strID + " was successfully added to the domain group " + strGroups[ii] + "</td></tr>";
                                        }
                                        else
                                        {
                                            strNotify += "<tr><td>There was a problem adding the account " + strID + " to the domain group " + strGroups[ii] + "</td></tr>";
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        strNotify += "<tr><td>There was a problem creating an account for " + strFName + " " + strLName + " in " + oVar.Name() + " - ERROR: " + strResult + "</td></tr>";
                    }
                    strNotify += "</table></p>";
                    //strNotify += "</table></div></p>";
                    Complete(_id);
                    oRequest.AddResult(_requestid, _itemid, _number, strNotify);
                }
            }
        }
예제 #10
0
        protected void btnGo_Click(object sender, EventArgs e)
        {
            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\temp\\destroys.xls;Extended Properties=Excel 8.0;";

            System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
            ClearViewWebServices         oServiceNow  = new ClearViewWebServices();

            oServiceNow.Timeout     = Timeout.Infinite;
            oServiceNow.Credentials = oCredentials;
            oServiceNow.Url         = oVariable.WebServiceURL();

            System.Net.NetworkCredential oCredentialsSN = new System.Net.NetworkCredential(oVariable.ServiceNowUsername(), oVariable.ServiceNowPassword());
            string url  = oVariable.ServiceNowHost();
            string user = oVariable.ServiceNowUsername();
            string pass = oVariable.ServiceNowPassword();

            OleDbDataAdapter myCommand1 = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn);
            DataSet          ds1        = new DataSet();

            myCommand1.Fill(ds1, "ExcelInfo");
            foreach (DataRow dr in ds1.Tables[0].Rows)
            {
                if (dr[0].ToString().Trim() == "")
                {
                    break;
                }
                string name = dr[0].ToString().Trim();
                Response.Write(name + "...");
                if (name.Contains("-DR") == false)
                {
                    // Ping server name
                    Ping   ping     = new Ping();
                    string response = "";
                    try
                    {
                        PingReply reply = ping.Send(name);
                        response = reply.Status.ToString().ToUpper();
                    }
                    catch { }
                    Response.Write((response == "SUCCESS" ? "** ONLINE **" : "offline") + "...");

                    // Check Service Now
                    string result = oServiceNow.GetServiceNowServer(url, user, pass, name);
                    if (String.IsNullOrEmpty(result) == false)
                    {
                        int _state = result.IndexOf("<u_desired_operational_state");
                        if (_state > -1)
                        {
                            string state = result.Substring(_state);
                            state = state.Substring(state.IndexOf(">") + 1);
                            state = state.Substring(0, state.IndexOf("<"));
                            if (state == "-2")
                            {
                                Response.Write("decommissioned" + "...");
                            }
                            else
                            {
                                Response.Write("** " + state + " **...");
                            }
                        }
                        else
                        {
                            Response.Write("** missing desired operational state **...");
                        }

                        int _status = result.IndexOf("<install_status");
                        if (_status > -1)
                        {
                            string status = result.Substring(_status);
                            status = status.Substring(status.IndexOf(">") + 1);
                            status = status.Substring(0, status.IndexOf("<"));
                            if (status == "7")
                            {
                                Response.Write("retired" + "...");
                            }
                            else
                            {
                                Response.Write("** " + status + " **...");
                            }
                        }
                        else
                        {
                            Response.Write("** missing install status **...");
                        }
                    }
                    else
                    {
                        Response.Write("** NOT THERE **" + "...");
                    }
                }
                else
                {
                    Response.Write("dr");
                }

                Response.Write("<br/>");
            }
        }
예제 #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string      strResult    = "";
            string      strError     = "";
            Servers     oServer      = new Servers(0, dsn);
            OnDemand    oOnDemand    = new OnDemand(0, dsn);
            IPAddresses oIPAddresses = new IPAddresses(0, dsnIP, dsn);

            oVMWare = new VMWare(0, dsn);

            string strName          = "healytest2";
            string strCluster       = "CDALVMTEST01";
            string strDatastore1    = "dt01-ibm-lun1";
            string strDatastore2    = "";
            string strVLAN          = "VLAN52";
            string strPortGroupName = "dvPortGroup255";
            string strMACAddress    = "";
            string strResourcePool  = "";
            string strMDTos         = "WABEx64";
            string strMDTtask       = "W2K8R2_ENT";
            string strMDTbuildDB    = "ServerShare";
            double dblDriveC        = 27.5;
            double dblDrive2        = 2.5;
            string strVMguestOS     = "winNetEnterprise64Guest";

            intEnvironment = 999;
            string strConnect = oVMWare.ConnectDEBUG("https://wdsvt100a/sdk", intEnvironment, "PNC");

            if (Request.QueryString["old"] != null)
            {
                strName        = "healytest";
                strCluster     = "ohcinxcv4003";
                strDatastore1  = "CINDSSVCN40063";
                strVLAN        = "vlan250net";
                intEnvironment = 3;
                strConnect     = oVMWare.ConnectDEBUG("https://ohcinutl4003/sdk", intEnvironment, "Dalton");
            }
            if (Request.QueryString["w"] != null)
            {
                strName          = "healytest2";
                strCluster       = "CLEVDTLAB01";
                strDatastore1    = "VDItest";
                strDatastore2    = "pagefile01";
                strPortGroupName = "dvPortGroup";
                strResourcePool  = "VDI";
                strMDTos         = "DesktopWABEx86";
                strMDTtask       = "VDIXP";
                strMDTbuildDB    = "DesktopDeploymentShare";
                strVMguestOS     = "windows7_64Guest";
                strConnect       = oVMWare.ConnectDEBUG("https://vwsvt102/sdk", intEnvironment, "PNC-TestLab");
            }
            if (Request.QueryString["t"] != null)
            {
                strName          = "healyTest2012";
                strCluster       = "CLESVTLAB01";
                dblDriveC        = 45.00;
                strDatastore1    = "CTVXN00008";
                strDatastore2    = "CTVXN00008";
                dblDrive2        = 10.00;
                strPortGroupName = "dvPortGroup5";  // DHCP enabled
                strMDTos         = "WABEx64";
                strMDTtask       = "W2K8R2_STD";
                strMDTbuildDB    = "ServerShare";
                strVMguestOS     = "windows8Server64Guest";
                strConnect       = oVMWare.ConnectDEBUG("https://wcsvt013a.pnceng.pvt/sdk", (int)CurrentEnvironment.PNCENG, "PNC");
            }
            Variables oVariable = new Variables(intEnvironment);

            if (strConnect == "")
            {
                VimService             _service            = oVMWare.GetService();
                ServiceContent         _sic                = oVMWare.GetSic();
                ManagedObjectReference datacenterRef       = oVMWare.GetDataCenter();
                ManagedObjectReference vmFolderRef         = oVMWare.GetVMFolder(datacenterRef);
                ManagedObjectReference clusterRef          = oVMWare.GetCluster(strCluster);
                ManagedObjectReference resourcePoolRootRef = (ManagedObjectReference)oVMWare.getObjectProperty(clusterRef, "resourcePool");
                if (strResourcePool != "")
                {
                    resourcePoolRootRef = oVMWare.GetResourcePool(clusterRef, strResourcePool);
                }
                VirtualMachineConfigSpec oConfig = new VirtualMachineConfigSpec();

                int intStep = 0;
                Int32.TryParse(Request.QueryString["s"], out intStep);

                string strUUID = "";
                ManagedObjectReference oComputer = null;
                if (intStep == 100 || intStep == 1)
                {
                    if (oComputer != null && oComputer.Value != "")
                    {
                        // Destroy computer
                        ManagedObjectReference _task_power = _service.Destroy_Task(oComputer);
                        TaskInfo _info_power = (TaskInfo)oVMWare.getObjectProperty(_task_power, "info");
                        while (_info_power.state == TaskInfoState.running)
                        {
                            _info_power = (TaskInfo)oVMWare.getObjectProperty(_task_power, "info");
                        }
                        if (_info_power.state == TaskInfoState.success)
                        {
                            strResult += "Virtual Machine " + strName.ToUpper() + " Destroyed<br/>";
                        }
                        else
                        {
                            strError = "Virtual Machine was not destroyed";
                        }
                    }
                    if (strError == "")
                    {
                        // Create computer
                        oConfig.annotation = "Blah, Blah, Blah" + Environment.NewLine + "Next Line";
                        oConfig.guestId    = strVMguestOS;
                        oConfig.firmware   = "efi";
                        string strRamConfig = "2048";
                        oConfig.memoryMB          = long.Parse(strRamConfig);
                        oConfig.memoryMBSpecified = true;
                        int intCpuConfig = 1;
                        oConfig.numCPUs          = intCpuConfig;
                        oConfig.numCPUsSpecified = true;
                        oConfig.name             = strName.ToLower();
                        oConfig.files            = new VirtualMachineFileInfo();
                        oConfig.files.vmPathName = "[" + strDatastore1 + "] " + strName.ToLower() + "/" + strName.ToLower() + ".vmx";

                        ManagedObjectReference _task = _service.CreateVM_Task(vmFolderRef, oConfig, resourcePoolRootRef, null);
                        TaskInfo oInfo = (TaskInfo)oVMWare.getObjectProperty(_task, "info");
                        while (oInfo.state == TaskInfoState.running)
                        {
                            oInfo = (TaskInfo)oVMWare.getObjectProperty(_task, "info");
                        }
                        if (oInfo.state == TaskInfoState.success)
                        {
                            oComputer = (ManagedObjectReference)oInfo.result;
                            VirtualMachineConfigInfo _temp = (VirtualMachineConfigInfo)oVMWare.getObjectProperty(oComputer, "config");
                            strResult += "Virtual Machine " + strName.ToUpper() + " Created (" + _temp.uuid + ")<br/>";
                        }
                        else
                        {
                            strError = "Virtual Machine was not created";
                        }
                    }
                }

                if (intStep > 1)
                {
                    oComputer = oVMWare.GetVM(strName);
                }

                if ((intStep == 100 || intStep == 2) && strError == "")
                {
                    // 2) SCSI Controller
                    VirtualMachineConfigSpec _cs_scsi      = new VirtualMachineConfigSpec();
                    VirtualDeviceConfigSpec  controlVMSpec = Controller(true);
                    _cs_scsi.deviceChange = new VirtualDeviceConfigSpec[] { controlVMSpec };
                    ManagedObjectReference _task_scsi = _service.ReconfigVM_Task(oComputer, _cs_scsi);
                    TaskInfo _inf_scsi = (TaskInfo)oVMWare.getObjectProperty(_task_scsi, "info");
                    while (_inf_scsi.state == TaskInfoState.running)
                    {
                        _inf_scsi = (TaskInfo)oVMWare.getObjectProperty(_task_scsi, "info");
                    }
                    if (_inf_scsi.state == TaskInfoState.success)
                    {
                        strResult += "SCSI Controller Created<br/>";
                    }
                    else
                    {
                        strError = "SCSI Controller Was Not Created";
                    }
                }

                if ((intStep == 100 || intStep == 3) && strError == "")
                {
                    // 3) Create Hard Disk 1
                    VirtualMachineConfigSpec _cs_hdd1 = new VirtualMachineConfigSpec();
                    dblDriveC = dblDriveC * 1024.00 * 1024.00;
                    VirtualDeviceConfigSpec diskVMSpec1 = Disk(oVMWare, strName, strDatastore1, dblDriveC.ToString(), 0, "");    // 10485760 KB = 10 GB = 10 x 1024 x 1024
                    _cs_hdd1.deviceChange = new VirtualDeviceConfigSpec[] { diskVMSpec1 };
                    ManagedObjectReference _task_hdd1 = _service.ReconfigVM_Task(oComputer, _cs_hdd1);
                    TaskInfo _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                    while (_info_hdd1.state == TaskInfoState.running)
                    {
                        _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                    }
                    if (_info_hdd1.state == TaskInfoState.success)
                    {
                        strResult += "Hard Drive Created (" + dblDriveC.ToString() + ")<br/>";
                    }
                    else
                    {
                        strError = "Hard Drive Was Not Created";
                    }
                }

                if ((intStep == 100 || intStep == 33) && strError == "")
                {
                    if (strDatastore2 != "")
                    {
                        // 33) Create Hard Disk 2
                        VirtualMachineConfigSpec _cs_hdd1 = new VirtualMachineConfigSpec();
                        dblDrive2 = dblDrive2 * 1024.00 * 1024.00;
                        VirtualDeviceConfigSpec diskVMSpec1 = Disk(oVMWare, strName, strDatastore2, dblDrive2.ToString(), 1, (strDatastore1 == strDatastore2 ? "_1" : ""));    // 10485760 KB = 10 GB = 10 x 1024 x 1024
                        _cs_hdd1.deviceChange = new VirtualDeviceConfigSpec[] { diskVMSpec1 };
                        ManagedObjectReference _task_hdd1 = _service.ReconfigVM_Task(oComputer, _cs_hdd1);
                        TaskInfo _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                        while (_info_hdd1.state == TaskInfoState.running)
                        {
                            _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                        }
                        if (_info_hdd1.state == TaskInfoState.success)
                        {
                            strResult += "Hard Drive # 2 Created (" + dblDrive2.ToString() + ")<br/>";
                        }
                        else
                        {
                            strError = "Hard Drive # 2 Was Not Created";
                        }
                    }
                }

                if ((intStep == 100 || intStep == 4) && strError == "")
                {
                    // 4) Create Network Adapter
                    bool boolISVmware4 = true;
                    if (boolISVmware4 == false)
                    {
                        VirtualDeviceConfigSpec[]             configspecarr = configspecarr = new VirtualDeviceConfigSpec[1];
                        VirtualEthernetCardNetworkBackingInfo vecnbi        = new VirtualEthernetCardNetworkBackingInfo();
                        vecnbi.deviceName = strVLAN;
                        VirtualEthernetCard newethdev;
                        //newethdev = new VirtualE1000();
                        newethdev = new VirtualVmxnet3();
                        //      ******** OTHER WAY = newethdev = new VirtualPCNet32();
                        newethdev.backing = vecnbi;
                        newethdev.key     = 5000;
                        VirtualDeviceConfigSpec newethdevicespec = new VirtualDeviceConfigSpec();
                        newethdevicespec.device             = newethdev;
                        newethdevicespec.operation          = VirtualDeviceConfigSpecOperation.add;
                        newethdevicespec.operationSpecified = true;
                        configspecarr[0] = newethdevicespec;
                        VirtualMachineConfigSpec vmconfigspec = new VirtualMachineConfigSpec();
                        vmconfigspec.deviceChange = configspecarr;
                        ManagedObjectReference _task_net = _service.ReconfigVM_Task(oComputer, vmconfigspec);
                        TaskInfo _info_net = (TaskInfo)oVMWare.getObjectProperty(_task_net, "info");
                        while (_info_net.state == TaskInfoState.running)
                        {
                            _info_net = (TaskInfo)oVMWare.getObjectProperty(_task_net, "info");
                        }
                        if (_info_net.state == TaskInfoState.success)
                        {
                            strResult += "Network Adapter Created<br/>";
                        }
                        else
                        {
                            strError = "Network Adapter Was Not Created";
                        }
                    }
                    else
                    {
                        bool   boolCompleted               = false;
                        string strPortGroupKey             = "";
                        ManagedObjectReference[] oNetworks = (ManagedObjectReference[])oVMWare.getObjectProperty(datacenterRef, "network");
                        foreach (ManagedObjectReference oNetwork in oNetworks)
                        {
                            if (boolCompleted == true)
                            {
                                break;
                            }
                            try
                            {
                                if (strPortGroupName == "" || strPortGroupName == oVMWare.getObjectProperty(oNetwork, "name").ToString())
                                {
                                    object oPortConfig = oVMWare.getObjectProperty(oNetwork, "config");
                                    if (oPortConfig != null)
                                    {
                                        DVPortgroupConfigInfo oPort = (DVPortgroupConfigInfo)oPortConfig;
                                        if (oPort.key != strPortGroupKey)
                                        {
                                            strPortGroupKey = oPort.key;
                                            ManagedObjectReference oSwitch = oPort.distributedVirtualSwitch;
                                            string strSwitchUUID           = (string)oVMWare.getObjectProperty(oSwitch, "uuid");
                                            Response.Write("Trying..." + strPortGroupKey + "(" + strSwitchUUID + ")" + "<br/>");

                                            VirtualDeviceConfigSpec[] configspecarr = configspecarr = new VirtualDeviceConfigSpec[1];
                                            VirtualEthernetCardDistributedVirtualPortBackingInfo vecdvpbi = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
                                            DistributedVirtualSwitchPortConnection connection             = new DistributedVirtualSwitchPortConnection();
                                            connection.portgroupKey = strPortGroupKey;
                                            connection.switchUuid   = strSwitchUUID;
                                            vecdvpbi.port           = connection;
                                            //VirtualEthernetCard newethdev = new VirtualE1000();
                                            VirtualEthernetCard newethdev = new VirtualVmxnet3();
                                            //      ******** OTHER WAY = newethdev = new VirtualPCNet32();
                                            newethdev.backing = vecdvpbi;
                                            newethdev.key     = 5000;
                                            VirtualDeviceConfigSpec newethdevicespec = new VirtualDeviceConfigSpec();
                                            newethdevicespec.device             = newethdev;
                                            newethdevicespec.operation          = VirtualDeviceConfigSpecOperation.add;
                                            newethdevicespec.operationSpecified = true;
                                            configspecarr[0] = newethdevicespec;
                                            VirtualMachineConfigSpec vmconfigspec = new VirtualMachineConfigSpec();
                                            vmconfigspec.deviceChange = configspecarr;
                                            ManagedObjectReference _task_net = _service.ReconfigVM_Task(oComputer, vmconfigspec);
                                            TaskInfo _info_net = (TaskInfo)oVMWare.getObjectProperty(_task_net, "info");
                                            while (_info_net.state == TaskInfoState.running)
                                            {
                                                _info_net = (TaskInfo)oVMWare.getObjectProperty(_task_net, "info");
                                            }
                                            if (_info_net.state == TaskInfoState.success)
                                            {
                                                strResult    += "Network Adapter Created<br/>";
                                                boolCompleted = true;
                                            }
                                            //break;
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                // Only hits here if it is not a "DistributedVirtualPortgroup" (meaning it is a standard NETWORK object)
                            }
                        }
                        if (boolCompleted == false)
                        {
                            strError = "Network Adapter Was Not Created ~ Could not find a port group";
                        }
                    }
                }
                if ((intStep == 100 || intStep == 5) && strError == "")
                {
                    VirtualMachineConfigSpec _cs_swap = new VirtualMachineConfigSpec();
                    _cs_swap.swapPlacement = "hostLocal";
                    ManagedObjectReference _task_swap = _service.ReconfigVM_Task(oComputer, _cs_swap);
                    TaskInfo _info_swap = (TaskInfo)oVMWare.getObjectProperty(_task_swap, "info");
                    while (_info_swap.state == TaskInfoState.running)
                    {
                        _info_swap = (TaskInfo)oVMWare.getObjectProperty(_task_swap, "info");
                    }
                    if (_info_swap.state == TaskInfoState.success)
                    {
                        strResult += "Swap File Configured<br/>";
                    }
                    else
                    {
                        strError = "Swap File Was Not Configured";
                    }

                    /*
                     * // 5) Attach Floppy Drive
                     * VirtualMachineConfigSpec _cs_floppy = new VirtualMachineConfigSpec();
                     * VirtualDeviceConfigSpec _dcs_floppy = new VirtualDeviceConfigSpec();
                     * _dcs_floppy.operation = VirtualDeviceConfigSpecOperation.add;
                     * _dcs_floppy.operationSpecified = true;
                     * VirtualDeviceConnectInfo _ci_floppy = new VirtualDeviceConnectInfo();
                     * _ci_floppy.startConnected = false;
                     * VirtualFloppy floppy = new VirtualFloppy();
                     * VirtualFloppyRemoteDeviceBackingInfo floppyBack = new VirtualFloppyRemoteDeviceBackingInfo();
                     * floppyBack.deviceName = "";
                     * floppy.backing = floppyBack;
                     * floppy.key = 8000;
                     * floppy.controllerKey = 400;
                     * floppy.controllerKeySpecified = true;
                     * floppy.connectable = _ci_floppy;
                     * _dcs_floppy.device = floppy;
                     * _cs_floppy.deviceChange = new VirtualDeviceConfigSpec[] { _dcs_floppy };
                     * ManagedObjectReference _task_floppy = _service.ReconfigVM_Task(oComputer, _cs_floppy);
                     * TaskInfo _info_floppy = (TaskInfo)oVMWare.getObjectProperty(_task_floppy, "info");
                     * while (_info_floppy.state == TaskInfoState.running)
                     *  _info_floppy = (TaskInfo)oVMWare.getObjectProperty(_task_floppy, "info");
                     * if (_info_floppy.state == TaskInfoState.success)
                     *  strResult += "Floppy Drive Created<br/>";
                     * else
                     *  strError = "Floppy Drive Was Not Created";
                     */
                }

                if ((intStep == 100 || intStep == 6) && strError == "")
                {
                    // 6) Attach CD-ROM Drive
                    VirtualMachineConfigSpec _cs_cd  = new VirtualMachineConfigSpec();
                    VirtualDeviceConfigSpec  _dcs_cd = new VirtualDeviceConfigSpec();
                    _dcs_cd.operation          = VirtualDeviceConfigSpecOperation.add;
                    _dcs_cd.operationSpecified = true;
                    VirtualDeviceConnectInfo _ci_cd = new VirtualDeviceConnectInfo();
                    _ci_cd.startConnected = false;
                    VirtualCdrom cd = new VirtualCdrom();
                    VirtualCdromRemotePassthroughBackingInfo cdBack = new VirtualCdromRemotePassthroughBackingInfo();
                    cdBack.exclusive          = false;
                    cdBack.deviceName         = "";
                    cd.backing                = cdBack;
                    cd.key                    = 3000;
                    cd.controllerKey          = 200;
                    cd.controllerKeySpecified = true;
                    cd.connectable            = _ci_cd;
                    _dcs_cd.device            = cd;
                    _cs_cd.deviceChange       = new VirtualDeviceConfigSpec[] { _dcs_cd };
                    ManagedObjectReference _task_cd = _service.ReconfigVM_Task(oComputer, _cs_cd);
                    TaskInfo _info_cd = (TaskInfo)oVMWare.getObjectProperty(_task_cd, "info");
                    while (_info_cd.state == TaskInfoState.running)
                    {
                        _info_cd = (TaskInfo)oVMWare.getObjectProperty(_task_cd, "info");
                    }
                    if (_info_cd.state == TaskInfoState.success)
                    {
                        strResult += "CD-ROM Was Created<br/>";
                    }
                    else
                    {
                        strError = "CD-ROM Was Not Created";
                    }
                }

                if ((intStep == 100 || intStep == 7) && strError == "")
                {
                    // 7) Boot Delay
                    VirtualMachineBootOptions oBootOptions = new VirtualMachineBootOptions();
                    oBootOptions.bootDelay          = 10000;
                    oBootOptions.bootDelaySpecified = true;
                    VirtualMachineConfigSpec _cs_boot_options = new VirtualMachineConfigSpec();
                    _cs_boot_options.bootOptions = oBootOptions;
                    ManagedObjectReference _task_boot_options = _service.ReconfigVM_Task(oComputer, _cs_boot_options);
                    TaskInfo _info_boot_options = (TaskInfo)oVMWare.getObjectProperty(_task_boot_options, "info");
                    while (_info_boot_options.state == TaskInfoState.running)
                    {
                        _info_boot_options = (TaskInfo)oVMWare.getObjectProperty(_task_boot_options, "info");
                    }
                    if (_info_boot_options.state == TaskInfoState.success)
                    {
                        strResult += "Boot delay changed to 10 seconds<br/>";
                    }
                    else
                    {
                        strError = "Boot delay NOT changed";
                    }
                }

                if ((intStep == 100 || intStep == 8) && strError == "")
                {
                    // 8) Get MAC Address
                    VirtualMachineConfigInfo _vminfo = (VirtualMachineConfigInfo)oVMWare.getObjectProperty(oComputer, "config");
                    VirtualDevice[]          _device = _vminfo.hardware.device;
                    for (int ii = 0; ii < _device.Length; ii++)
                    {
                        // 4/29/2009: Change to only one NIC for PNC
                        if (_device[ii].deviceInfo.label.ToUpper() == "NETWORK ADAPTER 1")
                        {
                            VirtualEthernetCard nic = (VirtualEthernetCard)_device[ii];
                            strMACAddress = nic.macAddress;
                            break;
                        }
                    }
                    if (strMACAddress != "")
                    {
                        strResult += "MAC Address = " + strMACAddress + "<br/>";
                    }
                    else
                    {
                        strError = "No MAC Address";
                    }
                }

                if ((intStep == 100 || intStep == 9) && strError == "")
                {
                    // 9) Configure WebService
                    System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
                    BuildSubmit oMDT = new BuildSubmit();
                    oMDT.Credentials = oCredentials;
                    oMDT.Url         = "http://wcrdp100a.pnceng.pvt/wabebuild/BuildSubmit.asmx";
                    string[] strExtendedMDT  = new string[] { "PNCBACKUPSOFTWARE:NONE", "IISInstall:NO", "HWConfig:DEFAULT", "ESMInstall:NO", "ClearViewInstall:YES", "Teamed2:DEFAULT", "HIDSInstall:NO" };
                    string   strExtendedMDTs = "";
                    foreach (string extendedMDT in strExtendedMDT)
                    {
                        if (strExtendedMDTs != "")
                        {
                            strExtendedMDTs += ", ";
                        }
                        strExtendedMDTs += extendedMDT;
                    }
                    string strOutput = oMDT.automatedBuild2(strName.ToUpper(), strMACAddress, strMDTos, "provision", "PNCNT", strMDTtask, strMDTbuildDB, strExtendedMDT);
                    strResult += "WebService Configured " + strOutput + "<br/>";
                }

                if ((intStep == 100 || intStep == 10) && strError == "")
                {
                    // 10) Power On
                    GuestInfo ginfo_power = (GuestInfo)oVMWare.getObjectProperty(oComputer, "guest");
                    if (ginfo_power.guestState.ToUpper() == "NOTRUNNING" || ginfo_power.guestState.ToUpper() == "UNKNOWN")
                    {
                        ManagedObjectReference _task_power = _service.PowerOnVM_Task(oComputer, null);
                        TaskInfo _info_power = (TaskInfo)oVMWare.getObjectProperty(_task_power, "info");
                        while (_info_power.state == TaskInfoState.running)
                        {
                            _info_power = (TaskInfo)oVMWare.getObjectProperty(_task_power, "info");
                        }
                        if (_info_power.state == TaskInfoState.success)
                        {
                            strResult += "Virtual Machine Powered On";
                        }
                        else
                        {
                            strError = "Virtual Machine Was Not Powered On";
                        }
                    }
                    else
                    {
                        strResult += "Virtual Machine Was Already Powered On (" + ginfo_power.guestState + ")";
                    }
                }

                // Logout
                if (_service != null)
                {
                    _service.Abort();
                    if (_service.Container != null)
                    {
                        _service.Container.Dispose();
                    }
                    try
                    {
                        _service.Logout(_sic.sessionManager);
                    }
                    catch { }
                    _service.Dispose();
                    _service = null;
                    _sic     = null;
                }

                Response.Write("RESULT(s): " + strResult);
                Response.Write("ERROR: " + strError);
            }
            else
            {
                Response.Write("LOGIN error");
            }
        }
예제 #12
0
        private double CompareDomainAccounts(int _search_domain, int _searched_domain, string _account_preface, int _accounts, int _requestid)
        {
            double            dblHours  = 0.00;
            double            dblTime   = 5.00 / 60.00;
            Variables         vDev      = new Variables(_search_domain);
            Variables         vProd     = new Variables(_searched_domain);
            ADObject          oADObject = new ADObject(0, dsn);
            DirectoryEntry    oDev      = new DirectoryEntry(vDev.primaryDC(dsn), vDev.ADUser(), vDev.ADPassword());
            DirectoryEntry    oProd     = new DirectoryEntry(vProd.primaryDC(dsn), vProd.ADUser(), vProd.ADPassword());
            DirectorySearcher sDev      = new DirectorySearcher(oDev);

            sDev.Filter = "(&(objectCategory=user)(|(sAMAccountName=t*)(|(sAMAccountName=e*)(sAMAccountName=x*))))";
            SearchResultCollection resDevs = sDev.FindAll();

            foreach (SearchResult resDev in resDevs)
            {
                if (_accounts > 0 && intCounter > _accounts)
                {
                    break;
                }
                if (resDev.Properties.Contains("sAMAccountName") == true)
                {
                    string            strXid    = resDev.Properties["sAMAccountName"][0].ToString();
                    string            strNewXid = _account_preface + strXid.Substring(1);
                    DirectorySearcher sProd     = new DirectorySearcher(oProd);
                    sProd.Filter = "(&(objectCategory=user)(sAMAccountName=" + strNewXid + "))";
                    SearchResult resProd = sProd.FindOne();
                    if (resProd == null)
                    {
                        string strFName = "";
                        if (resDev.Properties.Contains("givenname") == true)
                        {
                            strFName = resDev.Properties["givenname"][0].ToString();
                        }
                        string strLName = "";
                        if (resDev.Properties.Contains("sn") == true)
                        {
                            strLName = resDev.Properties["sn"][0].ToString();
                        }
                        string strName = "";
                        if (strFName != "" || strLName != "")
                        {
                            strName = "(" + strFName + " " + strLName + ")";
                        }
                        string strPath = "";
                        if (resDev.Properties.Contains("adspath") == true)
                        {
                            strPath = resDev.Properties["adspath"][0].ToString();
                        }
                        string strDate = "";
                        if (resDev.Properties.Contains("whencreated") == true)
                        {
                            strDate = resDev.Properties["whencreated"][0].ToString();
                        }
                        oADObject.AddDomainAccount(_requestid, _search_domain, strNewXid.ToUpper() + strName, strPath, vDev.Name() + " account not found in " + vProd.Name() + "(" + strNewXid + ")", strDate);
                        intCounter++;
                        dblHours += dblTime;
                    }
                }
            }
            return(dblHours);
        }
예제 #13
0
        protected void btnSync_Click(Object Sender, EventArgs e)
        {
            intMode = radResults.SelectedIndex;
            DateTime datStart = DateTime.Now;
            SearchResultCollection oResults;
            Variables         oVariable = new Variables(intEnvironment);
            DirectoryEntry    oEntry    = new DirectoryEntry(oVariable.primaryDC(dsn), oVariable.ADUser(), oVariable.ADPassword());
            DirectorySearcher oSearcher = new DirectorySearcher(oEntry);

            oSearcher.PageSize  = 100000;
            oSearcher.SizeLimit = 100000;
            if (intMode > -1)
            {
                int      intCounter   = 0;
                string[] letterArray  = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
                string[] letterArray2 = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
                lblResults.Text = "";
                for (int ii = 0; ii < letterArray.Length; ii++)
                {
                    for (int jj = 0; jj < letterArray2.Length; jj++)
                    {
                        string strFilter = "(&(objectCategory=user)(sAMAccountName=" + txtSync.Text + letterArray[ii] + letterArray[jj] + "*))";
                        oSearcher.Filter = strFilter;
                        oResults         = oSearcher.FindAll();
                        if (intMode == 1 || intMode == 3 || intMode == 5)
                        {
                            try
                            {
                                foreach (SearchResult oResult in oResults)
                                {
                                    if (oResult.Properties.Contains("extensionattribute10") == true || oResult.Properties.Contains("sAMAccountName") == true)
                                    {
                                        string strXid = "";
                                        if (oResult.Properties.Contains("extensionattribute10") == true)
                                        {
                                            strXid = oResult.GetDirectoryEntry().Properties["extensionattribute10"].Value.ToString();
                                        }
                                        else
                                        {
                                            strXid = oResult.GetDirectoryEntry().Properties["sAMAccountName"].Value.ToString();
                                        }
                                        if (intMode < 4)
                                        {
                                            intCounter++;
                                            lblResults.Text += intCounter.ToString() + ") ...Trying..." + strXid;
                                        }
                                        string strFName = "";
                                        if (oResult.Properties.Contains("givenname") == true)
                                        {
                                            strFName = oResult.GetDirectoryEntry().Properties["givenname"].Value.ToString();
                                        }
                                        string strLName = "";
                                        if (oResult.Properties.Contains("sn") == true)
                                        {
                                            strLName = oResult.GetDirectoryEntry().Properties["sn"].Value.ToString();
                                        }
                                        AddUser(strXid, strFName, strLName);
                                    }
                                }
                            }
                            catch { }
                        }
                        else
                        {
                            foreach (SearchResult oResult in oResults)
                            {
                                if (oResult.Properties.Contains("sAMAccountName") == true)
                                {
                                    string strXid = oResult.GetDirectoryEntry().Properties["sAMAccountName"].Value.ToString();
                                    if (intMode < 4)
                                    {
                                        intCounter++;
                                        lblResults.Text += intCounter.ToString() + ") ...Trying..." + strXid;
                                    }
                                    string strFName = "";
                                    if (oResult.Properties.Contains("givenname") == true)
                                    {
                                        strFName = oResult.GetDirectoryEntry().Properties["givenname"].Value.ToString();
                                    }
                                    string strLName = "";
                                    if (oResult.Properties.Contains("sn") == true)
                                    {
                                        strLName = oResult.GetDirectoryEntry().Properties["sn"].Value.ToString();
                                    }
                                    AddUser(strXid, strFName, strLName);
                                }
                            }
                        }
                    }
                }
                lblResults.Text += "<br/><br/><img src=\"" + oVariable.ImageURL() + "/images/check.gif\" border=\"0\" align=\"absmiddle\"/> <b>Done!</b>" + "<br/>";
                DateTime datEnd = DateTime.Now;
                TimeSpan oSpan  = datEnd.Subtract(datStart);
                lblResults.Text += "<br/><br/><b>Total Time:</b> " + oSpan.Minutes.ToString() + "mins, " + oSpan.Seconds.ToString() + "." + oSpan.Milliseconds.ToString() + " secs";
                lblResults.Text += "<br/><br/><b>New Users:</b> " + intUserAdd.ToString();
                lblResults.Text  = "<p><img src=\"" + oVariable.ImageURL() + "/images/bigCheck.gif\" border=\"0\" align=\"absmiddle\"/> <b>ClearView sync has finished!</b></p><br/>" + lblResults.Text;
                Functions oFunction      = new Functions(0, dsn, intEnvironment);
                string    strEMailIdsBCC = oFunction.GetGetEmailAlertsEmailIds("EMAILGRP_DEVELOPER_ALERT");
                if (intMode > 1)
                {
                    oFunction.SendEmail("ClearView Active Directory Sync", strEMailIdsBCC, "", "", "ClearView Active Directory Sync", "<p>" + lblResults.Text + "</p>", true, false);
                }
                else
                {
                    oFunction.SendEmail("ClearView Active Directory Sync", strEMailIdsBCC, "", "", "ClearView Active Directory Sync", "<p>" + lblResults.Text + "</p>", false, false);
                }
            }
            else
            {
                string strFilter = "(&(objectCategory=user)(sAMAccountName=" + txtSync.Text + "*))";
                oSearcher.Filter = strFilter;
                oResults         = oSearcher.FindAll();
                lblResults.Text  = "<p><font color=\"#990000\"><b>*** Please select a sync mode ***</b></font></p><p># of Results: " + oResults.Count + "</p>";
            }
        }
예제 #14
0
        public void Activations(int EnvironmentID)
        {
            // Setup Classes
            Servers            oServer             = new Servers(0, dsn);
            AvamarRegistration oAvamarRegistration = new AvamarRegistration(0, dsn);
            Log       oLog      = new Log(0, dsn);
            Variables oVariable = new Variables(EnvironmentID);

            // Setup Webservice for querying via SSH
            System.Net.NetworkCredential oCredentialsDNS = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
            ClearViewWebServices         oWebService     = new ClearViewWebServices();

            oWebService.Url = oVariable.WebServiceURL();

            DataSet dsActivations = oServer.GetAvamarActivations();

            if (dsActivations.Tables[0].Rows.Count > 0)
            {
                oLog.AddEvent("", "", "Get avamar activations (" + dsActivations.Tables[0].Rows.Count.ToString() + ")", LoggingType.Debug);
                foreach (DataRow drActivation in dsActivations.Tables[0].Rows)
                {
                    ClearResults();

                    int intServer = Int32.Parse(drActivation["id"].ToString());
                    oServer.UpdateAvamarActivationStarted(intServer, DateTime.Now.ToString());
                    int    intAnswer = Int32.Parse(drActivation["answerid"].ToString());
                    string strName   = drActivation["servername"].ToString();
                    string strGrid   = drActivation["grid"].ToString();
                    string strDomain = drActivation["domain"].ToString();
                    string strGroup1 = drActivation["group1"].ToString();
                    string strGroup2 = drActivation["group2"].ToString();
                    string strGroup3 = drActivation["group3"].ToString();

                    oLog.AddEvent(intAnswer, strName, "", "Starting automated Avamar activation", LoggingType.Information);
                    string strError   = "";
                    string strSuccess = "";

                    try
                    {
                        // Activate client
                        AvamarReturnType activate = oAvamarRegistration.API(oWebService.ActivateAvamarClient(strGrid, strDomain, strName));
                        if (activate.Error == false)
                        {
                            strSuccess = activate.Message;
                            // Wait 1/2 minute for synchronization
                            oLog.AddEvent(intAnswer, strName, "", "Activation script complete = " + activate.Message + ".", LoggingType.Information);
                            bool HasActivated = false;
                            for (int ii = 0; ii < 10 && HasActivated == false; ii++)
                            {
                                int activateCount = ii + 1;
                                oLog.AddEvent(intAnswer, strName, "", "Checking activation status (" + activateCount.ToString() + " of 10)...", LoggingType.Debug);
                                AvamarReturnType activated = oAvamarRegistration.API(oWebService.GetAvamarClient(strGrid, strDomain, strName));
                                if (activated.Error == false)
                                {
                                    foreach (XmlNode node in activated.Nodes)
                                    {
                                        if (node["Attribute"].InnerText == "Activated")
                                        {
                                            if (node["Value"].InnerText.Trim().ToUpper() == "YES")
                                            {
                                                HasActivated = true;
                                                oLog.AddEvent(intAnswer, strName, "", "Client has activated!", LoggingType.Information);
                                            }
                                            else
                                            {
                                                oLog.AddEvent(intAnswer, strName, "", "Client is not active. Waiting 30 seconds before retrying...", LoggingType.Debug);
                                                Thread.Sleep(30000);
                                            }
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    strError = "Error while activating - " + activated.Message;
                                    break;
                                }
                            }

                            if (String.IsNullOrEmpty(strError))
                            {
                                if (HasActivated)
                                {
                                    // Initiate backup
                                    oLog.AddEvent(intAnswer, strName, "", "Initiating backup...", LoggingType.Information);
                                    AvamarReturnType start = oAvamarRegistration.API(oWebService.StartAvamarBackup(strGrid, strDomain, strGroup1, strName));
                                    if (start.Error)
                                    {
                                        strError = start.Message + " (" + start.Code + ")";
                                    }
                                    else if (String.IsNullOrEmpty(strGroup2) == false)
                                    {
                                        oLog.AddEvent(intAnswer, strName, "", "Backup for " + strGroup1 + " started = " + start.Message, LoggingType.Information);
                                        AvamarReturnType start2 = oAvamarRegistration.API(oWebService.StartAvamarBackup(strGrid, strDomain, strGroup2, strName));
                                        if (start2.Error)
                                        {
                                            strError = start2.Message + " (" + start2.Code + ")";
                                        }
                                        else if (String.IsNullOrEmpty(strGroup3) == false)
                                        {
                                            oLog.AddEvent(intAnswer, strName, "", "Backup for " + strGroup2 + " started = " + start2.Message, LoggingType.Information);
                                            AvamarReturnType start3 = oAvamarRegistration.API(oWebService.StartAvamarBackup(strGrid, strDomain, strGroup3, strName));
                                            if (start3.Error)
                                            {
                                                strError = start3.Message + " (" + start3.Code + ")";
                                            }
                                            else
                                            {
                                                oLog.AddEvent(intAnswer, strName, "", "Backup for " + strGroup3 + " started = " + start3.Message, LoggingType.Information);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    strError = "Client has not activated after 5 minutes";
                                }
                            }
                        }
                        else
                        {
                            strError = activate.Message + " (" + activate.Code + ")";
                        }
                    }
                    catch (Exception exError)
                    {
                        strError = exError.Message;
                        if (exError.InnerException != null)
                        {
                            strError += " ~ " + exError.InnerException.Message;
                        }
                    }

                    if (strError != "")
                    {
                        oLog.AddEvent(intAnswer, strName, "", strError, LoggingType.Error);
                        oServer.UpdateAvamarActivationCompleted(intServer, "", strError, DateTime.Now.ToString(), 1);
                        oServer.AddError(0, 0, 0, intServer, 906, strError);
                    }
                    else
                    {
                        oLog.AddEvent(intAnswer, strName, "", "Activation completed and backup initiated", LoggingType.Information);
                        oServer.UpdateAvamarActivationCompleted(intServer, "", strSuccess, DateTime.Now.ToString(), 0);
                        oServer.AddAvamarBackup(intServer, strName, strGrid, strDomain, strGroup1);
                    }
                }
            }
        }
예제 #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string      strResult    = "";
            string      strError     = "";
            Servers     oServer      = new Servers(0, dsn);
            OnDemand    oOnDemand    = new OnDemand(0, dsn);
            IPAddresses oIPAddresses = new IPAddresses(0, dsnIP, dsn);

            oVMWare = new VMWare(0, dsn);
            Variables oVariable = new Variables(999);

            string strName          = "healyTest";
            string strCluster       = "CLESVTLAB01";
            double dblDriveC        = 60.00;
            string strDatastore     = "CTVXN00007";
            double dblDrive2        = 10.00;
            double dblDrive3        = 10.00;
            string strPortGroupName = "dvPortGroup5";  // DHCP enabled
            string strMDTos         = "WABEx64";
            string strMDTtask       = "W2K8R2_STD";
            string strMDTbuildDB    = "ServerShare";
            string strVMguestOS     = "windows7Server64Guest";
            string strMACAddress    = "";
            string strResourcePool  = "";

            string strConnect = oVMWare.ConnectDEBUG("https://vwsvt102/sdk", 999, "PNC-TestLab");

            if (strConnect == "")
            {
                VimService             _service            = oVMWare.GetService();
                ServiceContent         _sic                = oVMWare.GetSic();
                ManagedObjectReference datacenterRef       = oVMWare.GetDataCenter();
                ManagedObjectReference vmFolderRef         = oVMWare.GetVMFolder(datacenterRef);
                ManagedObjectReference clusterRef          = oVMWare.GetCluster(strCluster);
                ManagedObjectReference resourcePoolRootRef = (ManagedObjectReference)oVMWare.getObjectProperty(clusterRef, "resourcePool");
                if (strResourcePool != "")
                {
                    resourcePoolRootRef = oVMWare.GetResourcePool(clusterRef, strResourcePool);
                }
                VirtualMachineConfigSpec oConfig = new VirtualMachineConfigSpec();

                // Create computer
                ManagedObjectReference oComputer = null;
                oConfig.annotation = "Blah, Blah, Blah" + Environment.NewLine + "Next Line";
                oConfig.guestId    = strVMguestOS;
                string strRamConfig = "2048";
                oConfig.memoryMB          = long.Parse(strRamConfig);
                oConfig.memoryMBSpecified = true;
                int intCpuConfig = 1;
                oConfig.numCPUs          = intCpuConfig;
                oConfig.numCPUsSpecified = true;
                oConfig.name             = strName.ToLower();
                oConfig.files            = new VirtualMachineFileInfo();
                oConfig.files.vmPathName = "[" + strDatastore + "] " + strName.ToLower() + "/" + strName.ToLower() + ".vmx";

                ManagedObjectReference _task = _service.CreateVM_Task(vmFolderRef, oConfig, resourcePoolRootRef, null);
                TaskInfo oInfo = (TaskInfo)oVMWare.getObjectProperty(_task, "info");
                while (oInfo.state == TaskInfoState.running)
                {
                    oInfo = (TaskInfo)oVMWare.getObjectProperty(_task, "info");
                }
                if (oInfo.state == TaskInfoState.success)
                {
                    oComputer = (ManagedObjectReference)oInfo.result;
                    VirtualMachineConfigInfo _temp = (VirtualMachineConfigInfo)oVMWare.getObjectProperty(oComputer, "config");
                    strResult += "Virtual Machine " + strName.ToUpper() + " Created (" + _temp.uuid + ")<br/>";
                }
                else
                {
                    strError = "Virtual Machine was not created";
                }


                if (strError == "")
                {
                    // 2) SCSI Controller 1
                    VirtualMachineConfigSpec _cs_scsi      = new VirtualMachineConfigSpec();
                    VirtualDeviceConfigSpec  controlVMSpec = Controller(0, 2, 1000);
                    _cs_scsi.deviceChange = new VirtualDeviceConfigSpec[] { controlVMSpec };
                    ManagedObjectReference _task_scsi = _service.ReconfigVM_Task(oComputer, _cs_scsi);
                    TaskInfo _inf_scsi = (TaskInfo)oVMWare.getObjectProperty(_task_scsi, "info");
                    while (_inf_scsi.state == TaskInfoState.running)
                    {
                        _inf_scsi = (TaskInfo)oVMWare.getObjectProperty(_task_scsi, "info");
                    }
                    if (_inf_scsi.state == TaskInfoState.success)
                    {
                        strResult += "SCSI Controller # 1 Created<br/>";
                    }
                    else
                    {
                        strError = "SCSI Controller # 1 Was Not Created";
                    }
                }


                if (strError == "")
                {
                    // 3) Create Hard Disk 1
                    VirtualMachineConfigSpec _cs_hdd1 = new VirtualMachineConfigSpec();
                    dblDriveC = dblDriveC * 1024.00 * 1024.00;
                    VirtualDeviceConfigSpec diskVMSpec1 = Disk(oVMWare, strName, strDatastore, dblDriveC.ToString(), 0, 1000, "");
                    _cs_hdd1.deviceChange = new VirtualDeviceConfigSpec[] { diskVMSpec1 };
                    ManagedObjectReference _task_hdd1 = _service.ReconfigVM_Task(oComputer, _cs_hdd1);
                    TaskInfo _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                    while (_info_hdd1.state == TaskInfoState.running)
                    {
                        _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                    }
                    if (_info_hdd1.state == TaskInfoState.success)
                    {
                        strResult += "Hard Drive # 1 Created (" + dblDriveC.ToString() + ")<br/>";
                    }
                    else
                    {
                        strError = "Hard Drive # 1 Was Not Created";
                    }
                }


                if (strError == "")
                {
                    // 4) Create Hard Disk 2
                    VirtualMachineConfigSpec _cs_hdd1 = new VirtualMachineConfigSpec();
                    dblDrive2 = dblDrive2 * 1024.00 * 1024.00;
                    VirtualDeviceConfigSpec diskVMSpec1 = Disk(oVMWare, strName, strDatastore, dblDrive2.ToString(), 1, 1000, "_2");
                    _cs_hdd1.deviceChange = new VirtualDeviceConfigSpec[] { diskVMSpec1 };
                    ManagedObjectReference _task_hdd1 = _service.ReconfigVM_Task(oComputer, _cs_hdd1);
                    TaskInfo _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                    while (_info_hdd1.state == TaskInfoState.running)
                    {
                        _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                    }
                    if (_info_hdd1.state == TaskInfoState.success)
                    {
                        strResult += "Hard Drive # 2 Created (" + dblDriveC.ToString() + ")<br/>";
                    }
                    else
                    {
                        strError = "Hard Drive # 2 Was Not Created";
                    }
                }


                if (strError == "")
                {
                    // 5) SCSI Controller 2
                    VirtualMachineConfigSpec _cs_scsi      = new VirtualMachineConfigSpec();
                    VirtualDeviceConfigSpec  controlVMSpec = Controller(1, 3, 1001);
                    _cs_scsi.deviceChange = new VirtualDeviceConfigSpec[] { controlVMSpec };
                    ManagedObjectReference _task_scsi = _service.ReconfigVM_Task(oComputer, _cs_scsi);
                    TaskInfo _inf_scsi = (TaskInfo)oVMWare.getObjectProperty(_task_scsi, "info");
                    while (_inf_scsi.state == TaskInfoState.running)
                    {
                        _inf_scsi = (TaskInfo)oVMWare.getObjectProperty(_task_scsi, "info");
                    }
                    if (_inf_scsi.state == TaskInfoState.success)
                    {
                        strResult += "SCSI Controller # 1 Created<br/>";
                    }
                    else
                    {
                        strError = "SCSI Controller # 1 Was Not Created";
                    }
                }


                if (strError == "")
                {
                    // 6) Create Hard Disk 3
                    VirtualMachineConfigSpec _cs_hdd1 = new VirtualMachineConfigSpec();
                    dblDrive3 = dblDrive3 * 1024.00 * 1024.00;
                    VirtualDeviceConfigSpec diskVMSpec1 = Disk(oVMWare, strName, strDatastore, dblDrive3.ToString(), 0, 1001, "_3");
                    _cs_hdd1.deviceChange = new VirtualDeviceConfigSpec[] { diskVMSpec1 };
                    ManagedObjectReference _task_hdd1 = _service.ReconfigVM_Task(oComputer, _cs_hdd1);
                    TaskInfo _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                    while (_info_hdd1.state == TaskInfoState.running)
                    {
                        _info_hdd1 = (TaskInfo)oVMWare.getObjectProperty(_task_hdd1, "info");
                    }
                    if (_info_hdd1.state == TaskInfoState.success)
                    {
                        strResult += "Hard Drive # 3 Created (" + dblDriveC.ToString() + ")<br/>";
                    }
                    else
                    {
                        strError = "Hard Drive # 3 Was Not Created";
                    }
                }

                if (String.IsNullOrEmpty(Request.QueryString["build"]) == false)
                {
                    if (strError == "")
                    {
                        bool   boolCompleted               = false;
                        string strPortGroupKey             = "";
                        ManagedObjectReference[] oNetworks = (ManagedObjectReference[])oVMWare.getObjectProperty(datacenterRef, "network");
                        foreach (ManagedObjectReference oNetwork in oNetworks)
                        {
                            if (boolCompleted == true)
                            {
                                break;
                            }
                            try
                            {
                                if (strPortGroupName == "" || strPortGroupName == oVMWare.getObjectProperty(oNetwork, "name").ToString())
                                {
                                    object oPortConfig = oVMWare.getObjectProperty(oNetwork, "config");
                                    if (oPortConfig != null)
                                    {
                                        DVPortgroupConfigInfo oPort = (DVPortgroupConfigInfo)oPortConfig;
                                        if (oPort.key != strPortGroupKey)
                                        {
                                            strPortGroupKey = oPort.key;
                                            ManagedObjectReference oSwitch = oPort.distributedVirtualSwitch;
                                            string strSwitchUUID           = (string)oVMWare.getObjectProperty(oSwitch, "uuid");
                                            Response.Write("Trying..." + strPortGroupKey + "(" + strSwitchUUID + ")" + "<br/>");

                                            VirtualDeviceConfigSpec[] configspecarr = configspecarr = new VirtualDeviceConfigSpec[1];
                                            VirtualEthernetCardDistributedVirtualPortBackingInfo vecdvpbi = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
                                            DistributedVirtualSwitchPortConnection connection             = new DistributedVirtualSwitchPortConnection();
                                            connection.portgroupKey = strPortGroupKey;
                                            connection.switchUuid   = strSwitchUUID;
                                            vecdvpbi.port           = connection;
                                            //VirtualEthernetCard newethdev = new VirtualE1000();
                                            VirtualEthernetCard newethdev = new VirtualVmxnet3();
                                            //      ******** OTHER WAY = newethdev = new VirtualPCNet32();
                                            newethdev.backing = vecdvpbi;
                                            newethdev.key     = 5000;
                                            VirtualDeviceConfigSpec newethdevicespec = new VirtualDeviceConfigSpec();
                                            newethdevicespec.device             = newethdev;
                                            newethdevicespec.operation          = VirtualDeviceConfigSpecOperation.add;
                                            newethdevicespec.operationSpecified = true;
                                            configspecarr[0] = newethdevicespec;
                                            VirtualMachineConfigSpec vmconfigspec = new VirtualMachineConfigSpec();
                                            vmconfigspec.deviceChange = configspecarr;
                                            ManagedObjectReference _task_net = _service.ReconfigVM_Task(oComputer, vmconfigspec);
                                            TaskInfo _info_net = (TaskInfo)oVMWare.getObjectProperty(_task_net, "info");
                                            while (_info_net.state == TaskInfoState.running)
                                            {
                                                _info_net = (TaskInfo)oVMWare.getObjectProperty(_task_net, "info");
                                            }
                                            if (_info_net.state == TaskInfoState.success)
                                            {
                                                strResult    += "Network Adapter Created<br/>";
                                                boolCompleted = true;
                                            }
                                            //break;
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                // Only hits here if it is not a "DistributedVirtualPortgroup" (meaning it is a standard NETWORK object)
                            }
                        }
                        if (boolCompleted == false)
                        {
                            strError = "Network Adapter Was Not Created ~ Could not find a port group";
                        }
                    }

                    if (strError == "")
                    {
                        // 7) Boot Delay
                        VirtualMachineBootOptions oBootOptions = new VirtualMachineBootOptions();
                        oBootOptions.bootDelay          = 10000;
                        oBootOptions.bootDelaySpecified = true;
                        VirtualMachineConfigSpec _cs_boot_options = new VirtualMachineConfigSpec();
                        _cs_boot_options.bootOptions = oBootOptions;
                        ManagedObjectReference _task_boot_options = _service.ReconfigVM_Task(oComputer, _cs_boot_options);
                        TaskInfo _info_boot_options = (TaskInfo)oVMWare.getObjectProperty(_task_boot_options, "info");
                        while (_info_boot_options.state == TaskInfoState.running)
                        {
                            _info_boot_options = (TaskInfo)oVMWare.getObjectProperty(_task_boot_options, "info");
                        }
                        if (_info_boot_options.state == TaskInfoState.success)
                        {
                            strResult += "Boot delay changed to 10 seconds<br/>";
                        }
                        else
                        {
                            strError = "Boot delay NOT changed";
                        }
                    }

                    if (strError == "")
                    {
                        // 8) Get MAC Address
                        VirtualMachineConfigInfo _vminfo = (VirtualMachineConfigInfo)oVMWare.getObjectProperty(oComputer, "config");
                        VirtualDevice[]          _device = _vminfo.hardware.device;
                        for (int ii = 0; ii < _device.Length; ii++)
                        {
                            // 4/29/2009: Change to only one NIC for PNC
                            if (_device[ii].deviceInfo.label.ToUpper() == "NETWORK ADAPTER 1")
                            {
                                VirtualEthernetCard nic = (VirtualEthernetCard)_device[ii];
                                strMACAddress = nic.macAddress;
                                break;
                            }
                        }
                        if (strMACAddress != "")
                        {
                            strResult += "MAC Address = " + strMACAddress + "<br/>";
                        }
                        else
                        {
                            strError = "No MAC Address";
                        }
                    }

                    if (strError == "")
                    {
                        // 9) Configure WebService
                        System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
                        BuildSubmit oMDT = new BuildSubmit();
                        oMDT.Credentials = oCredentials;
                        oMDT.Url         = "http://wcrdp100a.pnceng.pvt/wabebuild/BuildSubmit.asmx";
                        string[] strExtendedMDT  = new string[] { "PNCBACKUPSOFTWARE:NONE", "IISInstall:NO", "HWConfig:DEFAULT", "ESMInstall:NO", "ClearViewInstall:YES", "Teamed2:DEFAULT", "HIDSInstall:NO" };
                        string   strExtendedMDTs = "";
                        foreach (string extendedMDT in strExtendedMDT)
                        {
                            if (strExtendedMDTs != "")
                            {
                                strExtendedMDTs += ", ";
                            }
                            strExtendedMDTs += extendedMDT;
                        }
                        string strOutput = oMDT.automatedBuild2(strName.ToUpper(), strMACAddress, strMDTos, "provision", "PNCNT", strMDTtask, strMDTbuildDB, strExtendedMDT);
                        strResult += "WebService Configured " + strOutput + "<br/>";
                    }

                    if (strError == "")
                    {
                        // 10) Power On
                        GuestInfo ginfo_power = (GuestInfo)oVMWare.getObjectProperty(oComputer, "guest");
                        if (ginfo_power.guestState.ToUpper() == "NOTRUNNING" || ginfo_power.guestState.ToUpper() == "UNKNOWN")
                        {
                            ManagedObjectReference _task_power = _service.PowerOnVM_Task(oComputer, null);
                            TaskInfo _info_power = (TaskInfo)oVMWare.getObjectProperty(_task_power, "info");
                            while (_info_power.state == TaskInfoState.running)
                            {
                                _info_power = (TaskInfo)oVMWare.getObjectProperty(_task_power, "info");
                            }
                            if (_info_power.state == TaskInfoState.success)
                            {
                                strResult += "Virtual Machine Powered On";
                            }
                            else
                            {
                                strError = "Virtual Machine Was Not Powered On";
                            }
                        }
                        else
                        {
                            strResult += "Virtual Machine Was Already Powered On (" + ginfo_power.guestState + ")";
                        }
                    }
                }


                // Logout
                if (_service != null)
                {
                    _service.Abort();
                    if (_service.Container != null)
                    {
                        _service.Container.Dispose();
                    }
                    try
                    {
                        _service.Logout(_sic.sessionManager);
                    }
                    catch { }
                    _service.Dispose();
                    _service = null;
                    _sic     = null;
                }

                Response.Write("RESULT(s): " + strResult);
                Response.Write("ERROR: " + strError);
            }
            else
            {
                Response.Write("LOGIN error");
            }
        }
예제 #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            intProfile        = Int32.Parse(Request.Cookies["profileid"].Value);
            oPage             = new Pages(intProfile, dsn);
            oFunction         = new Functions(intProfile, dsn, intEnvironment);
            oVariable         = new Variables(intEnvironment);
            oWorkstation      = new Workstations(intProfile, dsn);
            oUser             = new Users(intProfile, dsn);
            oRequest          = new Requests(intProfile, dsn);
            oServiceRequest   = new ServiceRequests(intProfile, dsn);
            oLocation         = new Locations(intProfile, dsn);
            oForecast         = new Forecast(intProfile, dsn);
            oType             = new Types(intProfile, dsn);
            oModel            = new Models(intProfile, dsn);
            oModelsProperties = new ModelsProperties(intProfile, dsn);
            oOperatingSystems = new OperatingSystems(intProfile, dsn);
            oVirtualHDD       = new VirtualHDD(intProfile, dsn);
            oVirtualRam       = new VirtualRam(intProfile, dsn);
            oVirtualCPU       = new VirtualCPU(intProfile, dsn);
            oClass            = new Classes(intProfile, dsn);
            oAD = new AD(intProfile, dsn, intEnvironment);

            //Menus
            int intMenuTab = 0;

            if (Request.QueryString["menu_tab"] != null && Request.QueryString["menu_tab"] != "")
            {
                intMenuTab = Int32.Parse(Request.QueryString["menu_tab"]);
            }
            Tab oTab = new Tab("", intMenuTab, "divMenu1", true, false);

            oTab.AddTab("Pool Configurtion", "");
            oTab.AddTab("Workstation History", "");
            oTab.AddTab("Workstations Currently Available", "");
            oTab.AddTab("Subscribed Users", "");
            strMenuTab1 = oTab.GetTabs();

            //End Menus

            if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
            {
                intApplication = Int32.Parse(Request.QueryString["applicationid"]);
            }
            if (Request.QueryString["pageid"] != null && Request.QueryString["pageid"] != "")
            {
                intPage = Int32.Parse(Request.QueryString["pageid"]);
            }
            if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
            {
                intApplication = Int32.Parse(Request.Cookies["application"].Value);
            }
            lblTitle.Text = oPage.Get(intPage, "title");
            if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
            {
                panPool.Visible = true;
                int intID = Int32.Parse(Request.QueryString["id"]);
                if (Request.QueryString["save"] != null)
                {
                    panSave.Visible = true;
                }
                DataSet ds = oWorkstation.GetPool(intID);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string strName = ds.Tables[0].Rows[0]["name"].ToString();
                    txtName.Text          = strName;
                    rptHistory.DataSource = oWorkstation.GetPoolWorkstationsStatus(strName);
                    rptHistory.DataBind();
                    lblHistory.Visible      = (rptHistory.Items.Count == 0);
                    rptAvailable.DataSource = oWorkstation.GetPoolWorkstations(strName);
                    rptAvailable.DataBind();
                    lblAvailable.Visible = (rptAvailable.Items.Count == 0);
                    DirectoryEntry oEntry = oAD.GroupSearch("GSGwra_" + strName);
                    if (oEntry != null)
                    {
                        if (oEntry.Properties.Contains("member") == true)
                        {
                            foreach (string strUser in oEntry.Properties["member"])
                            {
                                DirectoryEntry oEntry2 = new DirectoryEntry("LDAP://" + oVariable.primaryDCName(dsn) + "/" + strUser, oVariable.Domain() + "\\" + oVariable.ADUser(), oVariable.ADPassword());
                                strSubscribers += "<tr><td>" + oEntry2.Properties["displayname"].Value.ToString() + " (" + oEntry2.Properties["name"].Value.ToString() + ")</td></tr>";
                            }
                        }
                        else
                        {
                            strSubscribers += "<tr><td><img src=\"/images/bigAlert.gif\" border=\"0\" align=\"absmiddle\"/> There are no subscribers</td></tr>";
                        }
                    }
                    else
                    {
                        strSubscribers += "<tr><td><img src=\"/images/bigError.gif\" border=\"0\" align=\"absmiddle\"/> Could not find Active Directory Group <b>" + "GSGwra_" + strName + "</b></td></tr>";
                    }
                    txtDescription.Text = ds.Tables[0].Rows[0]["description"].ToString();
                    int intContact1 = 0;
                    int intContact2 = 0;
                    if (ds.Tables[0].Rows[0]["contact1"].ToString() != "")
                    {
                        intContact1 = Int32.Parse(ds.Tables[0].Rows[0]["contact1"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["contact2"].ToString() != "")
                    {
                        intContact2 = Int32.Parse(ds.Tables[0].Rows[0]["contact2"].ToString());
                    }
                    if (intContact1 > 0)
                    {
                        txtContact1.Text  = oUser.GetFullName(intContact1) + " (" + oUser.GetName(intContact1) + ")";
                        hdnContact1.Value = intContact1.ToString();
                    }
                    if (intContact2 > 0)
                    {
                        txtContact2.Text  = oUser.GetFullName(intContact2) + " (" + oUser.GetName(intContact2) + ")";
                        hdnContact2.Value = intContact2.ToString();
                    }
                    chkEnabled.Checked        = (ds.Tables[0].Rows[0]["enabled"].ToString() == "1");
                    lstCurrent.DataValueField = "id";
                    lstCurrent.DataTextField  = "name";
                    lstCurrent.DataSource     = oWorkstation.GetPoolWorkstations(intID);
                    lstCurrent.DataBind();
                    lstAvailable.DataValueField = "id";
                    lstAvailable.DataTextField  = "name";
                    lstAvailable.DataSource     = oWorkstation.GetPoolWorkstations(intProfile, intID);
                    lstAvailable.DataBind();
                    string strWorkstations = "";
                    int    intCount        = 0;
                    foreach (ListItem oItem in lstCurrent.Items)
                    {
                        strWorkstations = strWorkstations + oItem.Value + "_" + intCount.ToString() + "&";
                        intCount++;
                    }
                    hdnWorkstations.Value = strWorkstations;
                    txtContact1.Attributes.Add("onkeyup", "return AJAXTextBoxGet(this,'250','195','" + divContact1.ClientID + "','" + lstContact1.ClientID + "','" + hdnContact1.ClientID + "','" + oVariable.URL() + "/frame/users.aspx',2);");
                    lstContact1.Attributes.Add("ondblclick", "AJAXClickRow();");
                    txtContact2.Attributes.Add("onkeyup", "return AJAXTextBoxGet(this,'250','195','" + divContact2.ClientID + "','" + lstContact2.ClientID + "','" + hdnContact2.ClientID + "','" + oVariable.URL() + "/frame/users.aspx',2);");
                    lstContact2.Attributes.Add("ondblclick", "AJAXClickRow();");
                    btnAdd.Attributes.Add("onclick", "return MoveList('" + lstAvailable.ClientID + "','" + lstCurrent.ClientID + "','" + hdnWorkstations.ClientID + "','" + lstCurrent.ClientID + "');");
                    lstAvailable.Attributes.Add("ondblclick", "return MoveList('" + lstAvailable.ClientID + "','" + lstCurrent.ClientID + "','" + hdnWorkstations.ClientID + "','" + lstCurrent.ClientID + "');");
                    btnRemove.Attributes.Add("onclick", "return MoveList('" + lstCurrent.ClientID + "','" + lstAvailable.ClientID + "','" + hdnWorkstations.ClientID + "','" + lstCurrent.ClientID + "');");
                    lstCurrent.Attributes.Add("ondblclick", "return MoveList('" + lstCurrent.ClientID + "','" + lstAvailable.ClientID + "','" + hdnWorkstations.ClientID + "','" + lstCurrent.ClientID + "');");
                    btnUpdate.Attributes.Add("onclick", "return ValidateText('" + txtName.ClientID + "','Please enter a name')" +
                                             " && ValidateText('" + txtDescription.ClientID + "','Please enter a description')" +
                                             " && ValidateHidden0('" + hdnContact1.ClientID + "','" + txtContact1.ClientID + "','Please enter a primary contact')" +
                                             " && ValidateHidden0('" + hdnContact2.ClientID + "','" + txtContact2.ClientID + "','Please enter a secondary contact')" +
                                             ";");
                }
            }
            else if (Request.QueryString["create"] != null)
            {
                panCreate.Visible = true;
                LoadLists();
                if (Request.QueryString["qty"] != null && Request.QueryString["qty"] != "")
                {
                    if (Request.QueryString["qty"] == intMaxWorkstationsPerDay.ToString())
                    {
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "qty", "<script type=\"text/javascript\">alert('NOTE: You can request up to " + intMaxWorkstationsPerDay.ToString() + " virtual workstations per day.\\n\\nCurrently, you have requested " + Request.QueryString["qty"] + " virtual workstations and cannot be allocated additional hardware until tomorrow.\\n\\nIf your initiative requires more than " + intMaxWorkstationsPerDay.ToString() + " virtual workstations per day, you must use design builder.\\nPlease contact your technical lead or ClearView administrator for additional information.');<" + "/" + "script>");
                    }
                    else if (Request.QueryString["qty"] == "0")
                    {
                        int intDiff = intMaxWorkstationsPerDay - Int32.Parse(Request.QueryString["qty"]);
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "qty", "<script type=\"text/javascript\">alert('NOTE: You can request up to " + intMaxWorkstationsPerDay.ToString() + " virtual workstations per day.\\n\\nCurrently, you have requested " + Request.QueryString["qty"] + " virtual workstations. Please enter a quantity of " + intDiff.ToString() + " or less to continue.\\n\\nIf your initiative requires more than " + intMaxWorkstationsPerDay.ToString() + " virtual workstations per day, you must use design builder.\\nPlease contact your technical lead or ClearView administrator for additional information.');<" + "/" + "script>");
                    }
                    else
                    {
                        Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "qty", "<script type=\"text/javascript\">alert('NOTE: You can request up to " + intMaxWorkstationsPerDay.ToString() + " virtual workstations per day.\\n\\nPlease enter a quantity of " + intMaxWorkstationsPerDay.ToString() + " or less to continue.\\n\\nIf your initiative requires more than " + intMaxWorkstationsPerDay.ToString() + " virtual workstations per day, you must use design builder.\\nPlease contact your technical lead or ClearView administrator for additional information.');<" + "/" + "script>");
                    }
                }
                int intAddress = intLocation;
                if (intAddress > 0)
                {
                    txtParent.Text = oLocation.GetFull(intAddress);
                }
                hdnParent.Value = intAddress.ToString();
                btnContinue.Attributes.Add("onclick", "return ValidateNumber0('" + txtQuantity.ClientID + "','Please enter a valid quantity')" +
                                           " && ValidateDropDown('" + ddlRam.ClientID + "','Please select a RAM')" +
                                           " && ValidateDropDown('" + ddlOS.ClientID + "','Please select an operating system')" +
                                           " && ValidateDropDown('" + ddlCPU.ClientID + "','Please select a CPU')" +
                                           " && ValidateDropDown('" + ddlHardDrive.ClientID + "','Please select a hard drive')" +
                                           ";");
            }
            else if (Request.QueryString["rid"] != null)
            {
                int intRequest = Int32.Parse(Request.QueryString["rid"]);
                panExecute.Visible = true;
                DataSet dsService = oForecast.GetAnswerService(intRequest);
                if (dsService.Tables[0].Rows.Count > 0)
                {
                    int    intAnswer  = Int32.Parse(dsService.Tables[0].Rows[0]["id"].ToString());
                    int    intType    = oModelsProperties.GetType(intModelVirtual);
                    string strExecute = oType.Get(intType, "forecast_execution_path");
                    if (strExecute != "")
                    {
                        btnExecute.Attributes.Add("onclick", "return OpenWindow('FORECAST_EXECUTE','" + strExecute + "?id=" + intAnswer.ToString() + "');");
                    }
                    else
                    {
                        btnExecute.Attributes.Add("onclick", "alert('Execution has not been configured for asset type " + oType.Get(intType, "name") + "');return false;");
                    }
                }
                else
                {
                    btnExecute.Attributes.Add("onclick", "alert('There was a problem executing this request...please contact your ClearView administrator');return false;");
                }
            }
            else
            {
                DataSet ds = oWorkstation.GetPools(0);
                panPools.Visible    = true;
                rptPools.DataSource = ds;
                rptPools.DataBind();
                foreach (RepeaterItem ri in rptPools.Items)
                {
                    Label lblWorkstations = (Label)ri.FindControl("lblWorkstations");
                    lblWorkstations.Text = oWorkstation.GetPoolWorkstations(Int32.Parse(lblWorkstations.Text)).Tables[0].Rows.Count.ToString();
                }
                lblPools.Visible = (rptPools.Items.Count == 0);
            }
        }
예제 #17
0
        private void AddGroups(int _domain, string _name, string _ou, bool _disect)
        {
            Variables      oVariable = new Variables(_domain);
            string         strPath   = "LDAP://" + oVariable.primaryDCName(dsn) + "/ou=" + _ou + oVariable.LDAP();
            DirectoryEntry oParent   = new DirectoryEntry(strPath, oVariable.Domain() + "\\" + oVariable.ADUser(), oVariable.ADPassword());

            if (_disect == false)
            {
                foreach (DirectoryEntry oChild in oParent.Children)
                {
                    if (boolFound == true)
                    {
                        break;
                    }
                    string strName = oChild.Name.Substring(3);
                    if (oAccountRequest.GetExceptions(_domain, strName) == false)
                    {
                        if (CheckName(_name, strName) == true)
                        {
                            strResponse += "<value><![CDATA[" + Add(strName) + "]]></value><text><![CDATA[" + Add(strName) + "]]></text>";
                            intCount++;
                        }
                    }
                }
            }
            else
            {
                oTable = new DataTable();
                DataColumn oColumn = new DataColumn();
                oColumn.DataType   = System.Type.GetType("System.String");
                oColumn.ColumnName = "name";
                oTable.Columns.Add(oColumn);
                Populate(oParent, _domain);
                DataView dv = oTable.DefaultView;
                dv.Sort = "name";
                foreach (DataRowView dr in dv)
                {
                    if (boolFound == true)
                    {
                        break;
                    }
                    if (CheckName(_name, dr["name"].ToString()) == true)
                    {
                        strResponse += "<value><![CDATA[" + Add(dr["name"].ToString()) + "]]></value><text><![CDATA[" + Add(dr["name"].ToString()) + "]]></text>";
                        intCount++;
                    }
                }
            }
        }
예제 #18
0
        protected void btnGo_Click(Object Sender, EventArgs e)
        {
            boolVMFound = false;
            Response.Write(DateTime.Now.ToString() + "<br/>");

            Variables oVariable = new Variables(999);

            System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
            ClearViewWebServices         oWS          = new ClearViewWebServices();

            oWS.Timeout     = Int32.Parse(ConfigurationManager.AppSettings["WS_TIMEOUT"]);
            oWS.Credentials = oCredentials;
            //oWS.Url = oVariable.WebServiceURL();
            oWS.Url = "http://localhost:55030/ClearViewWebServices.asmx";

            string path = oWS.GetVMwarePath(txtVM.Text, "http://localhost:53744/", "OpHAa0tdJBAdeJALK65pMptAyK2SFcismq7QZNB9rMd4Fuhp6K8Zqx8z5gdA8KIGsi1YLTV7E57alz5cDMW5escYrHVTKbaReGLyDtNmYauuA8oFka6vXNCafcGe8cwD5q5OYHJk8Kgd7RyttpIJeO4BeLrAWJoWN1zkcJRNAWwnGxcyPnUSDXxqwEJmqjyzvuzfsmqTH5jssQ4QI3UJYFs0DiYHaEyrz71l86fC7blINf8PK2OwxYKZcIMjxSTcI13uZTSLYsMXuUmykj7h0b3Lybjzu5eori9WmN00kdHflWFrvo9pUMmH7s7XKsq3oyFlUAlGth6XDYzKG1dg5ZDP6CZ4Qcq2WN1XquH5dC6NPzdj2wrSok7x30prKrZq0eaZ6LtluhdD309GzPbuVINMQC4AfpuVMPXLxnnrcfxghEFd0S25pFFsAxjDR3gfXr0ndxilCTrPjGFm70JwwzGgkElaeTKj8ttZNsaCKQCFoZi337G0");

            while (path.Contains("\""))
            {
                path = path.Replace("\"", "");
            }
            string[] paths = path.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
            if (paths.Length >= 3)
            {
                string strConnect = oVMware.ConnectDEBUG("https://" + paths[0] + ".pncbank.com/sdk", 999, "");
                if (strConnect == "")
                {
                    _service = oVMware.GetService();
                    _sic     = oVMware.GetSic();
                    //ManagedObjectReference datacenterRef = oVMWare.GetDataCenter();
                    //ManagedObjectReference vmFolderRef = oVMWare.GetVMFolder(datacenterRef);
                    //ManagedObjectReference clusterRef = oVMWare.GetCluster(strCluster);
                    //ManagedObjectReference resourcePoolRootRef = (ManagedObjectReference)oVMWare.getObjectProperty(clusterRef, "resourcePool");
                    ManagedObjectReference oComputer = GetVM(txtVM.Text, paths);
                    if (oComputer != null)
                    {
                        VirtualMachineConfigInfo oInfo = (VirtualMachineConfigInfo)oVMware.getObjectProperty(oComputer, "config");
                        Response.Write(oInfo.uuid + "<br/>");
                    }
                    if (_service != null)
                    {
                        //ServiceContent _sic = oVMware.GetSic();
                        _service.Abort();
                        if (_service.Container != null)
                        {
                            _service.Container.Dispose();
                        }
                        try
                        {
                            _service.Logout(_sic.sessionManager);
                        }
                        catch { }
                        _service.Dispose();
                        _service = null;
                        _sic     = null;
                        //oLog.AddEvent(intAnswer, strName, strSerial, "Logged out of VMware", LoggingType.Information);
                    }
                }
            }
            Response.Write(DateTime.Now.ToString() + "<br/>");
        }
예제 #19
0
        private void Script()
        {
            try
            {
                Variables oVariable = new Variables(environment);
                Functions oFunction = new Functions(0, dsn, environment);
                oScheduler = new NCC.ClearView.Application.Core.Scheduler(0, dsn);
                oScheduler.Status(id, SchedulerStatus.Running, DateTime.Now.ToString(), -1);

                if (String.IsNullOrEmpty(server) == false)
                {
                    server = "\\\\" + server;
                }
                Variables oCredentials = new Variables(credentials);
                string    user         = oCredentials.Domain() + "\\" + oCredentials.ADUser();
                string    pass         = oCredentials.ADPassword();
                int       intTimeout   = (timeout * 60 * 1000); // convert to milliseconds
                //int intReturn = 0;
                if (interactive)
                {
                    parameters = "-i " + parameters;
                }
                if (privledges)
                {
                    parameters = "-h " + parameters;
                }

                bool             boolTimeout = false;
                ProcessStartInfo infoPsExec  = new ProcessStartInfo(location + "psexec");
                infoPsExec.WorkingDirectory = location;
                string command = server + " -u " + user + " -p {0} " + parameters;
                infoPsExec.Arguments = string.Format(command, pass);
                LogIt("Job \"" + name + "\" Starting PSEXEC: " + location + "psexec " + string.Format(command, "***"), false);
                Process procPsExec = Process.Start(infoPsExec);
                procPsExec.WaitForExit(intTimeout);
                if (procPsExec.HasExited == false)
                {
                    LogIt("Job \"" + name + "\" Timed Out after " + timeout.ToString() + " minute(s)...", true);
                    oScheduler.Status(id, SchedulerStatus.Waiting, DateTime.Now.ToString(), 1);
                    procPsExec.Kill();
                    boolTimeout = true;
                }
                else
                {
                    if (procPsExec.ExitCode == 0)   // 0 = Success
                    {
                        LogIt("Job \"" + name + "\" Exited (" + procPsExec.ExitCode.ToString() + ")", false);
                        oScheduler.Status(id, SchedulerStatus.Waiting, DateTime.Now.ToString(), 0);
                    }
                    else
                    {
                        LogIt("Job \"" + name + "\" Exited (" + procPsExec.ExitCode.ToString() + ")", true);
                        oScheduler.Status(id, SchedulerStatus.Waiting, DateTime.Now.ToString(), 1);
                    }
                }
                if (boolTimeout)
                {
                    string strEMails = oFunction.GetGetEmailAlertsEmailIds("EMAILGRP_DEVELOPER_ERROR");
                    oFunction.SendEmail("Timeout", strEMails, "", "", "SSIS Job \"" + name + "\" Timeout", "This message is to inform you that job \"" + name + "\" timed out after " + intTimeout.ToString() + "minute(s)", false, true);
                }
                //if (boolTimeout == false)
                //    intReturn = procPsExec.ExitCode;
                procPsExec.Close();
            }
            catch (Exception ex)
            {
                try
                {
                    string strError = "Scheduler Service (" + name + "): " + "(Error Message: " + ex.Message + ") ~ (Source: " + ex.Source + ") (Stack Trace: " + ex.StackTrace + ") [" + System.Environment.UserName + "]";
                    LogIt(strError, true);
                }
                catch
                {
                }
            }
        }
예제 #20
0
        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);
            }
        }
예제 #21
0
        public void Backups(int EnvironmentID)
        {
            // Setup Classes
            Servers            oServer             = new Servers(0, dsn);
            AvamarRegistration oAvamarRegistration = new AvamarRegistration(0, dsn);
            Log       oLog      = new Log(0, dsn);
            Variables oVariable = new Variables(EnvironmentID);

            // Setup Webservice for querying via SSH
            System.Net.NetworkCredential oCredentialsDNS = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
            ClearViewWebServices         oWebService     = new ClearViewWebServices();

            oWebService.Url = oVariable.WebServiceURL();

            DataSet dsBackups = oServer.GetAvamarBackups();

            if (dsBackups.Tables[0].Rows.Count > 0)
            {
                oLog.AddEvent("", "", "Get avamar backups (" + dsBackups.Tables[0].Rows.Count.ToString() + ")", LoggingType.Debug);
                foreach (DataRow drBackup in dsBackups.Tables[0].Rows)
                {
                    ClearResults();

                    int      intServer  = Int32.Parse(drBackup["id"].ToString());
                    DateTime datCreated = DateTime.Parse(drBackup["created"].ToString());
                    int      intAnswer  = Int32.Parse(drBackup["answerid"].ToString());
                    string   strName    = drBackup["servername"].ToString();
                    string   strGrid    = drBackup["grid"].ToString();
                    string   strDomain  = drBackup["domain"].ToString();
                    string   strGroup   = drBackup["group"].ToString();

                    oLog.AddEvent(intAnswer, strName, "", "Starting automated Avamar backup validation", LoggingType.Debug);
                    string strError = "";

                    // Initiate backup for client
                    AvamarReturnType backup = oAvamarRegistration.API(oWebService.GetAvamarBackup(strGrid, strDomain, strName));
                    if (backup.Error == false)
                    {
                        oLog.AddEvent(intAnswer, strName, "", "There are " + backup.Nodes.Count.ToString() + " backup(s).", LoggingType.Information);
                        if (backup.Nodes.Count > 0)
                        {
                            oLog.AddEvent(intAnswer, strName, "", "Backup has been validated", LoggingType.Information);
                            oServer.UpdateAvamarBackupCompleted(intServer, backup.Nodes[0].InnerXml, DateTime.Now.ToString(), 0);
                        }
                        else
                        {
                            // Check to see if a certain amount of time has passed and if so, throw error.
                            TimeSpan span = DateTime.Now.Subtract(datCreated);
                            if (span.TotalMinutes > 90)
                            {
                                // It's been an hour and a half.  Throw error.
                                strError = "The backup has still not completed after 90 minutes on grid " + strGrid;
                            }
                        }
                    }
                    else
                    {
                        strError = backup.Message + " (" + backup.Code + ")";
                    }

                    if (strError != "")
                    {
                        oLog.AddEvent(intAnswer, strName, "", strError, LoggingType.Error);
                        oServer.UpdateAvamarBackupCompleted(intServer, strError, DateTime.Now.ToString(), 1);
                        oServer.AddError(0, 0, 0, intServer, 906, strError);
                    }
                }
            }
        }
예제 #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Variables oVariable = new Variables(intEnvironment);
            Users     oUser     = new Users(0, dsn);

            System.Drawing.Image oImage;
            if (Request.QueryString["xid"] != null && Request.QueryString["xid"] != "")
            {
                string  strImage  = "";
                string  fileName  = Request.QueryString["xid"];
                string  fileName2 = "";
                int     intUser   = oUser.GetId(fileName);
                DataSet dsUser    = oUser.Get(intUser);
                if (dsUser.Tables[0].Rows.Count > 0)
                {
                    DataRow drUser = dsUser.Tables[0].Rows[0];
                    if (drUser["xid"].ToString().Trim().ToUpper() == fileName.Trim().ToUpper())
                    {
                        fileName2 = drUser["pnc_id"].ToString();
                    }
                    else if (drUser["pnc_id"].ToString().Trim().ToUpper() == fileName.Trim().ToUpper())
                    {
                        fileName2 = drUser["xid"].ToString();
                    }
                }

                if (fileName.ToUpper() == oVariable.ADUser().ToUpper() || (fileName2 != "" && fileName2.ToUpper() == oVariable.ADUser().ToUpper()))
                {
                    // ClearView User
                    strImage = Request.PhysicalApplicationPath + "\\images\\clearview.gif";
                    oImage   = System.Drawing.Image.FromFile(strImage);
                    oImage.Save(Response.OutputStream, ImageFormat.Jpeg);
                    oImage.Dispose();
                    oImage = null;
                }
                else
                {
                    string strPhysical = oVariable.DocumentsFolder() + "photos\\";
                    if (File.Exists(strPhysical + fileName + ".jpg") == false && (fileName2 == "" || File.Exists(strPhysical + fileName2 + ".jpg") == false))
                    {
                        strImage = Request.PhysicalApplicationPath + "\\images\\nophoto.gif";
                        oImage   = System.Drawing.Image.FromFile(strImage);
                        oImage.Save(Response.OutputStream, ImageFormat.Jpeg);
                        oImage.Dispose();
                        oImage = null;
                    }
                    else
                    {
                        if (Directory.Exists(strPhysical) == false)
                        {
                            Directory.CreateDirectory(strPhysical);
                        }
                        string strTemp = strPhysical + "temp\\";
                        if (Directory.Exists(strTemp) == false)
                        {
                            Directory.CreateDirectory(strTemp);
                        }

                        if (File.Exists(strPhysical + fileName + ".jpg") == true)
                        {
                            strImage = strPhysical + fileName + ".jpg";
                            oImage   = System.Drawing.Image.FromFile(strImage);
                            oImage.Save(Response.OutputStream, ImageFormat.Jpeg);
                            oImage.Dispose();
                            oImage = null;
                        }
                        else
                        {
                            strImage = strPhysical + fileName2 + ".jpg";
                            oImage   = System.Drawing.Image.FromFile(strImage);
                            oImage.Save(Response.OutputStream, ImageFormat.Jpeg);
                            oImage.Dispose();
                            oImage = null;
                        }
                    }
                }
            }
        }
예제 #23
0
        private double CompareDomainComputers(int _search_domain, int _searched_domain, int _computers, int _requestid)
        {
            double dblHours = 0.00;
            double dblTime  = 5.00 / 60.00;

            try
            {
                ADObject          oADObject  = new ADObject(0, dsn);
                DataPoint         oDataPoint = new DataPoint(0, dsn);
                Variables         oDevV      = new Variables(_search_domain);
                DirectoryEntry    oDevE      = new DirectoryEntry(oDevV.primaryDC(dsn), oDevV.Domain() + "\\" + oDevV.ADUser(), oDevV.ADPassword());
                DirectorySearcher oDevS      = new DirectorySearcher(oDevE);
                oDevS.Filter = "(objectCategory=computer)";
                SearchResultCollection oDevs = oDevS.FindAll();
                string[] a1       = new string[10000];
                int      intCount = 0;
                foreach (SearchResult oDev in oDevs)
                {
                    if (oDev.Properties.Contains("sAMAccountName") == true)
                    {
                        a1[intCount] = oDev.Properties["sAMAccountName"][0].ToString();
                        intCount++;
                    }
                }
                Variables         oTestV = new Variables(_searched_domain);
                DirectoryEntry    oTestE = new DirectoryEntry(oTestV.primaryDC(dsn), oTestV.Domain() + "\\" + oTestV.ADUser(), oTestV.ADPassword());
                DirectorySearcher oTestS = new DirectorySearcher(oTestE);
                oTestS.Filter = "(objectCategory=computer)";
                SearchResultCollection oTests = oTestS.FindAll();
                string[] a2 = new string[10000];
                intCount = 0;
                foreach (SearchResult oTest in oTests)
                {
                    if (oTest.Properties.Contains("sAMAccountName") == true)
                    {
                        a2[intCount] = oTest.Properties["sAMAccountName"][0].ToString();
                        intCount++;
                    }
                }
                string[] a3 = new string[10000];
                intCount = 0;
                for (int ii = 0; ii < 10000 && a1[ii] != null; ii++)
                {
                    for (int jj = 0; jj < 10000 && a2[jj] != null; jj++)
                    {
                        if (a1[ii] == a2[jj])
                        {
                            a3[intCount] = a2[jj];
                            intCount++;
                            break;
                        }
                    }
                }
                Ping oPing = new Ping();
                for (int kk = 0; kk < 10000 && a3[kk] != null; kk++)
                {
                    if (_computers > 0 && intCounter > _computers)
                    {
                        break;
                    }
                    string    strServer = a3[kk].Replace("$", "");
                    string    strStatus = "";
                    PingReply oReply;
                    try
                    {
                        string strDevSuffix = oDevV.FullyQualified();
                        oReply    = oPing.Send(strServer + "." + strDevSuffix);
                        strStatus = oReply.Status.ToString();
                    }
                    catch {}
                    if (strStatus == "Success")
                    {
                        AddDomainComputer(_requestid, strServer, _searched_domain);
                    }
                    else
                    {
                        try
                        {
                            string strTestSuffix = oTestV.FullyQualified();
                            oReply    = oPing.Send(strServer + "." + strTestSuffix);
                            strStatus = oReply.Status.ToString();
                        }
                        catch {}
                        if (strStatus == "Success")
                        {
                            AddDomainComputer(_requestid, strServer, _search_domain);
                        }
                        else
                        {
                            try
                            {
                                oReply    = oPing.Send(strServer);
                                strStatus = oReply.Status.ToString();
                            }
                            catch { }
                            if (strStatus == "Success")
                            {
                                int intDomain = oDevV.DomainID(oDataPoint.GetDomainNameFix(strServer, intEnvironment));
                                if (intDomain > 0)
                                {
                                    if (intDomain == _search_domain)
                                    {
                                        intDomain = _searched_domain;
                                    }
                                    else
                                    {
                                        intDomain = _search_domain;
                                    }
                                    AddDomainComputer(_requestid, strServer, intDomain);
                                }
                                else
                                {
                                    AddDomainComputer(_requestid, strServer, _search_domain);
                                    AddDomainComputer(_requestid, strServer, _searched_domain);
                                    dblHours += dblTime;
                                }
                            }
                            else
                            {
                                AddDomainComputer(_requestid, strServer, _search_domain);
                                AddDomainComputer(_requestid, strServer, _searched_domain);
                                dblHours += dblTime;
                            }
                        }
                    }
                    dblHours += dblTime;
                    intCounter++;
                }
            }
            catch (Exception er2)
            {
                oLog.WriteEntry(String.Format("ERROR: " + er2.Message), EventLogEntryType.Error);
            }
            return(dblHours);
        }
예제 #24
0
        protected void btnServiceNowIncidentGet_Click(object sender, EventArgs e)
        {
            if (false)
            {
                // QA Service Now
                string URL = "https://webqa-itsm.pncbank.com";
                WebServiceAPI.ClearViewWebServices ws = new WebServiceAPI.ClearViewWebServices();
                ws.Url = "http://localhost:64919/ClearViewWebServices.asmx";
                int ErrorID = 178255;
                if (String.IsNullOrEmpty(Request.QueryString["id"]) == false)
                {
                    Int32.TryParse(Request.QueryString["id"], out ErrorID);
                }
                string result = ws.GetServiceNowIncident(URL, "_clearview_user", "_clearview_userQA", ErrorID, "WORKSTATION");
                if (String.IsNullOrEmpty(result) == false)
                {
                    Response.Write(result);
                }
                else
                {
                    Response.Write("Success");
                }
            }
            else
            {
                // Production Service Now
                oVariable = new Variables(999);
                WebServiceAPI.ClearViewWebServices oServiceNow = new WebServiceAPI.ClearViewWebServices();
                if (true)
                {
                    // Production Web Service
                    System.Net.NetworkCredential oCredentials = new System.Net.NetworkCredential(oVariable.ADUser(), oVariable.ADPassword(), oVariable.Domain());
                    oServiceNow.Timeout     = Timeout.Infinite;
                    oServiceNow.Credentials = oCredentials;
                    oServiceNow.Url         = oVariable.WebServiceURL();
                }
                else  // Local Web Service
                {
                    oServiceNow.Url = "http://localhost:55030/ClearViewWebServices.asmx";
                }

                string url         = "https://itsm.pncbank.com";
                bool   workstation = false;
                int    errorid     = 29002;
                //string data = oServiceNow.GetServiceNowIncident(url, oVariable.ServiceNowUsername(), oVariable.ServiceNowPassword(), errorid, (workstation ? "WORKSTATION" : "SERVER"));
                string data = oServiceNow.GetServiceNowIncidentNumber(url, oVariable.ServiceNowUsername(), oVariable.ServiceNowPassword(), "INC2381530");
                if (String.IsNullOrEmpty(data) == false)
                {
                    Response.Write(data);
                }
                else
                {
                    Response.Write("Success");
                }
            }
        }
예제 #25
0
        private double LastLogin(int _search_domain, int _days, int _accounts, int _requestid)
        {
            double            dblHours  = 0.00;
            double            dblTime   = 5.00 / 60.00;
            ADObject          oADObject = new ADObject(0, dsn);
            Variables         oVariable = new Variables(_search_domain);
            DirectoryEntry    oEntry    = new DirectoryEntry(oVariable.primaryDC(dsn), oVariable.ADUser(), oVariable.ADPassword());
            DirectorySearcher oSearcher = new DirectorySearcher(oEntry);

            oSearcher.Filter = "(&(objectCategory=user)(|(sAMAccountName=t*)(|(sAMAccountName=e*)(sAMAccountName=x*))))";
            SearchResultCollection oResults = oSearcher.FindAll();

            foreach (SearchResult oResult in oResults)
            {
                if (_accounts > 0 && intCounter > _accounts)
                {
                    break;
                }
                if (oResult.Properties.Contains("sAMAccountName") == true)
                {
                    string strXid   = oResult.Properties["sAMAccountName"][0].ToString();
                    string strFName = "";
                    if (oResult.Properties.Contains("givenname") == true)
                    {
                        strFName = oResult.Properties["givenname"][0].ToString();
                    }
                    string strLName = "";
                    if (oResult.Properties.Contains("sn") == true)
                    {
                        strLName = oResult.Properties["sn"][0].ToString();
                    }
                    string strName = "";
                    if (strFName != "" || strLName != "")
                    {
                        strName = "(" + strFName + " " + strLName + ")";
                    }
                    string strPath = "";
                    if (oResult.Properties.Contains("adspath") == true)
                    {
                        strPath = oResult.Properties["adspath"][0].ToString();
                    }
                    DateTime dc1       = CheckDomain(1, _search_domain, strXid, _days);
                    DateTime dc2       = CheckDomain(2, _search_domain, strXid, _days);
                    DateTime dcGreater = new DateTime();
                    DateTime dcLess    = new DateTime();
                    if (dc1 > dc2)
                    {
                        dcGreater = dc1;
                        dcLess    = dc2;
                    }
                    else
                    {
                        dcGreater = dc2;
                        dcLess    = dc1;
                    }
                    TimeSpan oSpan     = DateTime.Today.Subtract(dcGreater);
                    TimeSpan oSpanLess = DateTime.Today.Subtract(dcLess);
                    if (oSpan.Days > _days)
                    {
                        string strDate = dcGreater.ToString();
                        oADObject.AddDomainAccount(_requestid, _search_domain, strXid.ToUpper() + strName, strPath, "Account has not logged in for " + oSpan.Days.ToString() + " days in " + oVariable.Name() + " (" + oSpanLess.Days.ToString() + " in other DC)", strDate);
                        intCounter++;
                        dblHours += dblTime;
                    }
                }
            }
            return(dblHours);
        }
예제 #26
0
        private void PopulateTree(int _domain)
        {
            Variables         oVariable = new Variables(_domain);
            DirectoryEntry    oEntry    = new DirectoryEntry("LDAP://" + oVariable.primaryDCName(dsn) + "/" + oVariable.LDAP(), oVariable.Domain() + "\\" + oVariable.ADUser(), oVariable.ADPassword());
            DirectorySearcher oSearcher = new DirectorySearcher(oEntry);

            oSearcher.Filter      = "(objectClass=organizationalUnit)";
            oSearcher.SearchScope = SearchScope.OneLevel;
            SearchResultCollection oCollection = oSearcher.FindAll();

            foreach (SearchResult oResult in oCollection)
            {
                TreeNode oNode = new TreeNode();
                oNode.Text = oResult.GetDirectoryEntry().Properties["name"].Value.ToString();
                if (oResult.GetDirectoryEntry().Properties["name"].Value.ToString() == "OUc_Orgs" || oResult.GetDirectoryEntry().Properties["name"].Value.ToString() == "OUg_Resources")
                {
                    oNode.Text         = oResult.GetDirectoryEntry().Properties["name"].Value.ToString();
                    oNode.ToolTip      = oNode.Text;
                    oNode.SelectAction = TreeNodeSelectAction.Expand;
                    PopulateTree2(_domain, "OU=" + oResult.GetDirectoryEntry().Properties["name"].Value.ToString() + ",", oNode);
                    oTreeview.Nodes.Add(oNode);
                }
            }
            oTreeview.ExpandDepth = 1;
            oTreeview.Attributes.Add("oncontextmenu", "return false;");
        }
예제 #27
0
        private void LoadObjects()
        {
            string strGroup = oFunction.decryptQueryString(Request.QueryString["g"]);

            txtFrom.Text = strGroup;
            int intDomain = Int32.Parse(oFunction.decryptQueryString(Request.QueryString["d"]));

            ddlDomain.SelectedValue = intDomain.ToString();
            intDomain = Int32.Parse(oDomain.Get(intDomain, "environment"));
            AD oAD = new AD(intProfile, dsn, intDomain);

            lblGroup.Text = oAD.GetGroupName(strGroup);
            DirectoryEntry oEntry    = oAD.GroupSearch(strGroup);
            Variables      oVariable = new Variables(intDomain);

            if (oEntry != null)
            {
                if (oEntry.Properties.Contains("member") == true)
                {
                    foreach (string strUser in oEntry.Properties["member"])
                    {
                        DirectoryEntry oEntry2 = new DirectoryEntry("LDAP://" + oVariable.primaryDCName(dsn) + "/" + strUser, oVariable.Domain() + "\\" + oVariable.ADUser(), oVariable.ADPassword());
                        ListItem       oList   = new ListItem(oEntry2.Properties["displayName"].Value.ToString() + " (" + oEntry2.Properties["name"].Value.ToString() + ")", oEntry2.Properties["name"].Value.ToString());
                        chkUsers.Items.Add(oList);
                        oList.Selected = true;
                    }
                }
                lblNone.Visible = (chkUsers.Items.Count == 0);
                // Get Group Type
                if (oEntry.Properties.Contains("groupType") == true)
                {
                    switch (oEntry.Properties["groupType"].Value.ToString())
                    {
                    case "-2147483646":
                        radS.Checked  = true;
                        radGG.Checked = true;
                        break;

                    case "-2147483644":
                        radS.Checked   = true;
                        radDLG.Checked = true;
                        break;

                    case "-2147483640":
                        radS.Checked  = true;
                        radUG.Checked = true;
                        break;

                    case "2":
                        radD.Checked  = true;
                        radGG.Checked = true;
                        break;

                    case "4":
                        radD.Checked   = true;
                        radDLG.Checked = true;
                        break;

                    case "8":
                        radD.Checked  = true;
                        radUG.Checked = true;
                        break;
                    }
                }
                panContinue.Visible = true;
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "saved", "<script type=\"text/javascript\">alert('The group could not be found.\\n\\nPlease enter a group name to continue.');<" + "/" + "script>");
                btnNext.Enabled = false;
            }
        }
예제 #28
0
        private void PopulateTree2(int _domain, string _parent, TreeNode oParent)
        {
            Variables         oVariable = new Variables(_domain);
            DirectoryEntry    oEntry    = new DirectoryEntry("LDAP://" + oVariable.primaryDCName(dsn) + "/" + _parent + oVariable.LDAP(), oVariable.Domain() + "\\" + oVariable.ADUser(), oVariable.ADPassword());
            DirectorySearcher oSearcher = new DirectorySearcher(oEntry);

            oSearcher.Filter      = "(objectClass=organizationalUnit)";
            oSearcher.SearchScope = SearchScope.OneLevel;
            SearchResultCollection oCollection = oSearcher.FindAll();

            foreach (SearchResult oResult in oCollection)
            {
                TreeNode oNode            = new TreeNode();
                string   strName          = oResult.GetDirectoryEntry().Properties["name"].Value.ToString();
                string   strDistinquished = oResult.GetDirectoryEntry().Properties["distinguishedname"].Value.ToString();
                oNode.Text         = strName;
                oNode.ToolTip      = strName;
                oNode.SelectAction = TreeNodeSelectAction.Expand;
                if (strDistinquished == lblOld.Text)
                {
                    oSelected      = oNode;
                    oNode.ImageUrl = "/images/green_arrow.gif";
                    lblOld.Text    = strDistinquished;
                }
                else
                {
                    oNode.NavigateUrl = "javascript:SelectNode('" + strDistinquished + "','" + hdnParent.ClientID + "','" + lblNew.ClientID + "');";
                }
                oParent.ChildNodes.Add(oNode);
                PopulateTree2(_domain, "OU=" + strName + "," + _parent, oNode);
            }
        }
예제 #29
0
        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...";
                }
            }
        }
예제 #30
0
        protected void CheckResults(SearchResultCollection oResults)
        {
            if (oResults.Count == 0)
            {
                panNone.Visible   = true;
                panSearch.Visible = true;
            }
            else if (oResults.Count == 1)
            {
                if (oResults[0].Properties.Contains("extensionattribute10") == true)
                {
                    txtID.Text = oResults[0].GetDirectoryEntry().Properties["extensionattribute10"].Value.ToString();
                }
                if (oResults[0].GetDirectoryEntry().Properties.Contains("businesscategory") == true)
                {
                    txtXID.Text = oResults[0].GetDirectoryEntry().Properties["businesscategory"].Value.ToString();
                }
                else if (oResults[0].Properties.Contains("sAMAccountName") == true)
                {
                    txtXID.Text = oResults[0].GetDirectoryEntry().Properties["sAMAccountName"].Value.ToString();
                }
                else if (oResults[0].Properties.Contains("mailnickname") == true)
                {
                    txtXID.Text = oResults[0].GetDirectoryEntry().Properties["mailnickname"].Value.ToString();
                }

                if (txtID.Text == "" && txtXID.Text != "" && Request.QueryString["xid"] != null)
                {
                    // National City lookup...Try looking up using eDirectory
                    SearchResultCollection oCollection = oFunction.eDirectory("cn", Request.QueryString["xid"]);
                    if (oCollection.Count == 0)
                    {
                        oCollection = oFunction.eDirectory("businesscategory", Request.QueryString["xid"]);
                    }
                    if (oCollection.Count == 1)
                    {
                        if (oCollection[0].GetDirectoryEntry().Properties.Contains("businesscategory") == true)
                        {
                            txtXID.Text = oCollection[0].GetDirectoryEntry().Properties["businesscategory"].Value.ToString();
                        }
                        if (oCollection[0].GetDirectoryEntry().Properties.Contains("cn") == true)
                        {
                            txtID.Text = oCollection[0].GetDirectoryEntry().Properties["cn"].Value.ToString();
                        }
                    }
                }

                //if (txtID.Text == "")
                //    txtID.Text = txtXID.Text;
                //if (txtXID.Text == "")
                //    txtXID.Text = txtID.Text;

                if (txtID.Text != "" && oUser.GetId(txtID.Text) > 0)
                {
                    panRegistered.Visible = true;
                    lblUser.Text          = txtID.Text;
                }
                else if (txtXID.Text != "" && oUser.GetId(txtXID.Text) > 0)
                {
                    panRegistered.Visible = true;
                    lblUser.Text          = txtXID.Text;
                }
                else
                {
                    panRegister.Visible = true;
                    txtFirst.Text       = oResults[0].GetDirectoryEntry().Properties["givenname"].Value.ToString();
                    txtLast.Text        = oResults[0].GetDirectoryEntry().Properties["sn"].Value.ToString();
                    if (oResults[0].Properties.Contains("manager") == true)
                    {
                        string         strManager = oResults[0].GetDirectoryEntry().Properties["manager"].Value.ToString();
                        DirectoryEntry oManager   = new DirectoryEntry("LDAP://" + oVariable.primaryDCName(dsn) + "/" + strManager, oVariable.Domain() + "\\" + oVariable.ADUser(), oVariable.ADPassword());
                        txtManager.Text = oManager.Properties["sAMAccountName"].Value.ToString();
                        int intManager = oUser.GetId(txtManager.Text);
                        if (intManager > 0)
                        {
                            hdnManager.Value = intManager.ToString();
                            txtManager.Text  = oUser.GetFullName(intManager) + " (" + oUser.GetName(intManager) + ")";
                        }
                        else
                        {
                            txtManager.Text  = "";
                            hdnManager.Value = "0";
                        }
                    }
                    if (oResults[0].Properties.Contains("telephonenumber") == true)
                    {
                        txtPhone.Text = oResults[0].GetDirectoryEntry().Properties["telephonenumber"].Value.ToString();
                    }
                }
            }
            else
            {
                panMultiple.Visible = true;
                foreach (SearchResult oResult in oResults)
                {
                    if (oResult.Properties.Contains("extensionattribute10") == true)
                    {
                        strMultiple += "<tr onmouseover=\"CellRowOver(this);\" onmouseout=\"CellRowOut(this);\" onclick=\"window.navigate('" + oPage.GetFullLink(intPage) + "?pid=" + oResult.GetDirectoryEntry().Properties["extensionattribute10"].Value.ToString() + "');\">";
                        strMultiple += "<td>" + oResult.GetDirectoryEntry().Properties["extensionattribute10"].Value.ToString() + "</td>";
                    }
                    else if (oResult.Properties.Contains("sAMAccountName") == true)
                    {
                        strMultiple += "<tr onmouseover=\"CellRowOver(this);\" onmouseout=\"CellRowOut(this);\" onclick=\"window.navigate('" + oPage.GetFullLink(intPage) + "?xid=" + oResult.GetDirectoryEntry().Properties["sAMAccountName"].Value.ToString() + "');\">";
                        strMultiple += "<td>" + oResult.GetDirectoryEntry().Properties["sAMAccountName"].Value.ToString() + "</td>";
                    }
                    else if (oResult.Properties.Contains("mail") == true)
                    {
                        strMultiple += "<tr onmouseover=\"CellRowOver(this);\" onmouseout=\"CellRowOut(this);\" onclick=\"window.navigate('" + oPage.GetFullLink(intPage) + "?mail=" + oResult.GetDirectoryEntry().Properties["mail"].Value.ToString() + "');\">";
                        strMultiple += "<td>" + oResult.GetDirectoryEntry().Properties["mailnickname"].Value.ToString() + "</td>";
                    }
                    else
                    {
                        strMultiple += "<td></td>";
                    }
                    if (oResult.Properties.Contains("givenname") == true)
                    {
                        strMultiple += "<td>" + oResult.GetDirectoryEntry().Properties["givenname"].Value.ToString() + "</td>";
                    }
                    else
                    {
                        strMultiple += "<td></td>";
                    }
                    if (oResult.Properties.Contains("sn") == true)
                    {
                        strMultiple += "<td>" + oResult.GetDirectoryEntry().Properties["sn"].Value.ToString() + "</td>";
                    }
                    else
                    {
                        strMultiple += "<td></td>";
                    }
                    strMultiple += "</tr>";
                }
            }
        }