Re: Connecting to SQLServer 2000 from ASP.NET

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Steven Cheng[MSFT] (v-schang_at_online.microsoft.com)
Date: 04/24/04


Date: Sat, 24 Apr 2004 02:59:47 GMT

Hi Patrick,

First, glad that your critical problem has been resolved. As for the
connecting to sqlserver problem,
have you ever tried the suggestions in my last reply? As I've mentioned,
when you want to provide some powerful permisssions(a powerful account )
when accessing some serverside resource, you can just use impersonate
rather than changing anything in the machine.config.

You can both
1) the user account from the client(passed by iis)
2) specified a fix accoun in the <identity ..> element for asp.net to use
when accessing serverside resources.
 <identity impersonate="true" userName="MyDomain\aspUser1"
password="password"/>

#note in your web.config, not machine.config, machine.config is the setting
for all the web applicatoin on the machine, and can be override in each web
app' web.config file.

when we set <identity impersonate="true" ...> if we specify a user account
after it, then the asp.net will use this account to access serverside
resources . If not specified, it will use the account passed from IIS(the
client account)

3) Also, we can use code to programmatically impersnate the current
thread's security context. I strongly recommend that you have a look at the
following tech article which may provide some clues.

#INFO: Implementing Impersonation in an ASP.NET Application
http://support.microsoft.com/?id=306158

Also, the following refrences will help you understand the impersonating
and the ASP.NET's authentication mechnism.

#ASP.NET Impersonation
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconaspnetimpersonatio
n.asp?frame=true

#Using IIS Authentication With ASP.NET Impersonation
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconusingiisauthentica
tionwithaspnetimpersonation.asp?frame=true

Good Luck. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx



Relevant Pages

  • Re: Connecting to SQLServer 2000 from ASP.NET
    ... I have deployed the code on the Development Server, ... > when you want to provide some powerful permisssions(a powerful account) ... > when accessing some serverside resource, ... Implementing Impersonation in an ASP.NET Application ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SetPassword access denied
    ... safely invoke SetPassword etc..... ... impersonation or using the process token without impersonation) is NOT ... account that is used for performing remote activities in the directory. ... Co-author of "The .NET Developer's Guide to Directory Services ...
    (microsoft.public.windows.server.active_directory)
  • Re: VS.NET 2005 and the "allowDefinition=MachineToApplication" error
    ... Your description of impersonation is great. ... If you want to use the default configured account, eliminate that entry, or configure it as: ... The easiest way to assign correct permissions to all required directories is to run: ... I re-started IIS and tried to access my ASPX page again -- same ...
    (microsoft.public.dotnet.framework.aspnet)
  • [Full-disclosure] Maybe nothing so shady; depends on the motive.
    ... There may be no impersonation going on. ... attempted use of a disabled account would produce messages about "account foo login fail" ... SecureWorks was still reading email addressed to David Maynor. ...
    (Full-Disclosure)
  • Re: SetPassword access denied
    ... That said, I think one thing worth pointing out is that in both cases here, your code is supplying credentials to the DirectoryEntry constructor. ... the identity of the current thread (established either via impersonation or using the process token without impersonation) is NOT the account that is used for performing remote activities in the directory. ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ...
    (microsoft.public.windows.server.active_directory)