views:

241

answers:

3

I'll start with appologies; I wasn't sure if this was best posted here of Server Fault so if its in the wrong place then please move :-)

Basic information

I have written the first module of a new application at work. This is written using Visual Studio 2010, targetting .net 3.5 (at the moment) and asp.net mvc 2. This has been working fine during development running on the built in Development server from VS but however does not work once deployed to IIS 7/7.5.

To deploy the application, I have built it in release mode and created a deployment package by right clicking on the project in the solution explorer (this will be done with an automated build in tfs once upgrade from the beta). This has then been imported into IIS on the server.

The application is using windows/domain authentication.

Issue #1

I can fire up internet explorer and browse to the application from a client computer as well as on a remote desktop connection. I can execute the code which reads/stores data in Session fine from the IE instance on the remote desktop but if I browse to it from the client pc it seems to lose the session state. I click on the form submit and the page refreshes and doesn't execute the required code. I've tried setting with; InProc, SQLServer and StateServer. but with no luck :-(

Issue #2

As part of the application it views PDF and Tiff documents on the fly which are on a network share on the office network and creates thumbnails if the document hasn't been viewed before. This works if running on the machine the application is deployed to; however when browsing from a client pc I get an error saying:

Access to the path '\\fileserver\folder\file.tif' is denied Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path '\\fileserver\folder\file.TIF' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

As this is on a different server the user is not accessible. To get round this I have tried:

1 - setting the application pool to run as domain administrator (I know this is a security risk, but I'm just trying to get it to work at the moment!)

2 - to set the log on account for World Wide Web Publishing service to be the domain admin . When trying to restart the service I get ...

Windows could not start the World Wide Web Publishing Service service on the Local Computer.

Error 1079: The account specified for this service is different from the account specified fro the other services running in the same process.

Any pointers/help would be much appriciated as I'm pulling my hair out (of what little I have left).


Update

I've been using this funky little tool I found - DelegConfig v2 beta (Delegation / Kerberos Configuration Tool). This has been really usefull. So I've got the accessing of the file share working (there is a test page which will read the files) so now I've just got the issue of passing through the users credentials through to the SQL Server (wans't my choice to do it this way!!) to execute the queries etc. but I can't get it to log on as the user. It tries to access it as "NT Authority\Network Service" which doesn't have a sql login (as should be the logged on user).

My connection string is:

<add name="User" connectionString="Data Source=.;Integrated Security=True" providerName="System.Data.SqlClient" />

No initial catalog is specified as the system is over multiple dbs (also wasn't my choice!!).

I really appriciate all the help so far! :-)

Any further hints?!

A: 

With this small part of information I could only give some hints:

Issue #1: Maybe you have a misleading URL as action for the form? Or an caught&ignored exception? Do you have an onError-event in your global.asax.vb?

Sub Application_Error()
    Dim ex As Exception = Server.GetLastError
    ' NOW HANDLE THE EXCEPTION --> REPORTING :-)
End Sub

Issue #2: I recently had the same exception - I had to check the access-rights for users for this folder and set the appPool-identity to "NETWORKSERVICE". In your case you even try to access a network-folder - check the accessrights on the server and try to use the IP instead of the name - it could be a name-resolution-problem?!

Sorry for this small portion of information... This looks like problems only solveable with direct debug-options on the running server.

Olaf Watteroth
+1  A: 

Issue #2 - Your options are:

  • Configure delegation (double-hop authentication) - I haven't done this on IIS7 and it's a bit different to 6, but I believe you will need to enable the web server machine account for delegation in AD, and create an SPN for the web server (eg setspn -A http/<Web Server FQDN> <Domain>\<Machine Name>). Troubleshooting Kerberos can be fairly painful.
  • Grant access to the network resources to the (domain) application pool account and make sure anonymous authentication is turned on ( <anonymousAuthentication enabled="true" userName="" defaultLogonDomain="" /> )

Response to Update:

You will need to make sure Kerberos authentication is working for SQL Server. Run the query select auth_scheme from sys.dm_exec_connections where session_id=@@spid; it will return NTLM or KERBEROS. If it's NTLM, you'll need to do some work configuring SQL Server to use Kerberos. Set an SPN in AD for the SQL service account: setspn -A MSSQLSvc/<SQL Server FQDN>:1433 <Domain>\<Sql Service Account>, restart SQL Server and try the query again. You must use TCP/IP as the connection mechanism (this is the default).

If you don't have an initial catalog, you'll need to make sure that all of the user logins have a default database that they have access to. I would personally pick one database to be the initial catalog as you may get different behaviour depending on how the login is configured.

Sam
A: 

Finally last thing on Friday I got it working ...

As I said in the update, the tool for sorting out the delegation of credentials was very handy and helped no end to setting the correct SPN records.

I found I also had to set it up for SQL as I was passing through the credentials into the server. The other thing I found stopping the connections was some of the inbound windows firewall settings where causing problems.

For the connection string; I had to update to:

<add name="ConnectionStringName" connectionString="Data Source=.;Integrated Security=SSPI;Trusted_Connection=True" providerName="System.Data.SqlClient" />

Links I found useful:

Kerberos Authentication and SQL Server

DelegConfig

And even tho it mainly talks about Sharepoint ... this was also useful.

Hope this helps people in the future.

WestDiscGolf