December 29, 2004 at 9:35 am
I will like to grant a specific database role to all NT users in a database and give everyone the same default database (refreshed weekly.)
Attempting to avoid repitition since there are so many users
Better Ideas are very welcome, but if all you can offer is a query which returns 'DOMAIN\username' that will be appreciated too.
Mike
December 29, 2004 at 11:23 am
use master
declare @name varchar(50)
declare @sqlscript varchar(2000)
declare name_cursor CURSOR FOR (select [name] into #temp from syslogins where name like '[Domain Name]%')
open name_cursor
FETCH NEXT FROM name_Cursor into @name
WHILE @@FETCH_STATUS = 0
BEGIN
set @sqlscript='EXEC sp_defaultdb '+@name+', ''[DB NAME]'''
exec (@sqlscript)
FETCH NEXT FROM name_Cursor into @name
END
CLOSE name_Cursor
DEALLOCATE nameCursor
drop table #temp
December 29, 2004 at 12:48 pm
Better mousetrap. Create an NT group (Windows or Active Directory). Assign ALL users that can get to the system to that group.
This way you already know the group and can assign permissions to 1 item....
Good Hunting!
AJ Ahrens
webmaster@kritter.net
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply