I am writing a MSSQL2000 database-aware application that is, among other things, going to run queries. The database in question will have security settings in different places, and the query must be executed from the user context of a given user / group. Users and groups refer to local system accounts or Active Directory accounts. Assume the former.
Herein lies my problem. I don't know how to begin to execute the query under the context of an arbitrary user. How do I execute code in an arbitrary user's context? Does the SqlConnection have to be created in that context, or just the query command?
Any solutions that don't use unmanaged code would be much preferred! Thanks.