Hybrid sql server and asp.net windows authentication

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Hybrid sql server and asp.net windows authentication

    I have an asp.net web application that executes stored procedures on SQL
    Server 2000 on the backend and displays the results of this stored procs on a
    grid. I use integrated windows authentication on IIS, asp.net and SQL Server.
    Here is what I want to do:

    - When a user starts to use the application I want to get the credentials of
    the user. (This can be done by web.config:: <identity impersonate="true">)
    - After I get the user info, I would like to run the stored procedures with
    a different specific NT user's credentials, one that I will give all SQL
    Server accesses. So, I will not give any application user SQL Server direct
    query access but only this specific user account. (This can be done by
    impersonating this specific user in the web.config)

    I want both of this, but I could not find a way to accomplish both. One
    method I thought would be having one asp.net application and another web
    service application both running with different credentials: First, with the
    logged in user and second with my sql server account)

    Any other ideas? Help wanted!

    Thanks in advance


    --
    Onur Gorur, MCSD
    Microsoft Turkey
    Mid-Market Programs Manager
    Onur Gorur Guest

  2. Similar Questions and Discussions

    1. Authentication on Windows NT Server w/IIS 5 or 6
      I changed the authentication files on my production server to add in some new session variables. I did this using Dreamweaver 8, using my personal...
    2. windows authentication and mssql server
      Hi, I've got this asp project, Authentication mode is set to Windows and the identity impersonate is enabled. Is there any way to find out what...
    3. connecting to sql server with windows authentication
      I'm confounded how difficult it is to setup a connection from an ASP.NET application to SQL Server on a different machine in the same windows domain...
    4. ASP.NET + SQL Server Windows authentication
      Hey All, Trying to understand why I can not get SQL server to trust my IIS server. I have two machines set up, 1 App and 1 DB, and I'm trying to...
    5. Hybrid CD - OS9, OSX, Windows
      Iım trying to create a hybrid CD. Normally Iıd just have a windows and mac projector, but I would like it to have both Mac platforms on the Mac...
  3. #2

    Default Re: Hybrid sql server and asp.net windows authentication

    Couldn't you just set up your process model run as the trusted SQL account
    and then disable impersonation in ASP.NET? In that case, the SQL calls will
    be made with the process account, but users will still log in to the site as
    normal. If you needed to impersonate the current user for some reason
    (local file security or something), then you could manually impersonate by
    casting Content.User.Identity to a WindowsIdentity and then creating the
    impersonation context from there.

    Another option would be to put the db access code in a COM+ component and
    run it under a different identity.

    Joe K.

    "Onur Gorur" <onur@gorur.com> wrote in message
    news:9D160A7D-6C0A-4FC0-B95D-95B88D62850F@microsoft.com...
    >I have an asp.net web application that executes stored procedures on SQL
    > Server 2000 on the backend and displays the results of this stored procs
    > on a
    > grid. I use integrated windows authentication on IIS, asp.net and SQL
    > Server.
    > Here is what I want to do:
    >
    > - When a user starts to use the application I want to get the credentials
    > of
    > the user. (This can be done by web.config:: <identity impersonate="true">)
    > - After I get the user info, I would like to run the stored procedures
    > with
    > a different specific NT user's credentials, one that I will give all SQL
    > Server accesses. So, I will not give any application user SQL Server
    > direct
    > query access but only this specific user account. (This can be done by
    > impersonating this specific user in the web.config)
    >
    > I want both of this, but I could not find a way to accomplish both. One
    > method I thought would be having one asp.net application and another web
    > service application both running with different credentials: First, with
    > the
    > logged in user and second with my sql server account)
    >
    > Any other ideas? Help wanted!
    >
    > Thanks in advance
    >
    >
    > --
    > Onur Gorur, MCSD
    > Microsoft Turkey
    > Mid-Market Programs Manager

    Joe Kaplan \(MVP - ADSI\) Guest

  4. #3

    Default Re: Hybrid sql server and asp.net windows authentication

    The only reason that I impersonate the current user is to get his NT login
    name. After I get the login name, I do not need the impersonation to this
    current account anymore. when i run the process with the trusted sql account
    (with integrated security=sspi), then as far as I know, correct me pls if I
    am wrong, when I get the identity of the user, i will get sql account's
    loginname and not the current user's or not?

    and also I think I should change the process's account from machine.config?
    or can it be changed from web.config? will it also affect other running web
    applications?

    I will be glad if you can give some code examples and elaborate on what you
    mean by "you could manually impersonate by casting Content.User.Identity to a
    WindowsIdentity and then creating the impersonation context from there."

    Thanks,
    Onur



    "Joe Kaplan (MVP - ADSI)" wrote:
    > Couldn't you just set up your process model run as the trusted SQL account
    > and then disable impersonation in ASP.NET? In that case, the SQL calls will
    > be made with the process account, but users will still log in to the site as
    > normal. If you needed to impersonate the current user for some reason
    > (local file security or something), then you could manually impersonate by
    > casting Content.User.Identity to a WindowsIdentity and then creating the
    > impersonation context from there.
    >
    > Another option would be to put the db access code in a COM+ component and
    > run it under a different identity.
    >
    > Joe K.
    >
    > "Onur Gorur" <onur@gorur.com> wrote in message
    > news:9D160A7D-6C0A-4FC0-B95D-95B88D62850F@microsoft.com...
    > >I have an asp.net web application that executes stored procedures on SQL
    > > Server 2000 on the backend and displays the results of this stored procs
    > > on a
    > > grid. I use integrated windows authentication on IIS, asp.net and SQL
    > > Server.
    > > Here is what I want to do:
    > >
    > > - When a user starts to use the application I want to get the credentials
    > > of
    > > the user. (This can be done by web.config:: <identity impersonate="true">)
    > > - After I get the user info, I would like to run the stored procedures
    > > with
    > > a different specific NT user's credentials, one that I will give all SQL
    > > Server accesses. So, I will not give any application user SQL Server
    > > direct
    > > query access but only this specific user account. (This can be done by
    > > impersonating this specific user in the web.config)
    > >
    > > I want both of this, but I could not find a way to accomplish both. One
    > > method I thought would be having one asp.net application and another web
    > > service application both running with different credentials: First, with
    > > the
    > > logged in user and second with my sql server account)
    > >
    > > Any other ideas? Help wanted!
    > >
    > > Thanks in advance
    > >
    > >
    > > --
    > > Onur Gorur, MCSD
    > > Microsoft Turkey
    > > Mid-Market Programs Manager
    >
    >
    >
    Onur Gorur Guest

  5. #4

    Default Re: Hybrid sql server and asp.net windows authentication

    Ok, a couple of things here:

    Context.User (or Page.User or Thread.CurrentPrincipal) will represent the
    user who authenticated. If you are using Windows authentication, this will
    be a WindowsPrincipal. If you want to get the name of the authenticated
    user, just do Context.User.Identity.Name. You don't need impersonation to
    do this. With Windows authentication, impersonation will just make whoever
    is in Context.User.Identity be the same as
    System.Security.Principal.WindowsIdentity.GetCurre nt(), which is the
    identity of the token that is executing code on the current thread. Without
    impersonation, that will be the process account.

    In IIS5, changing the process account is done by changing the
    machine.config. Note that this change will affect all other applications
    that are sharing that same worker process. In II6, you change the AppPool
    identity. You have more options of having different applications in
    different pools with IIS and the config is via the MMC and integrated with
    IIS.

    To impersonate any WindowsIdentity, just call the Impersonate method. When
    you are done, just call the Undo method on the WindowsImpersonationContext
    that is returned from Impersonate.

    HTH,

    Joe K.

    "Onur Gorur" <onur@gorur.com> wrote in message
    news:A37A5FD6-C049-486E-A92D-825F9B9E7B89@microsoft.com...
    > The only reason that I impersonate the current user is to get his NT login
    > name. After I get the login name, I do not need the impersonation to this
    > current account anymore. when i run the process with the trusted sql
    > account
    > (with integrated security=sspi), then as far as I know, correct me pls if
    > I
    > am wrong, when I get the identity of the user, i will get sql account's
    > loginname and not the current user's or not?
    >
    > and also I think I should change the process's account from
    > machine.config?
    > or can it be changed from web.config? will it also affect other running
    > web
    > applications?
    >
    > I will be glad if you can give some code examples and elaborate on what
    > you
    > mean by "you could manually impersonate by casting Content.User.Identity
    > to a
    > WindowsIdentity and then creating the impersonation context from there."
    >
    > Thanks,
    > Onur
    >
    >
    >
    > "Joe Kaplan (MVP - ADSI)" wrote:
    >
    >> Couldn't you just set up your process model run as the trusted SQL
    >> account
    >> and then disable impersonation in ASP.NET? In that case, the SQL calls
    >> will
    >> be made with the process account, but users will still log in to the site
    >> as
    >> normal. If you needed to impersonate the current user for some reason
    >> (local file security or something), then you could manually impersonate
    >> by
    >> casting Content.User.Identity to a WindowsIdentity and then creating the
    >> impersonation context from there.
    >>
    >> Another option would be to put the db access code in a COM+ component and
    >> run it under a different identity.
    >>
    >> Joe K.
    >>
    >> "Onur Gorur" <onur@gorur.com> wrote in message
    >> news:9D160A7D-6C0A-4FC0-B95D-95B88D62850F@microsoft.com...
    >> >I have an asp.net web application that executes stored procedures on SQL
    >> > Server 2000 on the backend and displays the results of this stored
    >> > procs
    >> > on a
    >> > grid. I use integrated windows authentication on IIS, asp.net and SQL
    >> > Server.
    >> > Here is what I want to do:
    >> >
    >> > - When a user starts to use the application I want to get the
    >> > credentials
    >> > of
    >> > the user. (This can be done by web.config:: <identity
    >> > impersonate="true">)
    >> > - After I get the user info, I would like to run the stored procedures
    >> > with
    >> > a different specific NT user's credentials, one that I will give all
    >> > SQL
    >> > Server accesses. So, I will not give any application user SQL Server
    >> > direct
    >> > query access but only this specific user account. (This can be done by
    >> > impersonating this specific user in the web.config)
    >> >
    >> > I want both of this, but I could not find a way to accomplish both. One
    >> > method I thought would be having one asp.net application and another
    >> > web
    >> > service application both running with different credentials: First,
    >> > with
    >> > the
    >> > logged in user and second with my sql server account)
    >> >
    >> > Any other ideas? Help wanted!
    >> >
    >> > Thanks in advance
    >> >
    >> >
    >> > --
    >> > Onur Gorur, MCSD
    >> > Microsoft Turkey
    >> > Mid-Market Programs Manager
    >>
    >>
    >>

    Joe Kaplan \(MVP - ADSI\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139