Threading and database connections

  • Thread starter Thread starter jacques.steward
  • Start date Start date
J

jacques.steward

I have an application that kicks off a long process on the database
server with a separate thread and then forwards the user to another
page which monitors the progress of this process by reading a table
that is being updated by the long process. On my development machine
it works fine but when I try to deploy the app to a server the long
process is blocked from database access. Apparently when the new
thread is created it either does not get or loses its credentials. On
my dev machine it is not a problem because it simply reverts back to my
credentials but on the server it reverts back to the default IIS user.
How can I work around this?
 
If you want, you can have the process run under the credentials of a user
that has the required database access. In web.config,
<identity impersonate="true" userName="theUser" password = "thePassword' />

Bear in mind that this does expose some security issues, but try it first
because it is a very "easy fix".
Peter
 
I added the line in the web.config file you suggested. It doesn't
appear that the processing thread ever proceeds. The monitor page is
updating properly. If I add records to the table it is monitoring it
appears on the status page.
 
Thanks so much for your help. Once I followed your advice I was able
to see that the problem was not the tread but the permissions on the
database. Apparently it was using my privileges when updating but it
was defaulting to the application default when control was passed. The
default privileges were not enough on a couple of tables so the tread
was bombing out without any indication as to why.
 
Back
Top