Beispiel #1
0
        private bool GetServerDetail()
        {
            try
            {
                string ServerName         = string.Empty;
                string UserName           = string.Empty;
                byte[] Password           = null;
                string IntegratedSecurity = string.Empty;

                //ConnectionString = "";

                using (DataStuff sn = new DataStuff())
                {
                    sn.ConnectionString = StoreConnectionString;

                    DataTable dt = sn.GetServerDetail(cbEnvironment.Text, UserID);

                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            ServerName         = row["ServerName"].ToString();
                            UserName           = row["UserName"].ToString();
                            Password           = (byte[])row["Password"];
                            IntegratedSecurity = row["IntegratedSecurity"].ToString();
                        }
                    }
                }

                if (IntegratedSecurity == "Y")
                {
                    ConnectionString = "Data Source=" + ServerName + ";Integrated Security=True";
                }
                else
                {
                    string DecryptedPassword = string.Empty;

                    using (DataStuff ds = new DataStuff())
                    {
                        DecryptedPassword = ds.Ontsyfer(Password);
                    }

                    ConnectionString = "Data Source=" + ServerName + ";User ID=" + UserName + ";Password="******"")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            catch
            {
                return(false);
            }
        }
        private string GetServerConnectionString(string ServerAlias)
        {
            try
            {
                string ServerName         = string.Empty;
                string UserName           = string.Empty;
                byte[] Password           = null;
                string IntegratedSecurity = string.Empty;
                string CnnString          = string.Empty;

                using (DataStuff sn = new DataStuff())
                {
                    DataTable dt = sn.GetServerDetail(ServerAlias, UserID);

                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            ServerName         = row["ServerName"].ToString();
                            UserName           = row["UserName"].ToString();
                            Password           = (byte[])row["Password"];
                            IntegratedSecurity = row["IntegratedSecurity"].ToString();
                        }
                    }
                }

                if (IntegratedSecurity == "Y")
                {
                    CnnString = "Data Source=" + ServerName + ";Integrated Security=True";
                }
                else
                {
                    string DecryptedPassword = string.Empty;

                    using (DataStuff ds = new DataStuff())
                    {
                        DecryptedPassword = ds.Ontsyfer(Password);
                    }

                    CnnString = "Data Source=" + ServerName + ";User ID=" + UserName + ";Password="******"");
            }
        }
Beispiel #3
0
        private void GetServerDetail()
        {
            try
            {
                tServerName.Text            = "";
                ServerID                    = 0;
                tUserName.Text              = "";
                tPassword.Text              = "";
                cIntegratedSecurity.Checked = false;
                tServerRole.Text            = "";

                using (DataStuff sn = new DataStuff())
                {
                    DataTable dt = sn.GetServerDetail(cbServerName.Text, UserID);

                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            ServerID         = Convert.ToInt32(row["ServerID"].ToString());
                            tServerName.Text = row["ServerName"].ToString();
                            tUserName.Text   = row["UserName"].ToString();

                            DataStuff p = new DataStuff();
                            tPassword.Text = p.Ontsyfer((byte[])row["Password"]);

                            if (row["IntegratedSecurity"].ToString() == "Y")
                            {
                                cIntegratedSecurity.Checked = true;
                            }
                            else
                            {
                                cIntegratedSecurity.Checked = false;
                            }

                            tServerRole.Text = row["ServerRoleDesc"].ToString();
                        }
                    }
                }
            }

            catch (Exception ex)
            {
            }
        }