Example #1
0
        public Form_SnapshotSchemaProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            InitializeComponent();

            // Update fields.
            m_Version   = version;
            m_ObjectTag = tag;

            // Retrieve properties.
            string name  = string.Empty,
                   owner = string.Empty;

            getNames(ref name, ref owner);

            // Set the labels.
            _lbl_Name.Text  = name;
            _lbl_Owner.Text = owner;

            // Set title based on type.
            this.Text = tag.TypeName + " Properties - " + name;

            // Fill explicit permissions.
            _permissionsGrid.Initialize(m_Version, m_ObjectTag);
        }
        private Form_SnapshotServiceProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            InitializeComponent();

            // Initialize fields.
            m_Version = version;
            m_Tag     = tag;

            // Get properties.
            Sql.Service s = Sql.Service.GetSnapshotService(m_Tag.SnapshotId, m_Tag.ObjectName);

            // Set display text.
            Text = "Service Properties - " + m_Tag.ObjectName;

            // Set minimum size.
            MinimumSize = Size;

            // Display labels.
            _lbl_Name.Text        = s.Name;
            _lbl_DisplayName.Text = s.DisplayName;
            _lbl_Path.Text        = s.Path;
            _lbl_StartupType.Text = s.StartupType;
            _lbl_LoginName.Text   = s.LoginName;
            _lbl_State.Text       = s.State;
        }
        public Form_SnapshotAvailabilityGroupProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            InitializeComponent();

            // Init size, icon & text.
            this.MinimumSize = this.Size;
            this.Text        = "Availability Group Properties - " + tag.ObjectName;
            // Get endpoint object.


            AvailabilityGroup gGroup = tag.Tag as AvailabilityGroup;

            if (gGroup != null)
            {
                _lbl_Name.Text     = gGroup.Name;
                _lbl_Type.Text     = tag.TypeName;
                _lbl_ResId.Text    = gGroup.ResourceGroupId;
                _lbl_Failure.Text  = gGroup.FailureConditionLevel.ToString();
                _lb_BuckupRef.Text = gGroup.AutomatedBackuppReferenceDesc;
                _lb_TimeOut.Text   = gGroup.HealthCheckTimeout.ToString();

                _permissionsGrid.Initialize(version, tag);
            }
        }
        public Form_SnapshotDatabaseProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            InitializeComponent();

            Sql.Database db = Sql.Database.GetSnapshotDatabase(tag.SnapshotId, tag.DatabaseId);
            if (db != null)
            {
                // Set the properties.
                _lbl_Name.Text         = db.Name;
                _lbl_Owner.Text        = db.Owner;
                _lbl_GuestEnabled.Text = db.IsGuestEnabled ? "Yes" : "No";
                _lbl_Trustworthy.Text  = db.IsTrustworthy;
                _lbl_Status.Text       = db.Status;

                // Set title based on type.
                this.Text = tag.TypeName + " Properties - " + db.Name;

                // If database is available, fill explicit permissions
                // Else disable the grid.
                if (db.IsAvailable)
                {
                    _permissionsGrid.Initialize(version, tag);
                }
                else
                {
                    _permissionsGrid.Enabled = false;
                }
            }
        }
        private Form_SnapshotServerProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            InitializeComponent();

            // Set minimum size.
            this.MinimumSize = this.Size;

            // Init fields.
            m_Version      = version;
            m_ObjectTag    = tag;
            m_Snapshot     = Sql.Snapshot.GetSnapShot(tag.SnapshotId);
            m_IsGridFilled = false;

            // Init general page.
            if (m_Snapshot != null)
            {
                // Set form title.
                Text = "Snapshot SQL Server Properties - " + m_Snapshot.FullName;

                // Init general page.
                initGeneralPage();

                // Init config page.
                initConfigPage();
            }

            ultraTabControl1.DrawFilter = new HideFocusRectangleDrawFilter();
        }
