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(); } }
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(); } }