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.

208 lines
6.2 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. /*-----------------------------------------------------------------------------
  4. / Local functions / data
  5. /----------------------------------------------------------------------------*/
  6. #define MAX_QUERY_STRING_LENGTH 2048
  7. static TCHAR szQueryString[] = TEXT("QueryString");
  8. static COLUMNINFO columnsRawLDAP[] =
  9. {
  10. 0, 20, IDS_CN, 0, c_szName,
  11. 0, 20, IDS_OBJECTCLASS, DSCOLUMNPROP_OBJECTCLASS, NULL,
  12. 0, 60, IDS_DESCRIPTION, 0, c_szDescription,
  13. };
  14. //
  15. // Help ID mappings
  16. //
  17. static DWORD const aFormHelpIDs[] =
  18. {
  19. IDC_LDAP, IDH_LDAP_QUERY,
  20. 0, 0
  21. };
  22. /*-----------------------------------------------------------------------------
  23. / PageProc_RawLDAP
  24. / ----------------
  25. / PageProc for handling the messages for this object.
  26. /
  27. / In:
  28. / pPage -> instance data for this form
  29. / hwnd = window handle for the form dialog
  30. / uMsg, wParam, lParam = message parameters
  31. /
  32. / Out:
  33. / HRESULT (E_NOTIMPL) if not handled
  34. /----------------------------------------------------------------------------*/
  35. HRESULT CALLBACK PageProc_RawLDAP(LPCQPAGE pPage, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  36. {
  37. HRESULT hr = S_OK;
  38. TCHAR szBuffer[MAX_QUERY_STRING_LENGTH];
  39. TraceEnter(TRACE_FORMS, "PageProc_RawLDAP");
  40. switch ( uMsg )
  41. {
  42. case CQPM_INITIALIZE:
  43. case CQPM_RELEASE:
  44. break;
  45. case CQPM_ENABLE:
  46. EnableWindow(GetDlgItem(hwnd, IDC_LDAP), (BOOL)wParam);
  47. break;
  48. case CQPM_GETPARAMETERS:
  49. {
  50. LPDSQUERYPARAMS* ppDsQueryParams = (LPDSQUERYPARAMS*)lParam;
  51. // If we already have some query params then lets add to the query string,
  52. // if no then we must construct a new query.
  53. if ( *ppDsQueryParams )
  54. {
  55. if ( GetDlgItemText(hwnd, IDC_LDAP, szBuffer, ARRAYSIZE(szBuffer)) )
  56. {
  57. hr = QueryParamsAddQueryString(ppDsQueryParams, szBuffer);
  58. FailGracefully(hr, "Failed to append query to existing query string");
  59. }
  60. }
  61. else
  62. {
  63. if ( GetDlgItemText(hwnd, IDC_LDAP, szBuffer, ARRAYSIZE(szBuffer)) )
  64. {
  65. hr = QueryParamsAlloc(ppDsQueryParams, szBuffer, GLOBAL_HINSTANCE, ARRAYSIZE(columnsRawLDAP), columnsRawLDAP);
  66. FailGracefully(hr, "Failed to build DS argument block");
  67. }
  68. }
  69. break;
  70. }
  71. case CQPM_CLEARFORM:
  72. SetDlgItemText(hwnd, IDC_LDAP, TEXT(""));
  73. break;
  74. case CQPM_PERSIST:
  75. {
  76. BOOL fRead = (BOOL)wParam;
  77. IPersistQuery* pPersistQuery = (IPersistQuery*)lParam;
  78. // Read/Write the current query string from the file, if reading and we cannot
  79. // get the string then no real problem, just ignore it.
  80. if ( fRead )
  81. {
  82. if ( SUCCEEDED(pPersistQuery->ReadString(c_szMsPropertyWell, szQueryString, szBuffer, ARRAYSIZE(szBuffer))) )
  83. {
  84. Trace(TEXT("Query string from file is: %s"), szBuffer);
  85. SetDlgItemText(hwnd, IDC_LDAP, szBuffer);
  86. }
  87. }
  88. else
  89. {
  90. if ( GetDlgItemText(hwnd, IDC_LDAP, szBuffer, ARRAYSIZE(szBuffer)) )
  91. {
  92. Trace(TEXT("Writing query string to file: %s"), szBuffer);
  93. hr = pPersistQuery->WriteString(c_szMsPropertyWell, szQueryString, szBuffer);
  94. FailGracefully(hr, "Failed when writing out raw query string");
  95. }
  96. }
  97. break;
  98. }
  99. case CQPM_HELP:
  100. {
  101. LPHELPINFO pHelpInfo = (LPHELPINFO)lParam;
  102. WinHelp((HWND)pHelpInfo->hItemHandle,
  103. DSQUERY_HELPFILE,
  104. HELP_WM_HELP,
  105. (DWORD_PTR)aFormHelpIDs);
  106. break;
  107. }
  108. case DSQPM_GETCLASSLIST:
  109. // we don't generate any class list
  110. break;
  111. case DSQPM_HELPTOPICS:
  112. {
  113. HWND hwndFrame = (HWND)lParam;
  114. HtmlHelp(hwndFrame, TEXT("omc.chm"), HH_HELP_FINDER, 0);
  115. break;
  116. }
  117. default:
  118. hr = E_NOTIMPL;
  119. break;
  120. }
  121. exit_gracefully:
  122. TraceLeaveResult(hr);
  123. }
  124. /*-----------------------------------------------------------------------------
  125. / DlgProc_RawLDAP
  126. / ---------------
  127. / Handle operations specific to the RAW LDAP query form.
  128. /
  129. / In:
  130. / hwnd, uMsg, wParam, lParam = standard parameters
  131. /
  132. / Out:
  133. / INT_PTR
  134. /----------------------------------------------------------------------------*/
  135. INT_PTR CALLBACK DlgProc_RawLDAP(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  136. {
  137. INT_PTR fResult = 0;
  138. LPCQPAGE pQueryPage;
  139. if ( uMsg == WM_INITDIALOG )
  140. {
  141. pQueryPage = (LPCQPAGE)lParam;
  142. SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)pQueryPage);
  143. Edit_LimitText(GetDlgItem(hwnd, IDC_LDAP), MAX_QUERY_STRING_LENGTH);
  144. }
  145. else
  146. {
  147. pQueryPage = (LPCQPAGE)GetWindowLongPtr(hwnd, DWLP_USER);
  148. switch ( uMsg )
  149. {
  150. case WM_SIZE:
  151. {
  152. HWND hwndLDAP = GetDlgItem(hwnd, IDC_LDAP);
  153. RECT rect;
  154. // size the edit control to cover the entire form, retain the original
  155. // height, but apply the left border to the edit control
  156. GetRealWindowInfo(hwndLDAP, &rect, NULL);
  157. SetWindowPos(hwndLDAP, NULL,
  158. 0, 0,
  159. LOWORD(lParam)-(rect.left*2),
  160. HIWORD(lParam)-rect.top-rect.left,
  161. SWP_NOMOVE|SWP_NOZORDER);
  162. break;
  163. }
  164. case WM_CONTEXTMENU:
  165. {
  166. WinHelp((HWND)wParam, DSQUERY_HELPFILE, HELP_CONTEXTMENU, (DWORD_PTR)aFormHelpIDs);
  167. fResult = TRUE;
  168. break;
  169. }
  170. }
  171. }
  172. return fResult;
  173. }