Example #6
0
        public Form_SnapshotEndpointProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            InitializeComponent();

            // Init size, icon & text.
            this.MinimumSize = this.Size;
            this.Text        = "Endpoint Properties - " + tag.ObjectName;

            // Get endpoint object.
            Sql.Endpoint endpoint = Sql.Endpoint.GetSnapshotEndpoint(tag.SnapshotId, tag.ObjectId);
            if (endpoint != null)
            {
                _lbl_Name.Text            = endpoint.Name;
                _lbl_Type.Text            = endpoint.EndpointType;
                _lbl_Protocol.Text        = endpoint.Protocol;
                _lbl_IsAdminEndpoint.Text = endpoint.IsAdminEndpointStr;
                _permissionsGrid.Initialize(version, tag);
            }
            else
            {
            }
        }
Example #7
0
        private Form_SnapshotFileProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            InitializeComponent();

            // Initialize fields.
            m_Version = version;
            m_Tag     = tag;

            // Get properties.
            Sql.FileSystemObject f = Sql.FileSystemObject.GetSnapshotObject(m_Tag.SnapshotId, m_Tag.ObjectId);

            // Set display text.
            Text = "File Properties - " + m_Tag.ObjectName;

            // Set minimum size.
            MinimumSize = Size;

            // Display labels.
            _lbl_Name.Text     = f.Name;
            _lbl_Type.Text     = f.TypeDescription;
            _lbl_DiskType.Text = f.DiskType;
            _lbl_Owner.Text    = f.Owner;
            _lbl_D.Visible     = _lbl_Database.Visible = (f.ObjectType == Utility.OsObjectType.DB);
            _lbl_Database.Text = f.Database;

            // Fill explicit permissions.
            _permissionsGrid.Initialize(m_Version, m_Tag);
        }
        private Form_SnapshotRegistryProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            InitializeComponent();

            // Initialize fields.
            m_Version = version;
            m_Tag     = tag;

            // Get properties.
            Sql.RegistryKey r = Sql.RegistryKey.GetSnapshotKey(m_Tag.SnapshotId, m_Tag.ObjectId);

            // Set display text.
            Text = "Registry Key Properties - " + m_Tag.ObjectName;

            // Set minimum size.
            MinimumSize = Size;

            // Display labels.
            _lbl_Name.Text  = r.Name;
            _lbl_Owner.Text = r.Owner;

            // Fill explicit permissions.
            _permissionsGrid.Initialize(m_Version, m_Tag);
        }
Example #9
0
        public Form_SnapshotAvailabilityGroupReplicaProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            InitializeComponent();

            // Init size, icon & text.
            this.MinimumSize = this.Size;
            this.Text        = "Availability Group Replica Properties - " + tag.ObjectName;
            // Get endpoint object.
            this.Description = "View properties of this Always On Availability Group Replica";

            AvailabilityGroupReplica gGroup = tag.Tag as AvailabilityGroupReplica;

            if (gGroup != null)
            {
                _lbl_Name.Text       = gGroup.ReplicaServerName;
                _lbl_FailMode.Text   = gGroup.FailoverModeDesc;
                _lbl_CreateDate.Text = gGroup.CreateDate.ToShortDateString();
                _lb_ModifyDate.Text  = gGroup.ModifyDate.ToShortDateString();
                _lb_AvMode.Text      = gGroup.AvailabilityModeDesc;
                _lbl_EndUrl.Text     = gGroup.EndpointUrl;
            }
        }
Example #10
0
 public void Initialize(
         Sql.ServerVersion version,
         Sql.ObjectTag tag
     )
 {
     m_Version = version;
     m_Tag = tag;
     updateGrid();
 }
