Windows identity during asynchronous calls

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

  1. #1

    Default Windows identity during asynchronous calls

    I'm trying to access a SQL server from a thread started from an asp.net
    application and get a "Cannot log into database as user null..." error. How
    can I make the thread inherit the same identity as the calling process?
    When I spin off the thread I have seen that it typically runs as NT
    ANONYMOUS\SYSTEM (via
    System.Security.Principal.WindowsIdentity.GetCurre nt().Name). I have had
    intermittent success
    passing the token of the calling process and impersonating it in the called
    process but once in a while hit an exception when trying to impersonate.

    Web Config of calling process:
    <authentication mode="Forms" >
    <forms name="adAuthCookie" loginUrl="_mem_bin/formslogin.aspx"
    protection="All" path="/" timeout="60" ></forms>
    </authentication>
    <identity impersonate="true" />

    Web Site Directory Security of calling process is set to Anonymous Access.
    Account used for anonymous access is a user w/ permissions to our SQL Server
    db. Windows Integrated Authentication is also checked.

    calling asynchronous process:
    ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf lfd.SubmitRequest),
    System.Security.Principal.WindowsIdentity.GetCurre nt().Token)

    Impersonation Logic:
    Sub SubmitRequest(ByVal Token As Object)
    System.Security.Principal.WindowsIdentity.Imperson ate(CType(Token,
    System.IntPtr))

    Thanks,

    Dave




    Dave Mullen Guest

  2. Similar Questions and Discussions

    1. Asynchronous calls from Java?
      Hi, I want to listen for events on the java side and have a flex method called when something happens. How would I do this? This should be...
    2. Web service calls asynchronous vs synchronous
      The best solution is to design you architecture using the observer pattern(GOF) K,Browne Developer
    3. Asynchronous web service calls
      Hi I am trying to do some tests using asynchronous web service calls and have hit a problem. I have reduced the problem to the minimum so...
    4. Asynchronous web service calls, will you still have timeouts
      If I am calling web services asynchronously, will I still have to be concerned with the request timing out? If IIS starts a process (calling a web...
    5. Impersonation not working with Asynchronous calls
      I make a connection from my web service function to a sql database (on another machine) using Windows Only authentication and the following in my...
  3. #2

    Default Windows identity during asynchronous calls

    I'm trying to access a SQL server from a thread started from an asp.net
    application and get a "Cannot log into database as user null..." error. How
    can I make the thread inherit the same identity as the calling process?
    When I spin off the thread I have seen that it typically runs as NT
    ANONYMOUS\SYSTEM (via
    System.Security.Principal.WindowsIdentity.GetCurre nt().Name). I have had
    intermittent success
    passing the token of the calling process and impersonating it in the called
    process but once in a while hit an exception when trying to impersonate.

    Web Config of calling process:
    <authentication mode="Forms" >
    <forms name="adAuthCookie" loginUrl="_mem_bin/formslogin.aspx"
    protection="All" path="/" timeout="60" ></forms>
    </authentication>
    <identity impersonate="true" />

    Web Site Directory Security of calling process is set to Anonymous Access.
    Account used for anonymous access is a user w/ permissions to our SQL Server
    db. Windows Integrated Authentication is also checked.

    calling asynchronous process:
    ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf lfd.SubmitRequest),
    System.Security.Principal.WindowsIdentity.GetCurre nt().Token)

    Impersonation Logic:
    Sub SubmitRequest(ByVal Token As Object)
    System.Security.Principal.WindowsIdentity.Imperson ate(CType(Token,
    System.IntPtr))

    Thanks,

    Dave






    Dave Mullen Guest

  4. #3

    Default RE: Windows identity during asynchronous calls

    Hi Dave,

    Thanks for posting in the group.

    Because forms users usually are not Microsoft Windows users, they do not
    have any roles associated with them by default. Thus, you must attach the
    roles of the authenticating user to that user's identity so that you can
    implement the role-based security inside your code.

    Generally speaking, we can achieve it in Application_AuthenticateRequest
    event handler in global.asax. For detailed sample codes, please refer to KB
    article:
    HOW TO: Implement Role-Based Security with Forms-Based Authentication in
    Your ASP.NET Application by Using Visual C# .NET
    [url]http://support.microsoft.com/?id=311495[/url]

    Another article is also useful in this area.
    HOW TO: Authenticate Against the Active Directory by Using Forms
    Authentication and Visual C# .NET
    [url]http://support.microsoft.com/?id=316748[/url]

    Hope this help.

    Regards,

    HuangTM
    Microsoft Online Partner Support
    MCSE/MCSD

    Get Secure! ¨C [url]www.microsoft.com/security[/url]
    This posting is provided ¡°as is¡± with no warranties and confers no rights.


    Tian Min Huang 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