On my Windows 7 x64 PC with Visual Studio 2010 Premium and SQL Server 2008 R2, for my C# ASP.NET class, I am developing an app that uses the Login and CreateUserWizard controls. After creating a few users in the ASP.NET Configuration tool, when I run the
app in Debug Mode in VS 2010, I can log in and create a new user with no problem.
When I run the app via IIS (localhost/ Ch19Authenticate), I can access the non-secured screens with no problem. When i try to log in, I ger an error:
Server Error in '/Ch19Authenticate' Application.
Failed to generate a user instance of SQL Server due to a failure in impersonating the client. The connection will be closed.
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.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in impersonating the client. The connection will be closed.
Source Error:
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
I have seen similar posts in the IIS and SQL Server forums, but they refer to user profile problems, the IIS version is older, it's a different OS. SQL Server is older or a different version, or it's an older version of ASP.NET..
What is different/missing in my IIS settings such that I can log in and create users while running in debug mode, but not when running under IIS?
You need to grant permission to the SQL database for the app pool account, or use a connection string that uses an existing account that has access. It's really not an IIS issue and there are ways to program this in ASP.NET, but take a look at:
WestonPK
10 Posts
Failed to generate a user instance of SQL Server due to a failure in impersonating the client. Th...
May 13, 2012 03:03 AM|LINK
On my Windows 7 x64 PC with Visual Studio 2010 Premium and SQL Server 2008 R2, for my C# ASP.NET class, I am developing an app that uses the Login and CreateUserWizard controls. After creating a few users in the ASP.NET Configuration tool, when I run the app in Debug Mode in VS 2010, I can log in and create a new user with no problem.
When I run the app via IIS (localhost/ Ch19Authenticate), I can access the non-secured screens with no problem. When i try to log in, I ger an error:
Server Error in '/Ch19Authenticate' Application.
Failed to generate a user instance of SQL Server due to a failure in impersonating the client. The connection will be closed.
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.Data.SqlClient.SqlException: Failed to generate a user instance of SQL Server due to a failure in impersonating the client. The connection will be closed.
Source Error:
Stack Trace:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
My settings in IIS for the app are
.NET Authorization Rules - Allow All Users
.NET Trust Levels - Full
Connection Strings - LocalSqlServer - Custom - data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
Anonymouus Authentication - Enabled
Authorization Rules - Allow All Users
Application Pool - ASP.NET v4.0
I have seen similar posts in the IIS and SQL Server forums, but they refer to user profile problems, the IIS version is older, it's a different OS. SQL Server is older or a different version, or it's an older version of ASP.NET..
What is different/missing in my IIS settings such that I can log in and create users while running in debug mode, but not when running under IIS?
Thanks.
jeff@zina.co...
3379 Posts
MVP
Moderator
Re: Failed to generate a user instance of SQL Server due to a failure in impersonating the client...
May 14, 2012 12:48 PM|LINK
The user account. IIS runs under the app pool identity, you're logged in as a user -- often an administrator or equivalent.
Jerff
WestonPK
10 Posts
Re: Failed to generate a user instance of SQL Server due to a failure in impersonating the client...
May 14, 2012 06:21 PM|LINK
Hi, Jeff.
Thanks for responding.
So what do I tweak -- and how do I tweak it -- so I can run the app under IIS?
jeff@zina.co...
3379 Posts
MVP
Moderator
Re: Failed to generate a user instance of SQL Server due to a failure in impersonating the client...
May 15, 2012 02:51 PM|LINK
You need to grant permission to the SQL database for the app pool account, or use a connection string that uses an existing account that has access. It's really not an IIS issue and there are ways to program this in ASP.NET, but take a look at:
http://support.microsoft.com/kb/2002980
http://stackoverflow.com/questions/4770596/failed-to-generate-a-user-instance-of-sql-server-due-to-failure-in-retrieving-th
http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/3d8df54b-f329-47ca-bd90-aee1acf74498
Jeff
WestonPK
10 Posts
Re: Failed to generate a user instance of SQL Server due to a failure in impersonating the client...
May 16, 2012 05:53 PM|LINK
Hi, Jeff.
the option
http://support.microsoft.com/kb/2002980
worked. I can now log on and create a new user.
Next up is changing the password and retrieving a password through email, but those are topics for other threads . . .
Thanks.
tom1978
2 Posts
Re: Failed to generate a user instance of SQL Server due to a failure in impersonating the client...
Mar 05, 2013 11:09 AM|LINK
http://answerforu.com/2011/06/11/instance-failure-sql-server-sqlconnection-oledbconnection-asp-net-c-net-vb-net-etc/