Wednesday, August 08, 2007

Different box when SQL server and web application located

http://weblogs.asp.net/achang/archive/2004/04/15/113866.aspx

basically;

1 Use a trusted connection with integrated authentication.
2 Use the Aspnet_setreg.exe utility to encrypt the connection string and store it in the registry. You can refer to these two articles for detailed instructions on how to do this: http://support.microsoft.com/default.aspx?scid=kb;EN-US;329290 and http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT11.asp
3 Using DPAPI (Data Protection application programming interface) to secure the connection string. You can refer to these articles: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT08.asp and http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsecure/html/windataprotection-dpapi.asp and http://www.codeproject.com/system/protected_data.asp



and,

1 When creating the domain account, make sure it has the proper level of access to run ASP.NET applications. You can refer to this page for a list of directories and the permissions that this domain account must have to them. For security purposes, don't give this domain account any more permission than you have to.
2 Assign the domain account the necessary permission to the database (you can still follow the instructions at http://www.asp.net/faq/AspNetAndIIS6.aspx#4. Just make sure you choose the domain account that you just created).
3 In order to turn on impersonation, there are two options:
a. In the web.config file of your application, add the following line: (put it somewhere between the tags) However this really defeats the purpose of using the trusted connection to avoid having to include the credential and the password in the connection string. If you use this method, you will still need to encrypt the credential and the password in order to keep this information safe.
b. (This is the better method in my opinion) In the web.config file, add the following: (this time without the user name and password). Then, from IIS Manager, right click on the virtual directory assigned to your application and select “Properties”. Click on the “Directory Security” tab, then under “Anonymous access and authentication control” click “Edit”. If you are going to allow anonymous access to the application (not requiring users to login with windows authentication each time they access this web application), make sure “Anonymous access” checkbox IS checked. Then uncheck “Allow IIS to control password”. In the “User Name” field, type in (or you can browse to) the domain account (domain\user) and type in the password for the domain account in the “Password” field (By default IIS uses IUSR_machinename for the anonymous account, you can refer to this page if you would like to find its default password in case you want to change it back later for some reason) . Then under “Authenticated Access”, make sure NONE of the boxes are checked. Press “OK” and “OK” to save the settings and exit IIS.
4 Then in web.config you can use either one of these connection strings:
a. "data source=yourservername;initial catalog=databasename;Integrated Security=SSPI"
b. "server=yourservername; database=databasename;Trusted_Connection=true"

Monday, August 06, 2007

Thread aborted?

using response.redirect(url) in asp.net,got "thread aborted" error.

try: response.redirect(url,false) instead.

Creating Windows Services(VS2005)

1. By default, a Windows Service project is missing an installer. From a service design view, right click select “Add Installer”.
2. By default, the ServiceProcessInstaller component is configured to use a “User” account, change it to either “LocalService” or “LocalSystem” depending on security concerns.
3. By default, a setup project does not invoke the custom installers contained within assemblies added to it. From the setup project’s Custom Actions Editor, right click select “Add Custom Action…” and select the primary output from the service application.
4. When having difficulties, use the installutil tool to obtain detailed installation progress logging output.