Microsoft KB Archive/305711

From BetaArchive Wiki

Article ID: 305711

Article Last Modified on 6/6/2005



APPLIES TO

  • Microsoft SQL Server 2000 Standard Edition



This article was previously published under Q305711


SYMPTOMS

The database owner (dbo) user in a user database is not listed in the Users folder in Enterprise Manager. Additionally, when you view the properties of any login in the Logins folder in Enterprise Manager, you may receive the following error messages:

Error 21776: [SQL-DMO] The name 'dbo' was not found in the Users collection. If the name is a qualified name, use [] to separate various parts of the name, and try again.

This problem only occurs after you apply SQL Server 2000 Service Pack 1 (SP1) to the server. Prior to Service Pack 1, the dbo user displays with a blank Login Name.

CAUSE

Enterprise Manager is incorrectly filtering out all the users that do not have matching logins, and the dbo user does not have a matching login. Two possible reasons for this behavior to occur are:

  • If a database is created by a Microsoft Windows NT authenticated login that is granted access to the computer that is running SQL Server through group membership (such as BUILTIN\Administrators), the security identification number (SID) stored in the sysusers system table in that database does not have a matching SID in the syslogins system table.
  • If a database is restored where the dbo user's SID in the sysusers system table is not matched with the SID in the syslogins system table.


WORKAROUND

If the dbo user does not have an explicit login, change the owner of the database to a user that has an explicit login. For example, change the owner of the database to the system administrator (sa), and then execute the following code:

exec sp_changedbowner 'sa'
                    

STATUS

Microsoft has confirmed this to be a problem in SQL Server 2000 Service Pack 1 (SP1).

MORE INFORMATION

To determine if the dbo user is unmatched in a user database, execute the following query:

Use <User_Database>

GO

SELECT u.name AS "Name", ISNULL(l.name, 'dbo is unmatched') AS "Matched Login"

FROM sysusers u

     LEFT JOIN master.dbo.syslogins l ON u.sid = l.sid

WHERE u.name = 'dbo'

GO

REFERENCES

For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:

218172 PRB: Cannot change SA password in Enterprise Manager


274188 PRB: "Troubleshooting Orphaned Users" topic in Books Online is incomplete


168001 PRB: User logon and/or permission errors after restoring dump


246133 How to transfer logins and passwords between instances of SQL Server


298758 PRB: Using the Auto_Fix option with sp_change_users_login can leave security vulnerabilities



Additional query words: error dmo sqldmo sem sysusers syslogins 21776

Keywords: kbbug kbpending KB305711