Example #11
0
        public static void Process(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Form_SnapshotAvailabilityGroupReplicaProperties form = new Form_SnapshotAvailabilityGroupReplicaProperties(version, tag);

            form.ShowDialog();
        }
        public static void Process(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Form_SnapshotUserProperties form = new Form_SnapshotUserProperties(version, tag);

            form.ShowDialog();
        }
        private Form_SnapshotServerRoleProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            InitializeComponent();

            // Initialize fields.
            m_Version = version;
            m_Tag     = tag;

            // Set min size to size.
            MinimumSize = Size;

            // Set form text.
            Text = "Server Role Properties - " + tag.ObjectName;

            // Fill name label.
            _lbl_Name.Text = tag.ObjectName;


            // Update members grid
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add(colTypeIcon, typeof(Image));
            dataTable.Columns.Add(colName, typeof(string));
            dataTable.Columns.Add(colType, typeof(string));
            List <Sql.Login> members = Sql.ServerRole.GetSnapshotServerRoleMembers(tag.SnapshotId, tag.ObjectId);

            foreach (Sql.Login l in members)
            {
                //Start-SQLsecure 3.1 (Tushar)--Added support for Azure SQL Database -- Using Windows user and group images for Azure AD user and group for now.
                if (l.Type == Sql.ObjectType.TypeEnum.AzureADUser)
                {
                    dataTable.Rows.Add(Sql.ObjectType.TypeImage16(Sql.ObjectType.TypeEnum.WindowsUserLogin), l.Name, l.TypeStr);
                }
                else if (l.Type == Sql.ObjectType.TypeEnum.AzureADGroup)
                {
                    dataTable.Rows.Add(Sql.ObjectType.TypeImage16(Sql.ObjectType.TypeEnum.WindowsGroupLogin), l.Name, l.TypeStr);
                }
                else
                {
                    dataTable.Rows.Add(Sql.ObjectType.TypeImage16(l.Type), l.Name, l.TypeStr);
                }
                //End-SQLsecure 3.1 (Tushar)--Added support for Azure SQL Database
            }
            _ultraGrid.BeginUpdate();
            _ultraGrid.DataSource = dataTable;
            _ultraGrid.DataMember = "";
            _ultraGrid.EndUpdate();

            ultraTabControl1.DrawFilter = new HideFocusRectangleDrawFilter();
        }
Example #14
0
        public static void Process(
            Sql.ServerVersion version,
            Sql.ObjectTag tag)
        {
            Debug.Assert(tag != null);

            Form_SnapshotDbObjProperties form = new Form_SnapshotDbObjProperties(version, tag);

            form.ShowDialog();
        }
        public static void Process(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            Form_SnapshotRegistryProperties form = new Form_SnapshotRegistryProperties(version, tag);

            form.ShowDialog();
        }
        public void Initialize(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            // Setup the fields.
            m_Version = version;
            m_Tag     = tag;

            // Update the grid with permissions.
            updateGrid();
        }
        public static void Process(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            // Validate inputs.
            if (tag == null || version == Sql.ServerVersion.Unsupported)
            {
                return;
            }

            // Create and show the form.
            Form_SnapshotServerProperties form = new Form_SnapshotServerProperties(version, tag);

            form.ShowDialog();
        }
        public Form_SnapshotUserProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            InitializeComponent();

            // Initialize fields.
            m_Version = version;
            m_Tag     = tag;

            // Set size and form text.
            MinimumSize = Size;
            Text        = "User Properties - " + m_Tag.ObjectName;

            // Get user associated with the tag.
            Sql.DatabasePrincipal user = Sql.DatabasePrincipal.GetSnapshotUser(m_Tag.SnapshotId, m_Tag.DatabaseId, m_Tag.ObjectId);

            // If user is found get roles and update fields.
            if (user != null)
            {
                // Fill fields.
                _lbl_Name.Text         = user.Name;
                _lbl_Type.Text         = user.TypeStr;
                _lbl_Login.Text        = user.Login;
                _lbl_HasAccess.Text    = user.HasAccessStr;
                _lbl_IsAliased.Text    = user.IsAliasStr;
                _lb_ContainedType.Text = user.AuthenticationType;
                if (user.IsAlias)
                {
                    _lbl_AliasedTo.Text = user.AltName;
                }

                if (version == Sql.ServerVersion.SQL2000)
                {
                    _lbl_DSN.Enabled = _lbl_DefaultSchemaName.Enabled = false;
                }
                else
                {
                    _lbl_DefaultSchemaName.Text = user.DefaultSchemaName;
                }

                // Get roles.
                List <Sql.DatabasePrincipal> roles = Sql.DatabasePrincipal.GetSnapshotUserRoles(m_Tag.SnapshotId, m_Tag.DatabaseId, m_Tag.ObjectId);

                // Update memberof grid
                DataTable dataTable = new DataTable();
                dataTable.Columns.Add(colTypeIcon, typeof(Image));
                dataTable.Columns.Add(colName, typeof(string));
                dataTable.Columns.Add(colType, typeof(string));
                foreach (Sql.DatabasePrincipal dbp in roles)
                {
                    dataTable.Rows.Add(Sql.ObjectType.TypeImage16(dbp.TypeEnum), dbp.Name, dbp.TypeStr);
                }
                _ultraGrid.BeginUpdate();
                _ultraGrid.DataSource = dataTable;
                _ultraGrid.DataMember = "";
                _ultraGrid.EndUpdate();

                ultraTabControl1.DrawFilter = new HideFocusRectangleDrawFilter();
            }
        }
