Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
vaddi
Posting Yak Master
145 Posts |
Posted - 2006-11-29 : 13:14:44
|
HelloAfter refreshing a test database , I am running the following procedure , but I am not able to get back the windows authenticated user permissions. What should I do.CREATE PROCEDURE dbo.sp_fixusersASBEGINDECLARE @username varchar(25)DECLARE fixusers CURSOR FORSELECT UserName = name FROM sysusersWHERE issqluser = 1 and (sid is not null and sid <> 0x0)and suser_sname(sid) is nullORDER BY nameOPEN fixusersFETCH NEXT FROM fixusersINTO @usernameWHILE @@FETCH_STATUS = 0BEGINIF @username='dbo'BEGIN EXEC sp_changedbowner 'sa'ENDELSEBEGINEXEC sp_change_users_login 'update_one', @username, @usernameENDFETCH NEXT FROM fixusersINTO @usernameENDCLOSE fixusersDEALLOCATE fixusersENDgoIF OBJECT_ID('dbo.sp_fixusers') IS NOT NULLPRINT '<<< CREATED PROCEDURE dbo.sp_fixusers >>>'ELSEPRINT '<<< FAILED CREATING PROCEDURE dbo.sp_fixusers >>>'goThanks |
|
Westley
Posting Yak Master
229 Posts |
Posted - 2006-11-29 : 21:41:14
|
I don't think you will need to sync the Windows users, as its not required. |
 |
|
vaddi
Posting Yak Master
145 Posts |
Posted - 2006-12-01 : 00:11:39
|
HelloI create the following procedure before the database is restored/refreshed .CREATE PROCEDURE dbo.sp_fixusersASBEGINDECLARE @username varchar(25)DECLARE fixusers CURSOR FORSELECT UserName = name FROM sysusersWHERE issqluser = 1 and isntuser=1 and (sid is not null and sid <> 0x0)and suser_sname(sid) is nullORDER BY nameOPEN fixusersFETCH NEXT FROM fixusersINTO @usernameWHILE @@FETCH_STATUS = 0BEGINIF @username='dbo'BEGIN EXEC sp_changedbowner 'sa'ENDELSEBEGINEXEC sp_change_users_login 'update_one', @username, @usernameENDFETCH NEXT FROM fixusersINTO @usernameENDCLOSE fixusersDEALLOCATE fixusersENDgoAnd run the dbo.sp_fixusers after the refresh is done.But I donot get back the user permissions back .What should I do.Thanks |
 |
|
|
|
|