Friday, April 9, 2010

Impersonating the current Windows user


SQL server 2008 seems to make life much easier with integrated security so that us DBA s no longer have to manage passwords. All we have to do is setup what AD groups have which permissions on whatever tables.


I use the following code when accessing a SQL server database with Integrated security so that I can control user permissions through AD groups and accounts based on what credentials are currently in use.


using (((WindowsIdentity)User.Identity).Impersonate()) {

// SQL statements

}

No comments:

Post a Comment