Example #19
0
        private bool isRepositoryValid()
        {
            using (logX.loggerX.DebugCall())
            {
                using (SqlConnection connection = new SqlConnection(m_ConnectionStringBuilder.ConnectionString))
                {
                    // Open connection to the repository SQL Server.  Make sure we are connected
                    // to SQL Server 2000 or 2005.
                    try
                    {
                        // Open the connection.
                        connection.Open();

                        // Check the SQL Server version.
                        m_VersionEnum = Sql.SqlHelper.ParseVersion(connection.ServerVersion);
                        if (m_VersionEnum == Sql.ServerVersion.Unsupported)
                        {
                            logX.loggerX.Error("ERROR - Repository SQL Server version: ", connection.ServerVersion,
                                               " is not supported.");
                            AppLog.WriteAppEventError(SQLsecureEvent.DlErrInvalidRepositoryVersionMsg,
                                                      SQLsecureCat.DlValidationCat,
                                                      m_ConnectionStringBuilder.DataSource,
                                                      connection.ServerVersion);
                            return(false);
                        }

                        // Check if SQLsecure database is in the repository.
                        logX.loggerX.Info("Checking for SQLsecure database in the repository");
                        using (SqlDataReader rdr = Sql.SqlHelper.ExecuteReader(connection, null, CommandType.Text,
                                                                               QueryCheckSQLsecureDbExists, null))
                        {
                            if (!rdr.HasRows) // No rows found, no SQLsecure database
                            {
                                logX.loggerX.Error("ERROR - SQLsecure database not found.");
                                AppLog.WriteAppEventError(SQLsecureEvent.DlErrSQLsecureDbNotFound,
                                                          SQLsecureCat.DlValidationCat,
                                                          m_ConnectionStringBuilder.DataSource);
                                return(false);
                            }
                        }

                        // Check schema/DAL versions.
                        logX.loggerX.Info("Checking SQLsecure schema/DAL versions");
                        using (SqlDataReader rdr = Sql.SqlHelper.ExecuteReader(connection, null, CommandType.Text,
                                                                               QueryGetSchemaDALVersion, null))
                        {
                            // This table has only one row.
                            int schemaVer = 0, dalVer = 0;
                            if (rdr.Read())
                            {
                                // Get DAL & schema versions.
                                dalVer    = (int)rdr[0];
                                schemaVer = (int)rdr[1];
                            }
                            // If versions don't match, bail out.
                            if (dalVer != Constants.DalVersion || schemaVer != Constants.SchemaVersion)
                            {
                                logX.loggerX.Error("ERROR - DAL: ", dalVer, " Schema: ", schemaVer, " is not supported.");
                                AppLog.WriteAppEventError(SQLsecureEvent.DlErrSchemaVerNotCompatible, SQLsecureCat.DlValidationCat,
                                                          dalVer.ToString(), schemaVer.ToString(),
                                                          Constants.DalVersion.ToString(), Constants.SchemaVersion.ToString());
                                return(false);
                            }
                        }

                        // Check permissions in the repository.
                        logX.loggerX.Info("Checking for permissions to update Repository");
                        using (SqlDataReader rdr = Sql.SqlHelper.ExecuteReader(connection, null, CommandType.Text,
                                                                               QueryGetSQLsecurePermissions, null))
                        {
                            // Check for permissions, the result set has only one column.
                            bool havePermissions = false;
                            while (rdr.Read() && !havePermissions)
                            {
                                string role = (string)rdr[0];
                                havePermissions = String.Compare(role, Constants.AdminRole, true) == 0 ||
                                                  String.Compare(role, Constants.LoaderRole, true) == 0;
                            }

                            // If no permission, bail out.
                            if (!havePermissions)
                            {
                                logX.loggerX.Error("ERROR - Data Loader does not have permissions to load data in SQLsecure database.");
                                AppLog.WriteAppEventError(SQLsecureEvent.DlErrNoSQLsecurePermissions, SQLsecureCat.DlValidationCat);
                                return(false);
                            }
                        }

                        using (SqlDataReader rdr = Sql.SqlHelper.ExecuteReader(connection, null, CommandType.Text,
                                                                               QueryGetCountTargetServers, null))
                        {
                            if (rdr.Read())
                            {
                                m_NumRegisteredServers = (int)rdr[0];
                            }
                            else
                            {
                                logX.loggerX.Warn("WARN - failed to read server name");
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        logX.loggerX.Error("ERROR - exception raised when validating the repository.", ex);
                        AppLog.WriteAppEventError(SQLsecureEvent.ExErrExceptionRaised, SQLsecureCat.DlValidationCat,
                                                  "Repository Validation", ex.Message);
                        return(false);
                    }
                }

                return(true);
            }
        }
Example #20
0
        private bool OpenRepository()
        {
            using (SqlConnection connection = new SqlConnection(m_ConnectionStringBuilder.ConnectionString))
            {
                // Open connection to the repository SQL Server.  Make sure we are connected
                // to SQL Server 2000 or 2005.
                try
                {
                    //Clear any previous access if there is an error
                    Program.gController.Permissions.Clear();

                    // Open the connection.
                    logX.loggerX.Info("Opening connection to repository");
                    try
                    {
                        connection.Open();
                    }
                    catch (SqlException ex)
                    {
                        logX.loggerX.Error("ERROR - Can't open connection to Repository", ex);
                        MsgBox.ShowError(Utility.ErrorMsgs.CantConnectRepository, Utility.ErrorMsgs.FailedToConnectMsg);
                        return(false);
                    }

                    // Check the SQL Server version.
                    logX.loggerX.Info("Checking SQL Server version of repository");
                    m_SQLServerVersion = Sql.SqlHelper.ParseVersion(connection.ServerVersion);
                    if (m_SQLServerVersion == Sql.ServerVersion.Unsupported)
                    {
                        logX.loggerX.Error(string.Format(Utility.ErrorMsgs.ErrorStub, Utility.ErrorMsgs.VersionNotSupported), connection.ServerVersion);
                        MsgBox.ShowError(Utility.ErrorMsgs.VersionNotSupported, Utility.ErrorMsgs.SQLServerVersionNotSupported);
                        return(false);
                    }
                    //Save the version info
                    m_SQLServerFullVersion = connection.ServerVersion;

                    // Check if SQLsecure database is in the repository.
                    logX.loggerX.Info("Checking for SQLsecure database in the repository");
                    using (SqlDataReader rdr = Sql.SqlHelper.ExecuteReader(connection, null, CommandType.Text,
                                                                           QueryCheckSQLsecureDbExists, null))
                    {
                        if (!rdr.HasRows) // No rows found, no SQLsecure database
                        {
                            logX.loggerX.Error(string.Format(Utility.ErrorMsgs.ErrorStub, Utility.ErrorMsgs.RepositoryNotFound));
                            MsgBox.ShowError(Utility.ErrorMsgs.RepositoryNotFound, Utility.ErrorMsgs.RepositoryDBNotFound);
                            return(false);
                        }
                    }

                    // Check schema/DAL versions.
                    logX.loggerX.Info("Checking SQLsecure DAL version");
                    using (SqlDataReader rdr = Sql.SqlHelper.ExecuteReader(connection, null, CommandType.Text,
                                                                           String.Format(QuerySchemaDALVersionCompatible, "DAL", Utility.Constants.DalVersion), null))
                    {
                        bool isDalCompatible = false;
                        // This table has only one column and row with a Y or N in it.
                        if (rdr.Read())
                        {
                            // Get DAL & schema versions.
                            if (rdr[0].ToString().ToUpper() == "Y")
                            {
                                isDalCompatible = true;
                            }
                        }
                        // If versions don't match, bail out.
                        if (!isDalCompatible)
                        {
                            logX.loggerX.Error(string.Format(Utility.ErrorMsgs.ErrorStub, Utility.ErrorMsgs.DalNotSupported), Utility.Constants.DalVersion);
                            MsgBox.ShowError(Utility.ErrorMsgs.VersionNotSupported,
                                             String.Format(Utility.ErrorMsgs.IncompatibleVersion));//SQLsecure 3.1 (Tushar)--Fix for Defect SQLSECU-1672
                            return(false);
                        }
                    }
                    // Get the Schema and DAL versions for display if valid
                    logX.loggerX.Info("Retrieving SQLsecure DAL and Schema version");
                    using (SqlDataReader rdr = Sql.SqlHelper.ExecuteReader(connection, null, CommandType.Text,
                                                                           String.Format(QueryGetDALSchemaVersion), null))
                    {
                        // This table has only one column and row with a Y or N in it.
                        if (rdr.Read())
                        {
                            // Get DAL & schema versions.
                            m_SchemaVersion = Convert.ToInt32(rdr[(int)VersionColumn.schemaversion]);
                            m_DALVersion    = Convert.ToInt32(rdr[(int)VersionColumn.dalversion]);
                        }
                    }

                    Program.gController.Permissions.checkRepositorySecurity(m_ConnectionStringBuilder.ConnectionString);

                    // populate the lists of policies, registered servers and notification providers if user has view security
                    if (Program.gController.Permissions.isViewer)
                    {
                        LoadPolicies();
                        LoadRegisteredServers();
                        LoadNotificationProvider();
                    }

                    using (SqlDataReader rdr = Sql.SqlHelper.ExecuteReader(connection, null, CommandType.Text,
                                                                           QueryServername, null))
                    {
                        if (rdr.Read())
                        {
                            m_RepositoryComputerName = (string)rdr[0];
                        }
                        else
                        {
                            logX.loggerX.Warn("WARN - failed to read server name");
                        }
                    }

                    // get repository info - currently, only the size is used
                    using (SqlDataReader rdr = Sql.SqlHelper.ExecuteReader(connection, null, CommandType.Text,
                                                                           QueryGetDbInfo, null))
                    {
                        m_DbSize = string.Empty;
                        if (rdr.Read())
                        {
                            m_DbSize = rdr[ColRepositoryInfo_DbSize].ToString().Trim();
                        }
                        else
                        {
                            logX.loggerX.Warn("WARN - failed to read repository server info");
                        }
                    }
                }
                catch (SqlException ex)
                {
                    if (ex.Number == 229)
                    {
                        logX.loggerX.Error("ERROR - user has no permissions to the repository.", ex);
                        MsgBox.ShowError(Utility.ErrorMsgs.CantConnectRepository, Utility.ErrorMsgs.UserHasNoPermission);
                    }
                    else
                    {
                        logX.loggerX.Error("ERROR - exception raised when validating the repository.", ex);
                        MsgBox.ShowError(Utility.ErrorMsgs.CantConnectRepository, Utility.ErrorMsgs.CantValidateRepository, ex);
                    }
                    return(false);
                }

                return(true);
            }
        }
Example #21
0
        private Form_SnapshotLoginProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            InitializeComponent();

            // Initialize fields.
            m_Version = version;
            m_Tag     = tag;

            // Set min size to size.
            MinimumSize = Size;

            // Set form text.
            Text = "Login Properties - " + m_Tag.ObjectName;

            // Get login properties.
            Sql.Login l = Sql.Login.GetSnapshotLogin(m_Tag.SnapshotId, m_Tag.ObjectId);

            switch (m_Tag.ObjType)
            {
            case Sql.ObjectType.TypeEnum.WindowsUserLogin:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.WindowsUser_48;
                break;

            case Sql.ObjectType.TypeEnum.WindowsGroupLogin:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.WindowsGroup_48;
                break;

            case Sql.ObjectType.TypeEnum.SqlLogin:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.SQLServerLogin_48;
                break;

            //Start-SQLsecure 3.1 (Tushar)--Added support for Azure SQL Database
            case Sql.ObjectType.TypeEnum.AzureADUser:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.WindowsUser_48;
                break;

            case Sql.ObjectType.TypeEnum.AzureADGroup:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.WindowsGroup_48;
                break;
                //End-SQLsecure 3.1 (Tushar)--Added support for Azure SQL Database
            }

            // Fill fields.
            _lbl_Name.Text              = l.Name;
            _lbl_Type.Text              = l.TypeStr;
            _lbl_ServerAccess.Text      = l.ServerAccessStr;
            _lbl_ServerDeny.Text        = l.ServerDenyStr;
            _lbl_PasswordHealth.Text    = l.PasswordStatus;
            _lbl_DefaultDatabase.Text   = l.DefaultDatabase;
            _lbl_DefaultLanguage.Text   = l.DefaultLanguage;
            _lbl_Disabled.Text          = l.IsDisabledStr;
            _lbl_ExpirationChecked.Text = l.IsExpirationCheckedStr;
            _lbl_PolicyChecked.Text     = l.IsPolicyCheckedStr;


            // Get roles.
            List <Sql.ServerRole> roles = Sql.Login.GetSnapshotLoginRoles(m_Tag.SnapshotId, m_Tag.ObjectId);

            // Update members grid
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add(colTypeIcon, typeof(Image));
            dataTable.Columns.Add(colName, typeof(string));
            dataTable.Columns.Add(colType, typeof(string));
            foreach (Sql.ServerRole role in roles)
            {
                dataTable.Rows.Add(Sql.ObjectType.TypeImage16(role.TypeEnum), role.Name, role.TypeStr);
            }
            _ultraGrid.BeginUpdate();
            _ultraGrid.DataSource = dataTable;
            _ultraGrid.DataMember = "";
            _ultraGrid.EndUpdate();

            ultraTabControl1.DrawFilter = new HideFocusRectangleDrawFilter();
        }
Example #22
0
        public Form_SnapshotDbObjProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            InitializeComponent();

            // Update fields.
            m_Version   = version;
            m_ObjectTag = tag;

            // Retrieve properties.
            string name        = string.Empty,
                   owner       = string.Empty,
                   schema      = string.Empty,
                   schemaowner = string.Empty;

            getNames(ref name, ref owner, ref schema, ref schemaowner);

            // Set the properties.
            _lbl_Name.Text  = name;
            _lbl_Owner.Text = owner;
            if (m_Version == Sql.ServerVersion.SQL2000)
            {
                _lbl_S.Enabled        = _lbl_Schema.Enabled = false;
                _lbl_SO.Enabled       = _lbl_SchemaOwner.Enabled = false;
                _lbl_Schema.Text      = "";
                _lbl_SchemaOwner.Text = "";
            }
            else
            {
                _lbl_Schema.Text      = schema;
                _lbl_SchemaOwner.Text = schemaowner;
            }

            // Set title based on type.
            this.Text = tag.TypeName + " Properties - " + name;

            Description = "View properties for this SQL Server " + tag.TypeName;

            switch (tag.ObjType)
            {
            case Sql.ObjectType.TypeEnum.Table:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.Table_48;
                break;

            case Sql.ObjectType.TypeEnum.View:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.View1_48;
                break;

            case Sql.ObjectType.TypeEnum.Synonym:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.Synonym_48;
                break;

            case Sql.ObjectType.TypeEnum.StoredProcedure:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.StoredProcedure_48;
                break;

            case Sql.ObjectType.TypeEnum.Function:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.Function_48;
                break;

            case Sql.ObjectType.TypeEnum.ExtendedStoredProcedure:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.StoredProcedure_48;
                break;

            case Sql.ObjectType.TypeEnum.Assembly:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.assembly_48;
                break;

            case Sql.ObjectType.TypeEnum.UserDefinedDataType:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.UserDefinedData_48;
                break;

            case Sql.ObjectType.TypeEnum.XMLSchemaCollection:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.XMLSchemaCollection_48;
                break;

            case Sql.ObjectType.TypeEnum.FullTextCatalog:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.FulltextCatalog_48;
                break;

            case Sql.ObjectType.TypeEnum.SequenceObjects:
                Picture = global::Idera.SQLsecure.UI.Console.Properties.Resources.sequence_48;
                break;
            }

            // Fill explicit permissions.
            _permissionsGrid.Initialize(m_Version, m_ObjectTag);
        }
