Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
4.9 KiB

  1. // LogODBC.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include <iadmw.h>
  5. #include "logui.h"
  6. #include "LogODBC.h"
  7. #include "CnfrmPsD.h"
  8. #include <iiscnfg.h>
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CLogODBC property page
  16. IMPLEMENT_DYNCREATE(CLogODBC, CPropertyPage)
  17. //--------------------------------------------------------------------------
  18. CLogODBC::CLogODBC()
  19. : CPropertyPage(CLogODBC::IDD),
  20. m_fInitialized( FALSE )
  21. {
  22. //{{AFX_DATA_INIT(CLogODBC)
  23. m_sz_datasource = _T("");
  24. m_sz_password = _T("");
  25. m_sz_table = _T("");
  26. m_sz_username = _T("");
  27. //}}AFX_DATA_INIT
  28. m_szOrigPass.Empty();
  29. m_bPassTyped = FALSE;
  30. }
  31. //--------------------------------------------------------------------------
  32. CLogODBC::~CLogODBC()
  33. {
  34. }
  35. //--------------------------------------------------------------------------
  36. void CLogODBC::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CPropertyPage::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CLogODBC)
  40. DDX_Control(pDX, IDC_ODBC_PASSWORD, m_cedit_password);
  41. DDX_Text(pDX, IDC_ODBC_DATASOURCE, m_sz_datasource);
  42. DDX_Text_SecuredString(pDX, IDC_ODBC_PASSWORD, m_sz_password);
  43. DDX_Text(pDX, IDC_ODBC_TABLE, m_sz_table);
  44. DDX_Text(pDX, IDC_ODBC_USERNAME, m_sz_username);
  45. //}}AFX_DATA_MAP
  46. }
  47. //--------------------------------------------------------------------------
  48. BEGIN_MESSAGE_MAP(CLogODBC, CPropertyPage)
  49. //{{AFX_MSG_MAP(CLogODBC)
  50. ON_EN_CHANGE(IDC_ODBC_DATASOURCE, OnChangeOdbcDatasource)
  51. ON_EN_CHANGE(IDC_ODBC_PASSWORD, OnChangeOdbcPassword)
  52. ON_EN_CHANGE(IDC_ODBC_TABLE, OnChangeOdbcTable)
  53. ON_EN_CHANGE(IDC_ODBC_USERNAME, OnChangeOdbcUsername)
  54. //}}AFX_MSG_MAP
  55. ON_COMMAND(ID_HELP_FINDER, DoHelp)
  56. ON_COMMAND(ID_HELP, DoHelp)
  57. ON_COMMAND(ID_CONTEXT_HELP, DoHelp)
  58. ON_COMMAND(ID_DEFAULT_HELP, DoHelp)
  59. END_MESSAGE_MAP()
  60. //---------------------------------------------------------------------------
  61. void CLogODBC::DoHelp()
  62. {
  63. DebugTraceHelp(HIDD_LOGUI_ODBC);
  64. WinHelp( HIDD_LOGUI_ODBC );
  65. }
  66. //--------------------------------------------------------------------------
  67. BOOL
  68. CLogODBC::OnInitDialog()
  69. {
  70. BOOL bRes = CPropertyPage::OnInitDialog();
  71. CError err;
  72. CString csTempPassword;
  73. m_szPassword.CopyTo(csTempPassword);
  74. CComAuthInfo auth(m_szServer, m_szUserName, csTempPassword);
  75. CMetaKey mk(&auth, m_szMeta, METADATA_PERMISSION_READ);
  76. do
  77. {
  78. err = mk.QueryResult();
  79. BREAK_ON_ERR_FAILURE(err);
  80. err = mk.QueryValue(MD_LOGSQL_DATA_SOURCES, m_sz_datasource);
  81. BREAK_ON_ERR_FAILURE(err);
  82. CString csTempPassword;
  83. m_sz_password.CopyTo(csTempPassword);
  84. err = mk.QueryValue(MD_LOGSQL_PASSWORD, csTempPassword);
  85. m_sz_password = csTempPassword;
  86. BREAK_ON_ERR_FAILURE(err);
  87. err = mk.QueryValue(MD_LOGSQL_TABLE_NAME, m_sz_table);
  88. BREAK_ON_ERR_FAILURE(err);
  89. err = mk.QueryValue(MD_LOGSQL_USER_NAME, m_sz_username);
  90. BREAK_ON_ERR_FAILURE(err);
  91. UpdateData(FALSE);
  92. } while (FALSE);
  93. return bRes;
  94. }
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CLogODBC message handlers
  97. //--------------------------------------------------------------------------
  98. BOOL CLogODBC::OnApply()
  99. {
  100. BOOL f;
  101. UpdateData( TRUE );
  102. // confirm the password
  103. if ( m_bPassTyped )
  104. {
  105. CConfirmPassDlg dlgPass;
  106. m_sz_password.CopyTo(dlgPass.m_szOrigPass);
  107. if ( dlgPass.DoModal() != IDOK )
  108. {
  109. m_cedit_password.SetFocus();
  110. m_cedit_password.SetSel(0, -1);
  111. return FALSE;
  112. }
  113. }
  114. CError err;
  115. CString csTempPassword;
  116. m_szPassword.CopyTo(csTempPassword);
  117. CComAuthInfo auth(m_szServer, m_szUserName, csTempPassword);
  118. CMetaKey mk(&auth, m_szMeta, METADATA_PERMISSION_WRITE);
  119. // TODO add inheritace override dialog support
  120. do
  121. {
  122. err = mk.QueryResult();
  123. BREAK_ON_ERR_FAILURE(err);
  124. err = mk.SetValue(MD_LOGSQL_DATA_SOURCES, m_sz_datasource);
  125. BREAK_ON_ERR_FAILURE(err);
  126. if (m_bPassTyped)
  127. {
  128. CString csTempPassword;
  129. m_sz_password.CopyTo(csTempPassword);
  130. err = mk.SetValue(MD_LOGSQL_PASSWORD, csTempPassword);
  131. BREAK_ON_ERR_FAILURE(err);
  132. }
  133. err = mk.SetValue(MD_LOGSQL_TABLE_NAME, m_sz_table);
  134. BREAK_ON_ERR_FAILURE(err);
  135. err = mk.SetValue(MD_LOGSQL_USER_NAME, m_sz_username);
  136. BREAK_ON_ERR_FAILURE(err);
  137. SetModified(FALSE);
  138. } while (FALSE);
  139. m_sz_password.CopyTo(m_szOrigPass);
  140. m_bPassTyped = FALSE;
  141. return CPropertyPage::OnApply();
  142. }
  143. void CLogODBC::OnChangeOdbcDatasource()
  144. {
  145. SetModified();
  146. }
  147. void CLogODBC::OnChangeOdbcPassword()
  148. {
  149. m_bPassTyped = TRUE;
  150. SetModified();
  151. }
  152. void CLogODBC::OnChangeOdbcTable()
  153. {
  154. SetModified();
  155. }
  156. void CLogODBC::OnChangeOdbcUsername()
  157. {
  158. SetModified();
  159. }