user_sid - 05-04-2004 , 06:26 PM
What does the SQL command user_sid do? Where does it get it's data? It is currently used in sp_change_users_login, but I cannot find any documentation on this function
Re: user_sid - 05-04-2004 , 09:35 PM
It's not documented (but suser_sid is documented). If you
look at what it's doing, it's essentially just executing:
which returns the sid. The sids are stored in sysusers,
On Tue, 4 May 2004 16:26:02 -0700, "partymonkey"
<anonymous (AT) discussions (DOT) microsoft.com> wrote:
Re: user_sid - 05-05-2004 , 06:56 PM
I acutally figured this out. You are correct that in sp_change_users_login it is used as such "user_sid(suser_sid('SomeUser'))"
But if you also look in sp_grantdbaccess, you'll see it used as such "user_sid(user_id('SomeUser'))". So this is actually an MS bug in sp_change_users_login
"user_sid" takes a uid from sysusers of the current database and returns the sid. But in sp_change_users_login is passing in a sid from syslogins, which is incorrect
In my case, the sid that was being passed into sp_change_users_login was implicitly being converted to a smallint (because it's expecting a uid, which is a smallint) which turned out to be a valid uid and I was getting a duplicate sid error