Hello Dave,
I think the problem here is that the your deamon application doesn't has a
credential store, or can not get crential or authenticated token from IIS.
In such case, I'm afraid you have to pre-store the certain user(you want to
run as)'s username/password credentials in your application storage. This
could be database or configuration file. One example is SQL Server
reporting service which will store the username/password credentials in the
database and used for accessing external resource.
In .net framework 2.0, we have some built-in means to encrpt data such as
the DPAPI wrapper:
#Using the DPAPI through ProtectedData Class in .Net Framework 2.0
http://www.c-sharpcorner.com/UploadF...eddataclass010
52006142332PM/dpapiprotecteddataclass.aspx?ArticleID=d6a6c525-1898-45de-b16e
-58c763472348
Also, .net framework 2.0 support RSA or DPAPI provider to encrypt
configuration file sections:
#Encrypting Configuration Information in ASP.NET 2.0 Applications
http://aspnet.4guysfromrolla.com/articles/021506-1.aspx
In addition, as for your deamon application, after it runas/impersonate a
certain user, will it access any remote resource or only the resoruce on
the local machine? If it only accessing resource on local machine, and the
deamon application can run under LOCAL SYSTEM account(as service), you can
consider the kerberos S4U logon approach as Joe has mentioend. Here is a
article introducing this:
#Exploring S4U Kerberos Extensions in Windows Server 2003
http://msdn.microsoft.com/msdnmag/is...ecurityBriefs/
For example, you can use the following code to constructor a
windowsIdentity and impersonate it(through user principal name):
============================
WindowsIdentity wi = new WindowsIdentity("username@domainname");
WindowsImpersonationContext ctx = wi.Impersonate();
StreamWriter sw = new
StreamWriter(@"d:\\temp\\testfolder\\jetan_file111 .txt");
sw.WriteLine("this file is created by jetan.");
sw.Close();
Response.Write("<br/>IMpersonate: " +
System.Security.Principal.WindowsIdentity.GetCurre nt().Name);
ctx.Undo();
=========================
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.