I've restored a database on another server where I've recreated all the users (SQL users and Windows users) with the same permissions of the original ones. The problem is that the sid of the newly created users isn't the same of the originals, so I wrote a little script to assign the right sid to the restored users.
exec sp_configure 'allow updates', '1'
RECONFIGURE WITH OVERRIDE
go
/* SQL users */
update sysusers set sid=l.sid
FROM sysusers u INNER JOIN master..syslogins l
ON u.name=l.name
where (u.isntuser = 0) and
(islogin = 1) AND u.name=right(l.name,len(u.name))
go
/* Windows users */
update sysusers set sid=l.sid
FROM sysusers u, master..syslogins l
where (u.isntuser = 1) and
(islogin = 1) AND u.name=right(l.name,len(u.name))
go
/* dbo user */
update sysusers set sid=l.sid
FROM sysusers u, master..syslogins l
WHERE u.name='dbo' AND l.name='BUILTIN\Administrator'
exec sp_configure 'allow updates', '0'
reconfigure WITH OVERRIDE
go
Hope that's helpful. Max
exec sp_configure 'allow updates', '1'
RECONFIGURE WITH OVERRIDE
go
/* SQL users */
update sysusers set sid=l.sid
FROM sysusers u INNER JOIN master..syslogins l
ON u.name=l.name
where (u.isntuser = 0) and
(islogin = 1) AND u.name=right(l.name,len(u.name))
go
/* Windows users */
update sysusers set sid=l.sid
FROM sysusers u, master..syslogins l
where (u.isntuser = 1) and
(islogin = 1) AND u.name=right(l.name,len(u.name))
go
/* dbo user */
update sysusers set sid=l.sid
FROM sysusers u, master..syslogins l
WHERE u.name='dbo' AND l.name='BUILTIN\Administrator'
exec sp_configure 'allow updates', '0'
reconfigure WITH OVERRIDE
go
Hope that's helpful. Max