HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

Fix for orphan user 'guest'?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
fixorphanuserguestfor

Problem

What can be done, if anything, when the special guest user is orphaned (not linked to any login)?

For one of my databases (SQL Server 2005), executing the following lists the guest user as an orphaned user.

exec sp_change_users_login 'report'


Results:

UserName    UserSID
guest       0x3C2E66759FFBC14F84127D6795C27FD3


If I try to fix the guest user using that procedure, I get the following:

exec sp_change_users_login 'update_one', 'guest', 'guest'



Terminating this procedure. 'guest' is a forbidden value for the
login name parameter in this procedure.

If I try to delete the user, I get:


User 'guest' cannot be dropped, it can only be disabled.

select * from sys.database_principals where name = 'guest'


Results in:

name                 guest
principal_id         2
type                 S
type_desc            SQL_USER
default_schema_name  guest
create_date          11/13/98 2:58 AM
modify_date          10/16/01 4:31 PM
owning_principal_id  NULL
sid                  0x3C2E66759FFBC14F84127D6795C27FD3
is_fixed_role        0


The database seems to be confused as to whether this is a special user or not. Is there anything that can be done?

Solution

The user "guest" is never assigned to a server login, even on a fresh install it is classified as a SQL user without a login. As you can only set the SID of a login (upon creation), and not a user I don't believe that this is possible; sp_change_users_login does not work precisely for the reason that the guest account should never be mapped to a server login. As a result, the user "guest" is always an orphaned user. Probably not the answer you wanted though :)

Context

StackExchange Database Administrators Q#18801, answer score: 5

Revisions (0)

No revisions yet.