SQL Server Developer Center > SQL Server Forums > SQL Server Security > Automatically add new windows user to sql server?
Ask a questionAsk a question
 

AnswerAutomatically add new windows user to sql server?

  • Thursday, November 05, 2009 11:20 AMMeltdown61 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi all,

    Is it possible to automatically add a new windows user to sql server as a login and assign them to a role?...if so...how? So when the Admin is creating the new Windows account they are automatically added to Sql Server.

    Thanks

Answers

  • Thursday, November 05, 2009 2:36 PMAkimZ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello,

    I assume you have small environment and minimal auditing with all users in the environment "MUST HAVE" access to SQL Server.
    You can create SQL_Server_Access Active Directory group and grant that group access to your SQL Server. Your Windows Admin would create a script or policy which would add every new user to that SQL_Server_Access AD group. It is done on AD side, not on SQL Server side.
    On SQL Server side you can add "Authenticated Users" or "Everyone", but that would be OPEN GATE to your SQL Server for the whole world, so I DON'T recommend doing that.

    Regards,
    • Marked As Answer byMeltdown61 Saturday, November 07, 2009 11:24 PM
    •  

All Replies

  • Thursday, November 05, 2009 2:36 PMAkimZ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hello,

    I assume you have small environment and minimal auditing with all users in the environment "MUST HAVE" access to SQL Server.
    You can create SQL_Server_Access Active Directory group and grant that group access to your SQL Server. Your Windows Admin would create a script or policy which would add every new user to that SQL_Server_Access AD group. It is done on AD side, not on SQL Server side.
    On SQL Server side you can add "Authenticated Users" or "Everyone", but that would be OPEN GATE to your SQL Server for the whole world, so I DON'T recommend doing that.

    Regards,
    • Marked As Answer byMeltdown61 Saturday, November 07, 2009 11:24 PM
    •  
  • Thursday, November 05, 2009 2:48 PMrichbrownesqModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    Absolutely- use Windows groups (these can be local groups or active directory groups).

    Read the following article:

    http://www.mssqltips.com/tip.asp?tip=1831

    every day is a school day
    • Proposed As Answer byLekss Thursday, November 05, 2009 4:18 PM
    •  
  • Saturday, November 07, 2009 11:25 PMMeltdown61 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks very much guys, I'll look  into those options.

    Regards
    Melt
  • Sunday, November 08, 2009 4:52 PMA.Lockwood Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    To add to AkimZ answer; in a domain you could grant login access to DOMAIN\Domain Users and then map that login to various DB roles, but it's really wide open and I don't think anyone would recommend that unless you've designed the server, database, and roles in a such a way as to mitigate all the associated risks.
    It would however be the absolute easiest way to ensure that every single account has access to SQL at creation time while still ensuring the account is properly authenticated.

    -Andrew