Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

SSMS <-> SMO Bug listing db_datareader role members

未關閉
#44 7 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
csharp, sql
領域
database

研究方向

首先重現 issue 中的資料庫設定,並將 SMO/SSMS db_datareader 角色成員檢視與 sys.database_role_members 進行比較。檢查 Object Explorer 輸出中顯示的 SQL 以及進入點 DBRoleProp;當巢狀角色成員資格與查詢結果一致地顯示時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

@shueybubbles Ran into this Friday night during a production deploy that re-organized permissions... Came up with a simple repro:

Try the following database:

CREATE DATABASE [Test]
GO

USE [Test]
GO

CREATE ROLE Readers
GO

ALTER ROLE db_datareader ADD MEMBER [Readers]
GO

CREATE USER [MYDOMAIN\michael.miller] WITHOUT LOGIN
GO

ALTER ROLE Readers ADD MEMBER [MYDOMAIN\michael.miller]
GO

/* Output Table formatted with GitHub Markdown below */
SELECT * FROM sys.database_principals WHERE name = 'db_datareader'

/* Output Table formatted with GitHub Markdown below */
SELECT p.name FROM sys.database_role_members rm 
JOIN sys.database_principals p ON rm.member_principal_id = p.principal_id
WHERE rm.role_principal_id = 16390
name principal_id type type_desc default_schema_name create_date modify_date owning_principal_id sid is_fixed_role authentication_type authentication_type_desc default_language_name default_language_lcid allow_encrypted_value_modifications
db_datareader 16390 R DATABASE_ROLE NULL 2003-04-08 09:10:42.363 2009-04-13 12:59:14.467 1 0x01050000000000090400000000000000000000000000000006400000 1 0 NONE NULL NULL 0
name
Readers

When I go into SSMS and right click on Properties for the db_datareader role, I see the following INCORRECT mappings that do not match the output of the last two queries above:

image

I think there may be a separate bug here, observable in SSMS but not sure what SMO calls SSMS is making (is there a way to force SSMS to log that to the telemetry window? Telemetry window doesn't have super detailed logging by default).

The SSMS "Output Window --> Object Explorer" output I get is:

[2021-01-11T11:05:14.2162761-05:00 End Query] URN:Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role 

                                   Elapsed time:10.7294 ms 

                                   Query: SELECT
                                   rl.name AS [Name],
                                   'Server[@Name=' + quotename(CAST(
                                           serverproperty(N'Servername')
                                          AS sysname),'''') + ']' + '/Database[@Name=' + quotename(db_name(),'''') + ']' + '/Role[@Name=' + quotename(rl.name,'''') + ']' AS [Urn],
                                   rl.principal_id AS [ID],
                                   CAST(CASE WHEN rl.principal_id > 16383 AND rl.principal_id < 16400 THEN 1 ELSE 0 END AS bit) AS [IsFixedRole]
                                   FROM
                                   sys.database_principals AS rl
                                   WHERE
                                   (rl.type = 'R')
                                   ORDER BY
                                   [Name] ASC

which produces the following output table:

Name Urn ID IsFixedRole
db_accessadmin Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='db_accessadmin'] 16385 1
db_backupoperator Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='db_backupoperator'] 16389 1
db_datareader Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='db_datareader'] 16390 1
db_datawriter Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='db_datawriter'] 16391 1
db_ddladmin Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='db_ddladmin'] 16387 1
db_denydatareader Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='db_denydatareader'] 16392 1
db_denydatawriter Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='db_denydatawriter'] 16393 1
db_owner Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='db_owner'] 16384 1
db_securityadmin Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='db_securityadmin'] 16386 1
public Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='public'] 0 0
Readers Server[@Name='---SCRUBBED---']/Database[@Name='Test']/Role[@Name='Readers'] 5 0

and the SSMS "Output Window -> Telemetry" output view has:

[2021-01-11T11:05:07.7326467-05:00] sql/ssms/explorerhierarchynode/buildchildren
                                    DataModel.Action.DurationInMilliseconds = 185.0194
                                    SQL.SSMS.ObjectExplorer.Entity = Server/DatabasesFolder
                                    SQL.SSMS.ObjectExplorer.IsSqlDW = False
                                    SQL.SSMS.ObjectExplorer.ServerType = Standalone
[2021-01-11T11:05:09.2765405-05:00] sql/ssms/explorerhierarchynode/buildchildren
                                    DataModel.Action.DurationInMilliseconds = 44.0064
                                    SQL.SSMS.ObjectExplorer.Entity = Server/Database
                                    SQL.SSMS.ObjectExplorer.IsSqlDW = False
                                    SQL.SSMS.ObjectExplorer.ServerType = Standalone
[2021-01-11T11:05:11.3234256-05:00] sql/ssms/explorerhierarchynode/buildchildren
                                    DataModel.Action.DurationInMilliseconds = 3.982
                                    SQL.SSMS.ObjectExplorer.Entity = Server/Database/DatabaseSecurityFolder
                                    SQL.SSMS.ObjectExplorer.IsSqlDW = False
                                    SQL.SSMS.ObjectExplorer.ServerType = Standalone
[2021-01-11T11:05:12.6408375-05:00] sql/ssms/explorerhierarchynode/buildchildren
                                    DataModel.Action.DurationInMilliseconds = 0.538
                                    SQL.SSMS.ObjectExplorer.Entity = Server/Database/RolesFolder
                                    SQL.SSMS.ObjectExplorer.IsSqlDW = False
                                    SQL.SSMS.ObjectExplorer.ServerType = Standalone
[2021-01-11T11:05:14.2193114-05:00] sql/ssms/explorerhierarchynode/buildchildren
                                    DataModel.Action.DurationInMilliseconds = 27.0348
                                    SQL.SSMS.ObjectExplorer.Entity = Server/Database/DatabaseRolesFolder
                                    SQL.SSMS.ObjectExplorer.IsSqlDW = False
                                    SQL.SSMS.ObjectExplorer.ServerType = Standalone
[2021-01-11T11:05:16.9081278-05:00] sql/ssms/explorerhierarchynode/setupmenuparent
                                    DataModel.Action.DurationInMilliseconds = 0
                                    SQL.SSMS.ObjectExplorer.Entity = Server/Database/Role
                                    SQL.SSMS.ObjectExplorer.IsSqlDW = False
                                    SQL.SSMS.ObjectExplorer.ServerType = Standalone
[2021-01-11T11:05:16.9191466-05:00] sql/ssms/explorerhierarchynode/getmenuitems
                                    DataModel.Action.DurationInMilliseconds = 8.9941
                                    SQL.SSMS.ObjectExplorer.Entity = Server/Database/Role
                                    SQL.SSMS.ObjectExplorer.IsSqlDW = False
                                    SQL.SSMS.ObjectExplorer.ServerType = Standalone
[2021-01-11T11:05:21.8648667-05:00] /sql/ssms/dialog
                                    SQL.Dialog.Action = Invoke
                                    SQL.Dialog.Name = DBRoleProp

主要語言
C#
星號
143
分支
28
PR 合併指標
30 天內沒有已合併 PR

環境準備

我們還沒有檢查這個專案的環境設定檔。先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

microsoft/sqlmanagementobjects 的其他 Issue

查看 microsoft/sqlmanagementobjects 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。