Source code of Windows XP (NT5)
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.

248 lines
8.1 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Windows NT Directory Service Property Pages
  4. //
  5. // Microsoft Windows
  6. // Copyright (C) Microsoft Corporation, 1992 - 1999
  7. //
  8. // File: dscmn.h
  9. //
  10. // Contents: Methods exported from DSPROP.DLL for use in DSADMIN.DLL
  11. //
  12. // History: 19-February-98 JonN created
  13. //
  14. //-----------------------------------------------------------------------------
  15. #ifndef _DSCMN_H_
  16. #define _DSCMN_H_
  17. //
  18. // Illegal characters that cannot be used in the UPN or SAM Account name
  19. //
  20. #define INVALID_ACCOUNT_NAME_CHARS L"\"/\\[]:|<>+=;,?,*"
  21. #define INVALID_ACCOUNT_NAME_CHARS_WITH_AT L"\"/\\[]:|<>+=;,?,*@"
  22. // This GUID is copied from ds\setup\schema.ini
  23. #define SZ_GUID_CONTROL_UserChangePassword L"ab721a53-1e2f-11d0-9819-00aa0040529b"
  24. extern const GUID GUID_CONTROL_UserChangePassword;
  25. /* add this to your source:
  26. const GUID GUID_CONTROL_UserChangePassword =
  27. { 0xab721a53, 0x1e2f, 0x11d0, { 0x98, 0x19, 0x00, 0xaa, 0x00, 0x40, 0x52, 0x9b}};
  28. */
  29. HRESULT DSPROP_PickComputer(
  30. IN HWND hwndParent,
  31. IN LPCWSTR lpcwszRootPath, // only the server name is used
  32. OUT BSTR* pbstrADsPath );
  33. HRESULT DSPROP_PickNTDSDSA(
  34. IN HWND hwndParent,
  35. IN LPCWSTR lpcwszRootPath,
  36. OUT BSTR* pbstrADsPath );
  37. HRESULT DSPROP_DSQuery(
  38. IN HWND hwndParent,
  39. IN LPCWSTR lpcwszRootPath,
  40. IN CLSID* pclsidDefaultForm,
  41. OUT BSTR* pbstrADsPath );
  42. HRESULT DSPROP_IsFrsObject( IN LPWSTR pszClassName, OUT bool* pfIsFrsObject );
  43. HRESULT DSPROP_RemoveX500LeafElements(
  44. IN unsigned int nElements,
  45. IN OUT BSTR* pbstrADsPath );
  46. HRESULT DSPROP_TweakADsPath(
  47. IN LPCWSTR lpcwszInitialADsPath,
  48. IN int iTargetLevelsUp,
  49. IN PWCHAR* ppwszTargetLevelsBack,
  50. OUT BSTR* pbstrResultDN
  51. );
  52. HRESULT DSPROP_RetrieveRDN(
  53. IN LPCWSTR lpwszDN,
  54. OUT BSTR* pbstrRDN
  55. );
  56. //HRESULT DSPROP_GetGCSearch(
  57. // IN REFIID iid,
  58. // OUT void** ppvObject
  59. // );
  60. HRESULT DSPROP_GetGCSearchOnDomain(
  61. PWSTR pwzDomainDnsName,
  62. IN REFIID iid,
  63. OUT void** ppvObject
  64. );
  65. typedef enum {
  66. GET_OBJ_CAN_NAME,
  67. GET_OBJ_CAN_NAME_EX,
  68. GET_OBJ_1779_DN,
  69. GET_OBJ_NT4_NAME,
  70. GET_DNS_DOMAIN_NAME,
  71. GET_NT4_DOMAIN_NAME,
  72. GET_FQDN_DOMAIN_NAME,
  73. GET_OBJ_UPN
  74. } CRACK_NAME_OPR;
  75. HRESULT CrackName(PWSTR pwzNameIn, PWSTR * ppwzDnsName,
  76. CRACK_NAME_OPR Opr, HWND hWnd = NULL);
  77. void MsgBox(UINT MsgID, HWND hWnd);
  78. void MsgBox2(UINT MsgID, UINT InsertID, HWND hWnd);
  79. //
  80. // Error reporting. Note, use MsgBoxX (see above) for non-error messages.
  81. //
  82. void ErrMsg(UINT MsgID, HWND hWnd = NULL);
  83. void ErrMsgParam(UINT MsgID, LPARAM param, HWND hWnd = NULL);
  84. BOOL CheckADsError(HRESULT * phr, BOOL fIgnoreAttrNotFound, PSTR file,
  85. int line, HWND hwnd = NULL);
  86. #define CHECK_ADS_HR(phr, hwnd) CheckADsError(phr, FALSE, __FILE__, __LINE__, hwnd)
  87. #define CHECK_ADS_HR_IGNORE_UNFOUND_ATTR(phr, hwnd) \
  88. CheckADsError(phr, TRUE, __FILE__, __LINE__, hwnd)
  89. void ReportError(HRESULT hr, int nStr, HWND hWnd = NULL);
  90. #if defined(DSADMIN)
  91. //+----------------------------------------------------------------------------
  92. //
  93. // Function: SuperMsgBox
  94. //
  95. // Synopsis: Displays a message obtained from a string resource with
  96. // the parameters expanded. The error param, dwErr, if
  97. // non-zero, is converted to a string and becomes the first
  98. // replaceable param.
  99. //
  100. // This function includes the functionality of ReportErrorEx in
  101. // dsadmin\util.cpp *except* it does not have SpecialMessageBox.
  102. // It also can replace ReportMessageEx by setting dwErr to zero.
  103. //
  104. // Note: this function is UNICODE-only.
  105. //
  106. //-----------------------------------------------------------------------------
  107. int SuperMsgBox(
  108. HWND hWnd, // owning window.
  109. int nMessageId, // string resource ID of message. Must have replacable params to match nArguments.
  110. int nTitleId, // string resource ID of the title. If zero, uses IDS_MSG_TITLE.
  111. UINT ufStyle, // MessageBox flags.
  112. DWORD dwErr, // Error code, or zero if not needed.
  113. PVOID * rgpvArgs, // array of pointers/values for substitution in the nMessageId string.
  114. int nArguments, // count of pointers in string array.
  115. BOOL fTryADSiErrors,// If the failure is the result of an ADSI call, see if an ADSI extended error.
  116. PSTR szFile, // use the __FILE__ macro. ignored in retail build.
  117. int nLine // use the __LINE__ macro. ignored in retail build.
  118. );
  119. #endif //defined(DSADMIN)
  120. HRESULT
  121. ModifyNetWareUserPassword(
  122. IN IADsUser* pADsUser,
  123. IN PCWSTR pwzADsPath,
  124. IN PCWSTR pwzNewPassword
  125. );
  126. BOOL CheckGroupUpdate(HRESULT hr, HWND hPage = NULL, BOOL fAdd = TRUE, PWSTR pwzDN = NULL);
  127. #ifndef dspAssert
  128. #define dspAssert ASSERT
  129. #endif
  130. // smartpointer for PADS_ATTR_INFO
  131. void Smart_PADS_ATTR_INFO__Empty( PADS_ATTR_INFO* ppAttrs );
  132. class Smart_PADS_ATTR_INFO
  133. {
  134. private:
  135. PADS_ATTR_INFO m_pAttrs;
  136. public:
  137. Smart_PADS_ATTR_INFO::Smart_PADS_ATTR_INFO() : m_pAttrs(NULL) {}
  138. Smart_PADS_ATTR_INFO::~Smart_PADS_ATTR_INFO() { Empty(); }
  139. operator PADS_ATTR_INFO() const { return m_pAttrs; }
  140. PADS_ATTR_INFO* operator&() { return &m_pAttrs; }
  141. PADS_ATTR_INFO operator->() {dspAssert(m_pAttrs); return m_pAttrs;}
  142. void Empty() { Smart_PADS_ATTR_INFO__Empty( &m_pAttrs ); }
  143. };
  144. // smartpointer for DsBind handle
  145. void Smart_DsHandle__Empty( HANDLE* phDs );
  146. class Smart_DsHandle
  147. {
  148. private:
  149. HANDLE m_hDs;
  150. public:
  151. Smart_DsHandle::Smart_DsHandle() : m_hDs(NULL) {}
  152. Smart_DsHandle::~Smart_DsHandle() { Empty(); }
  153. operator HANDLE() const { return m_hDs; }
  154. HANDLE* operator&() { return &m_hDs; }
  155. void Empty() { Smart_DsHandle__Empty( &m_hDs ); }
  156. };
  157. class DSPROP_BSTR_BLOCK;
  158. bool DSPROP_BSTR_BLOCK__SetCount( DSPROP_BSTR_BLOCK& block, int cItems );
  159. BSTR& DSPROP_BSTR_BLOCK__Reference( DSPROP_BSTR_BLOCK& block, int iItem );
  160. class DSPROP_BSTR_BLOCK
  161. {
  162. public:
  163. DSPROP_BSTR_BLOCK()
  164. : m_cItems( 0 )
  165. , m_abstrItems( NULL ) {}
  166. ~DSPROP_BSTR_BLOCK() { Empty(); }
  167. int QueryCount() const { return m_cItems; }
  168. const BSTR operator[](int iItem) const
  169. { return DSPROP_BSTR_BLOCK__Reference(
  170. const_cast<DSPROP_BSTR_BLOCK&>(*this), iItem ); }
  171. operator const BSTR*() const { return m_abstrItems; }
  172. operator LPWSTR*() const { return (LPWSTR*)m_abstrItems; }
  173. bool SetCount( int cItems )
  174. { return DSPROP_BSTR_BLOCK__SetCount( *this, cItems ); }
  175. bool Set( BSTR cbstrItem, int iItem )
  176. {
  177. return (NULL != (
  178. DSPROP_BSTR_BLOCK__Reference( *this, iItem ) =
  179. ::SysAllocString(cbstrItem) ) );
  180. }
  181. void Empty() { (void) SetCount(0); }
  182. private:
  183. int m_cItems;
  184. BSTR* m_abstrItems;
  185. friend bool DSPROP_BSTR_BLOCK__SetCount( DSPROP_BSTR_BLOCK& block, int cItems );
  186. friend BSTR& DSPROP_BSTR_BLOCK__Reference( DSPROP_BSTR_BLOCK& block, int iItem );
  187. };
  188. HRESULT DSPROP_ShallowSearch(
  189. IN OUT DSPROP_BSTR_BLOCK* pbstrBlock,
  190. IN LPCTSTR lpcwszADsPathDirectory,
  191. IN LPCTSTR lpcwszTargetDesiredClass,
  192. IN PADS_ATTR_INFO pAttrInfoExclusions = NULL
  193. );
  194. // The following functions support duelling listbox capability
  195. HRESULT DSPROP_Duelling_Populate(
  196. IN HWND hwndListbox,
  197. IN const DSPROP_BSTR_BLOCK& bstrblock
  198. );
  199. void DSPROP_Duelling_UpdateButtons(
  200. HWND hwndDlg,
  201. int nAnyCtrlid
  202. );
  203. void DSPROP_Duelling_ButtonClick(
  204. HWND hwndDlg,
  205. int nButtonCtrlid
  206. );
  207. void DSPROP_Duelling_ClearListbox(
  208. HWND hwndListbox
  209. );
  210. // JonN 4/8/99: add code to enable horizontal scrolling where appropriate
  211. HRESULT DSPROP_HScrollStringListbox(
  212. HWND hwndListbox
  213. );
  214. DWORD DSPROP_CreateHomeDirectory(IN PSID pUserSid, IN LPCWSTR lpszPathName);
  215. BOOL DSPROP_IsValidUNCPath(LPCWSTR lpszPath);
  216. void DSPROP_DomainVersionDlg(PCWSTR pwzDomainPath, PCWSTR pwzDomainDnsName,
  217. HWND hWndParent);
  218. void DSPROP_ForestVersionDlg(PCWSTR pwzConfigPath, PCWSTR pwzPartitionsPath,
  219. PCWSTR pwzSchemaPath, PCWSTR pwzRootDnsName,
  220. HWND hWndParent);
  221. #endif // _DSCMN_H_