SQL Script to add domain users in SQL Server
Posted on 2011-10-11
Just wondering if anyone can help me out here...I guess a vendor asked me to add users to the SQL Server via a script (I can do it manually, but that would take forever...lol....). We have about 125 users and they need to be mapped to 2 databases. Within 1 database, the users will sorted in 3 roles within the database: Admin, Editor, Viewers and assinged a schema.
Normally, I would create a Workgroup in Active Directory (AD) then add that workgroup in the SQL Server, and apply the roles, schemas, etc...but the vendor said this would not work...
What would be the best practice to accomplish this? I have access to the AD server, so I was thinking this:
Export the users from AD into a Excel file
Run a macro to generate the SQL Syntax code based on those users
Run the script against the SQL Server....
Would this work, or am I out to lunch somewhere...lol? Can anyone provide a sample script where I can edit the default databases, roles, and schemas?
Thanks for your help!