Monday, April 28, 2008

MSCRM4 Diagnostic: Cannot open database "MSCRM_CONFIG" requested by the login. The login failed.

This error can be caused by following scenarios:

• Redeployment
• Moving database to another server
• Upgrades
• Changing from multiple-server environment to single-server environment
• Install MSCRM 4 on existing MSCRM 4 database
• Install MSCRM 4 on existing MSCRM 4 multiple-server environment database
• or whatever activity that causing this issue

Details of the error:

Exception Details: System.Data.SqlClient.SqlException: Cannot open database "MSCRM_CONFIG" requested by the login. The login failed.
Login failed for user 'DOMAIN\SERVER$'.

Stack Trace:

[SqlException (0x80131904): Cannot open database "MSCRM_CONFIG" requested by the login. The login failed.
Login failed for user 'DOMAIN\SERVER$'.]
   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
   Microsoft.Crm.CrmDbConnection.Open() +213
   Microsoft.Crm.SharedDatabase.DatabaseMetadata.LoadMetadataXmlFromDatabase(CrmDBConnectionType connectionType, String connectionString, Int32& maxBlobSize) +89
   Microsoft.Crm.SharedDatabase.DatabaseMetadata.LoadCacheFromDatabase(CrmDBConnectionType connectionType, String connectionString) +22
   Microsoft.Crm.ConfigurationDatabase.ConfigurationMetadata.get_Cache() +76
   Microsoft.Crm.ConfigurationDatabase.ConfigurationDatabaseService.InitializeMetadataCache() +5
   Microsoft.Crm.SharedDatabase.DatabaseService.Initialize(String tableName) +20
   Microsoft.Crm.SharedDatabase.DatabaseService.Retrieve(String tableName, String[] columns, PropertyBag[] conditions) +297
   Microsoft.Crm.ServerLocatorService.GetSiteSettingIdFromDatabase() +107
   Microsoft.Crm.ServerLocatorService.GetSiteSettingId() +156
   Microsoft.Crm.ServerLocatorService.GetSiteSetting(String settingName) +32
   Microsoft.Crm.CrmTrace.get_RefreshTrace() +429

[TypeInitializationException: The type initializer for 'Microsoft.Crm.ApplicationSqmHelper' threw an exception.]
   Microsoft.Crm.MainApplication.Application_OnStart() +476


1. Add the computer as a member to the SQLAccessGroup in the Active Directory (can be achieved using dsa.msc tool):

2. Open Management Studio on the database server, expand Server>Security>Logins and right click on the NT AUTHORITY\NETWORK SERVICE and select Properties.

3. At the left, select User Mapping, and configure appropriate mapping for MSCRM_CONFIG and Organization_MSCRM, assign db_owner for both.

4. Restart MSCRM 4 Server.

Friday, April 25, 2008

Web Service: Enabling Web Service Test Form for Remote Client

To enable the Web Service Test Form for remote machine, edit following in the Web.Config:

            <add name="HttpPost" />
            <add name="HttpGet" />

This should be enabled for debugging purposes only. For production, this should be disabled (by removing or commenting tags above).