Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Open Core Testi...Open Core Testi...DNN 5.5.0 (336) Host Settings Update ErrorDNN 5.5.0 (336) Host Settings Update Error
Previous
 
Next
New Post
7/9/2010 8:19 AM
 
Upon successfully installing source package of DNN 5.5.0 (336) Beta, noted in Event Viewer the following error which occurred during the install:

StackTrace:
Message: System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_DNN_HostSettings'. Cannot insert duplicate key in object 'dbo.DNN_HostSettings'. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(String connectionString, String spName, Object[] parameterValues) at DotNetNuke.Data.SqlDataProvider.AddHostSetting(String SettingName, String SettingValue, Boolean SettingIsSecure, Int32 CreatedByUserID) at DotNetNuke.Entities.Controllers.HostController.Update(ConfigurationSetting config, Boolean clearCache) in C:\DNN Websites\DNN550Beta\Library\Entities\Controllers\HostController.vb:line 47

I then accessed Host Settings tab and noted that each attempt to update host settings resulted in multiple iinstances of this same error being logged. Traced the error down to the following fragment found in the Update method in the new HostController class:

If GetSettings.ContainsKey(config.Key) Then
        DataProvider.Instance().UpdateHostSetting(config.Key, config.Value, config.IsSecure, UserController.GetCurrentUserInfo.UserID)
        objEventLog.AddLog(config.Key, config.Value, PortalController.GetCurrentPortalSettings, UserController.GetCurrentUserInfo.UserID,
                                                       Log.EventLog.EventLogController.EventLogType.HOST_SETTING_UPDATED)
Else
       DataProvider.Instance().AddHostSetting(config.Key, config.Value, config.IsSecure, UserController.GetCurrentUserInfo.UserID)
       objEventLog.AddLog(config.Key, config.Value, PortalController.GetCurrentPortalSettings, UserController.GetCurrentUserInfo.UserID,
                                                      Log.EventLog.EventLogController.EventLogType.HOST_SETTING_CREATED)
End If

Since the host settings dictionary returned by GetSettings does not contain entries for any SettingName containing "password", the above condition will always be false for keys "SMTPPassword", "ProcessorPassword" and "ProxyPassword" resulting in AddHostSetting always being called for these three keys and the resulting PK violation being generated due to the duplication of a key alread in the Host Settings table. Due to the error, any changes to these keys will not be saved to the database.

The cached host settings dictionary is initially generated in the following callback method of HostController:

Private Function GetSettingsDictionaryCallBack(ByVal cacheItemArgs As CacheItemArgs) As Object
     Dim dicSettings As New Dictionary(Of String, ConfigurationSetting)
     Dim dr As IDataReader
     Try
          dr = DataProvider.Instance().GetHostSettings
          While dr.Read()
               Dim key As String = dr.GetString(0)
               If Not key.ToLower().Contains("password") Then
                    Dim config As New ConfigurationSetting()
                   config.Key = key
                   config.IsSecure = Convert.ToBoolean(dr(2))
                   If dr.IsDBNull(1) Then
                          config.Value = String.Empty
                   Else
                          config.Value = dr.GetString(1)
                   End If
              dicSettings.Add(key, config)
          End If
        End While
   Catch ex As Exception
           LogException(ex)
    Finally
           CBO.CloseDataReader(dr, True)
    End Try
    Return dicSettings
End Function

As you can see, any setting key containing "password" will be excluded from the settings dictionary.

I did not see this issue in Gemini and will log it.
EDIT: Logged in Gemini as http://support.dotnetnuke.com/issue/V...


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
7/9/2010 10:13 AM
 
thanks Bill - FYI the "password" check is an attempt to ensure that sensitive values are not leaked via tokenreplace i.e. only host users can access all host settings include sensitive ones. The updated code does not take this into account and needs to be resolved.

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
7/18/2010 11:04 PM
 
I'm concerned that the root cause of this issue has not been addressed as DNN-13046 has been marked closed as duplicate of DNN 12548. However, although the issue description in DNN-12548 is related, the release note for the  DNN-12548 fix (also closed) has nothing to do with the stripping out of any host settings dictionary entry having "password" in its key (in method HostController.GetSettingsDictionaryCallback). Nor do I find any changes to this or related methods in Fortress 5 Development or Maintenance branches.

I have found tonight that this issue is causing SendMail (lines 402 and 456 of Services\Mail\Mail.vb) to fail in any case where basic authentication has been specified in Host Settings as Host.SMTPPassword always returns an empty string.

I have added a comment to the already closed issue DN-12548 to this effect.

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Open Core Testi...Open Core Testi...DNN 5.5.0 (336) Host Settings Update ErrorDNN 5.5.0 (336) Host Settings Update Error


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out