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.

179 lines
4.9 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. /*-----------------------------------------------------------------------------
  4. / Local functions / data
  5. /----------------------------------------------------------------------------*/
  6. static WCHAR c_szQueryPrefixUser[] =
  7. L"(|"
  8. L"(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3))"
  9. L"(&(objectCategory=person)(!objectSid=*))"
  10. L"(&(objectCategory=group)(groupType:1.2.840.113556.1.4.804:=14))"
  11. L")";
  12. static COLUMNINFO columns[] =
  13. {
  14. 0, 0, IDS_CN, 0, c_szName,
  15. 0, 0, IDS_OBJECTCLASS, DSCOLUMNPROP_OBJECTCLASS, NULL,
  16. 0, DEFAULT_WIDTH_DESCRIPTION, IDS_DESCRIPTION, 0, c_szDescription,
  17. };
  18. //
  19. // Help ID mappings
  20. //
  21. static DWORD const aFormHelpIDs[] =
  22. {
  23. IDC_USERNAME, IDH_USER_GROUP_NAME,
  24. IDC_USERDESC, IDH_USER_GROUP_DESCRIPTION,
  25. 0, 0
  26. };
  27. /*-----------------------------------------------------------------------------
  28. / Users and Groups
  29. /----------------------------------------------------------------------------*/
  30. static PAGECTRL ctrlsUser[] =
  31. {
  32. IDC_USERNAME, L"anr", FILTER_CONTAINS,
  33. IDC_USERDESC, c_szDescription, FILTER_CONTAINS,
  34. };
  35. static LPWSTR c_szClassListUsers[] =
  36. {
  37. L"user",
  38. L"group",
  39. L"contact",
  40. };
  41. /*-----------------------------------------------------------------------------
  42. / PageProc_User
  43. / -------------
  44. / PageProc for handling the messages for this object.
  45. /
  46. / In:
  47. / pPage -> instance data for this form
  48. / hwnd = window handle for the form dialog
  49. / uMsg, wParam, lParam = message parameters
  50. /
  51. / Out:
  52. / HRESULT (E_NOTIMPL) if not handled
  53. /----------------------------------------------------------------------------*/
  54. HRESULT CALLBACK PageProc_User(LPCQPAGE pPage, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  55. {
  56. HRESULT hr = S_OK;
  57. LPWSTR pQuery = NULL;
  58. TraceEnter(TRACE_FORMS, "PageProc_User");
  59. switch ( uMsg )
  60. {
  61. case CQPM_INITIALIZE:
  62. case CQPM_RELEASE:
  63. break;
  64. case CQPM_ENABLE:
  65. EnablePageControls(hwnd, ctrlsUser, ARRAYSIZE(ctrlsUser), (BOOL)wParam);
  66. break;
  67. case CQPM_GETPARAMETERS:
  68. {
  69. hr = GetQueryString(&pQuery, c_szQueryPrefixUser, hwnd, ctrlsUser, ARRAYSIZE(ctrlsUser));
  70. if ( SUCCEEDED(hr) )
  71. {
  72. hr = QueryParamsAlloc((LPDSQUERYPARAMS*)lParam, pQuery, GLOBAL_HINSTANCE, ARRAYSIZE(columns), columns);
  73. LocalFreeStringW(&pQuery);
  74. }
  75. FailGracefully(hr, "Failed to build DS argument block");
  76. break;
  77. }
  78. case CQPM_CLEARFORM:
  79. ResetPageControls(hwnd, ctrlsUser, ARRAYSIZE(ctrlsUser));
  80. break;
  81. case CQPM_PERSIST:
  82. {
  83. BOOL fRead = (BOOL)wParam;
  84. IPersistQuery* pPersistQuery = (IPersistQuery*)lParam;
  85. hr = PersistQuery(pPersistQuery, fRead, c_szMsPeople, hwnd, ctrlsUser, ARRAYSIZE(ctrlsUser));
  86. FailGracefully(hr, "Failed to persist page");
  87. break;
  88. }
  89. case CQPM_HELP:
  90. {
  91. LPHELPINFO pHelpInfo = (LPHELPINFO)lParam;
  92. WinHelp((HWND)pHelpInfo->hItemHandle,
  93. DSQUERY_HELPFILE,
  94. HELP_WM_HELP,
  95. (DWORD_PTR)aFormHelpIDs);
  96. break;
  97. }
  98. case DSQPM_GETCLASSLIST:
  99. {
  100. hr = ClassListAlloc((LPDSQUERYCLASSLIST*)lParam, c_szClassListUsers, ARRAYSIZE(c_szClassListUsers));
  101. FailGracefully(hr, "Failed to allocate class list");
  102. break;
  103. }
  104. case DSQPM_HELPTOPICS:
  105. {
  106. HWND hwndFrame = (HWND)lParam;
  107. HtmlHelp(hwndFrame, TEXT("omc.chm"), HH_HELP_FINDER, 0);
  108. break;
  109. }
  110. default:
  111. hr = E_NOTIMPL;
  112. break;
  113. }
  114. exit_gracefully:
  115. TraceLeaveResult(hr);
  116. }
  117. /*-----------------------------------------------------------------------------
  118. / DlgProc_User
  119. / ------------
  120. / Handle dialog specific message for the users page.
  121. /
  122. / In:
  123. / hwnd, uMsg, wParam, lParam = standard parameters
  124. /
  125. / Out:
  126. / INT_PTR
  127. /----------------------------------------------------------------------------*/
  128. INT_PTR CALLBACK DlgProc_User(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  129. {
  130. INT_PTR fResult = 0;
  131. LPCQPAGE pQueryPage;
  132. if ( uMsg == WM_INITDIALOG )
  133. {
  134. pQueryPage = (LPCQPAGE)lParam;
  135. SetWindowLongPtr(hwnd, DWLP_USER, (LRESULT)pQueryPage);
  136. Edit_LimitText(GetDlgItem(hwnd, IDC_USERNAME), MAX_PATH);
  137. Edit_LimitText(GetDlgItem(hwnd, IDC_USERDESC), MAX_PATH);
  138. }
  139. else if ( uMsg == WM_CONTEXTMENU )
  140. {
  141. WinHelp((HWND)wParam, DSQUERY_HELPFILE, HELP_CONTEXTMENU, (DWORD_PTR)aFormHelpIDs);
  142. fResult = TRUE;
  143. }
  144. return fResult;
  145. }