在Windows Service中执行的应用程序;将数据发送到Web服务,然后将数据发送到SQL数据库

问题描述:

很抱歉,您认为标题更好.但基本上那是我想要实现的目标.

Sorry for title and couldn't think much better. But basically that was I'm trying to achieve.

场景:

我的应用程序将在Windows服务(在系统帐户下运行)应用程序下运行.计划每天运行并通过Web服务引用(Web方法)发送更新.默认情况下,Web服务器使用匿名帐户,而我的MSSQL需要Windows身份验证 允许插入记录.这是我的问题,我不允许匿名添加/插入记录.

My application will run under windows service (run under system account) application. Scheduled to run daily and sends updates via Web service reference (Web method). The web server uses anonymous account by default which my MSSQL requires windows authentication to allow insertion of records. This comes my problem which I can't allow anonymous to add/insert records.

我应该采取什么方法?我尝试在Windows服务中捕获交互式用户令牌并将其发送到Web服务,但是我不知道如何在IIS服务器中访问该令牌时进行身份验证?

What approach should I take? I tried capturing the interactive user token in windows service and send to web service but I don't know how to authenticate when it reach in IIS server?

需要帮助或建议. (注意:我使用的是NET 2.0框架,而不是3.5)

Need help or suggestion. (Note: I am using NET 2.0 framework not 3.5)

您需要在Web服务器中模拟一个有效的Windows帐户以访问MSSQL. Web服务器仍将使用匿名(用于传入请求),但在内部必须访问资源时,将使用此新的有效Windows帐户进行操作.

You need to impersonate in the Web Server a valid Windows account to access the MSSQL. The Web Server will still use Anonymous (for incoming requests) but internally when it has to access resources, will do with this new valid Windows account.

换句话说:

  • windows服务在系统帐户下运行
  • windows服务调用Web服务
  • 该Web服务不关心调用方的身份,它使用匿名身份验证.
  • 该Web服务在内部模拟了Windows帐户(例如mydomain \ myprogram)以访问资源(例如MSSQL).
  • The windows service runs under system account
  • The windows service calls the web service
  • The web service doesn't care about the identity of callers, it uses anonymous auth.
  • The web service internally impersonates a Windows account (e.g mydomain\myprogram) to access resources (e.g. MSSQL).

为此,您可以看一下这篇文章: http://support.microsoft.com/kb/306158 .

To do this, you can take a look to this article: http://support.microsoft.com/kb/306158.

此致

毛罗