Example #23
0
        public Form_SnapshotDbRoleProperties(
            Sql.ServerVersion version,
            Sql.ObjectTag tag
            )
        {
            Debug.Assert(version != Sql.ServerVersion.Unsupported);
            Debug.Assert(tag != null);

            InitializeComponent();

            // Initialize fields.
            m_Version = version;
            m_Tag     = tag;

            // Set size and text.
            MinimumSize = Size;
            Text        = "Role Properties - " + m_Tag.ObjectName;

            // Get the role object & its members.
            Sql.DatabasePrincipal role = Sql.DatabasePrincipal.GetSnapshotDbRole(m_Tag.SnapshotId, m_Tag.DatabaseId, m_Tag.ObjectId);
            if (role != null)
            {
                // Update fields.
                _lbl_Name.Text  = role.Name;
                _lbl_Type.Text  = role.TypeStr;
                _lbl_Owner.Text = role.Owner;

                // Fill role members grid based on the role type.
                DataTable dataTable = new DataTable();
                if (role.TypeEnum == Sql.ObjectType.TypeEnum.DatabaseRole)
                {
                    // Get role members.
                    List <Sql.DatabasePrincipal> members = Sql.DatabasePrincipal.GetSnapshotDbRoleMembers(m_Tag.SnapshotId, m_Tag.DatabaseId, m_Tag.ObjectId);

                    // Update members grid
                    dataTable.Columns.Add(colTypeIcon, typeof(Image));
                    dataTable.Columns.Add(colName, typeof(string));
                    dataTable.Columns.Add(colType, typeof(string));
                    foreach (Sql.DatabasePrincipal dbp in members)
                    {
                        dataTable.Rows.Add(Sql.ObjectType.TypeImage16(dbp.TypeEnum), dbp.Name, dbp.TypeStr);
                    }
                }
                else if (role.TypeEnum == Sql.ObjectType.TypeEnum.ApplicationRole)
                {
                    dataTable.Columns.Add(colTypeIcon, typeof(Image));
                    dataTable.Columns.Add(colName, typeof(string));
                    dataTable.Columns.Add(colType, typeof(string));
                    dataTable.Rows.Add(null, "Application roles do not contain members", string.Empty);
                }
                else
                {
                    Debug.Assert(false, "Unknown role type");
                }

                _ultraGrid.BeginUpdate();
                _ultraGrid.DataSource = dataTable;
                _ultraGrid.DataMember = "";
                _ultraGrid.EndUpdate();

                ultraTabControl1.DrawFilter = new HideFocusRectangleDrawFilter();
            }
        }