Cannot open database "aspnetdb" requested by the login. The login failed.

Apr 29, 2009 at 7:52 PM

Below is the error I am getting.  I know I need to make that user a DBO on the database but I cant find the user anyhwere in Active Directory I have done millions of searches and I am about to rip my hair out.  Why is it using the account below.  Can I make it use a different account.  LWGCRM$ is not in AD anywhere. 

Cannot open database "aspnetdb" requested by the login. The login failed.
Login failed for user 'LWGINC\LWGCRM$'.

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: Cannot open database "aspnetdb" requested by the login. The login failed.
Login failed for user 'LWGINC\LWGCRM$'.

Source Error:

Line 44: 		_contactId = new Guid(plainText);
Line 45: 		CreateUserWizard1.CreatedUser += new EventHandler(CreateUserWizard1_CreatedUser);
Line 46: ProfileInfoCollection allProfiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.Authenticated);Line 47: 		foreach (ProfileInfo profileInfo in allProfiles)
Line 48: 		{

Source File: c:\Program Files\Microsoft Dynamics CRM Customer Portal\Controls\CreateUserAccount.ascx.cs    Line: 46

Stack Trace:

[SqlException (0x80131904): Cannot open database "aspnetdb" requested by the login. The login failed.
Login failed for user 'LWGINC\LWGCRM$'.]
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +437
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
   System.Data.SqlClient.SqlConnection.Open() +111
   System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +84
   System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +197
   System.Web.Profile.SqlProfileProvider.GetProfilesForQuery(SqlParameter[] args, ProfileAuthenticationOption authenticationOption, Int32 pageIndex, Int32 pageSize, Int32& totalRecords) +930
   System.Web.Profile.SqlProfileProvider.GetAllProfiles(ProfileAuthenticationOption authenticationOption, Int32 pageIndex, Int32 pageSize, Int32& totalRecords) +40
   System.Web.Profile.ProfileManager.GetAllProfiles(ProfileAuthenticationOption authenticationOption) +170
   Controls_CreateUserAccount.OnLoad(EventArgs e) in c:\Program Files\Microsoft Dynamics CRM Customer Portal\Controls\CreateUserAccount.ascx.cs:46
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Control.LoadRecursive() +131
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

Apr 29, 2009 at 7:54 PM
I should mention SQL will not even allow me to create a user that has a name with a $ sign in it. 
Apr 29, 2009 at 8:39 PM
The account 'LWGINC\LWGCRM$ is actually the name of the CRM Server.  Do I need to check a service from Local Account to Network or something like that?
Apr 29, 2009 at 9:37 PM
Finally 6 hours later I figured it out. SQL wouldnt let me create login for a computer account through the WEB UI.  However, through the command line I ran a script against the aspnet database

Create login [domain\computername$] FROM WINDOWS

That command created the login account which I then added to the aspnet database and gave it DBO privs which fixed my problem.  I think this should have been in the video.