Note:Fix those SIDs

Big fat disclaimer: Microsoft does NOT support ANY modifications to your SharePoint databases.  That's not to say they won't support your SharePoint site, but if this operation breaks your server, Microsoft won't help you.  I'm not responsible for the results, either, while we're on the subject of passing the buck.  BACK UP YOUR DATABASE.

Okay, now that we've gotten that mumbo-jumbo out of the way, here's the code.

DECLARE @login varchar(40), @systemid varbinary(128)

DECLARE curUsers CURSOR LOCAL FOR
SELECT tp_login, tp_systemid FROM userinfo where tp_deleted = 0

OPEN curUsers

FETCH NEXT FROM curUsers INTO @login, @systemid

WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Resetting user ' + @login + ' to new SID '
PRINT suser_sid(@login)
UPDATE UserInfo
SET tp_systemid = suser_sid(tp_login) WHERE CURRENT OF curUsers
FETCH NEXT FROM curUsers INTO @login, @systemid
END

CLOSE curUsers
DEALLOCATE curUsers

GO

你可能感兴趣的:(Note)