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
5.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: misc.h
  8. //
  9. // Definitions and prototypes for miscellaneous stuff
  10. //
  11. //--------------------------------------------------------------------------
  12. #ifndef _MISC_H_
  13. #define _MISC_H_
  14. typedef struct _USER_INFO
  15. {
  16. PSID pSid;
  17. LPCTSTR pszName;
  18. LPCTSTR pszLogonName;
  19. SID_NAME_USE SidType;
  20. } USER_INFO, *PUSER_INFO;
  21. typedef struct _USER_LIST
  22. {
  23. ULONG cUsers;
  24. USER_INFO rgUsers[ANYSIZE_ARRAY];
  25. } USER_LIST, *PUSER_LIST;
  26. PSID GetAceSid(PACE_HEADER pAce);
  27. PSID LocalAllocSid(PSID pOriginal);
  28. void DestroyDPA(HDPA hList);
  29. extern "C" {
  30. #include <ntlsa.h>
  31. }
  32. LSA_HANDLE GetLSAConnection(LPCTSTR pszServer, DWORD dwAccessDesired);
  33. BOOL LookupSid(PSID pSid,
  34. LPCTSTR pszServer,
  35. LPSECURITYINFO2 psi2,
  36. PUSER_LIST *ppUserList);
  37. BOOL LookupSids(HDPA hSids,
  38. LPCTSTR pszServer,
  39. LPSECURITYINFO2 psi2,
  40. PUSER_LIST *ppUserList);
  41. BOOL LookupSidsAsync(HDPA hSids,
  42. LPCTSTR pszServer,
  43. LPSECURITYINFO2 psi2,
  44. HWND hWndNotify,
  45. UINT uMsgNotify,
  46. PHANDLE phThread = NULL);
  47. BOOL BuildUserDisplayName(LPTSTR *ppszDisplayName,
  48. LPCTSTR pszName,
  49. LPCTSTR pszLogonName = NULL);
  50. // Indexes into the SID image list
  51. typedef enum
  52. {
  53. SID_IMAGE_UNKNOWN = 0,
  54. SID_IMAGE_COMPUTER,
  55. SID_IMAGE_GROUP,
  56. SID_IMAGE_LOCALGROUP,
  57. SID_IMAGE_USER
  58. } SID_IMAGE_INDEX;
  59. HIMAGELIST LoadImageList(HINSTANCE hInstance, LPCTSTR pszBitmapID);
  60. SID_IMAGE_INDEX GetSidImageIndex(PSID psid, SID_NAME_USE sidType);
  61. BOOL IsStandalone(LPCTSTR pszMachine, PBOOL pbIsDC = NULL);
  62. BOOL IsDACLCanonical(PACL pDacl);
  63. BOOL IsDenyACL(PACL pDacl,
  64. BOOL fProtected,
  65. DWORD dwFullControlMask,
  66. LPDWORD pdwWarning);
  67. //
  68. // Possible SIDs that can be retrieved using QuerySystemSid.
  69. //
  70. enum UI_SystemSid
  71. {
  72. // Well-known / universal
  73. UI_SID_World = 0,
  74. UI_SID_CreatorOwner,
  75. UI_SID_CreatorGroup,
  76. UI_SID_Dialup,
  77. UI_SID_Network,
  78. UI_SID_Batch,
  79. UI_SID_Interactive,
  80. UI_SID_Service,
  81. UI_SID_AnonymousLogon,
  82. UI_SID_Proxy,
  83. UI_SID_EnterpriseDC,
  84. UI_SID_Self,
  85. UI_SID_AuthenticatedUser,
  86. UI_SID_RestrictedCode,
  87. UI_SID_TerminalServer,
  88. UI_SID_LocalSystem,
  89. // Aliases ("BUILTIN")
  90. UI_SID_Admins,
  91. // UI_SID_Users,
  92. // UI_SID_Guests,
  93. // UI_SID_PowerUsers,
  94. // UI_SID_AccountOps,
  95. // UI_SID_SystemOps,
  96. // UI_SID_PrintOps,
  97. // UI_SID_BackupOps,
  98. // UI_SID_Replicator,
  99. // UI_SID_RasServers,
  100. // Special value that gives the number of valid UI_SID_* types.
  101. // Don't add any new types after this value (add them before).
  102. UI_SID_Count,
  103. // This special value can be used for initializing enum UI_SystemSid
  104. // variables with a known unused quantity. This value should never
  105. // be passed to QuerySystemSid.
  106. UI_SID_Invalid = -1
  107. };
  108. #define COUNT_SYSTEM_SID_TYPES ((int)UI_SID_Count)
  109. #define COUNT_WELL_KNOWN_SYSTEM_SIDS ((int)UI_SID_Admins)
  110. PSID QuerySystemSid(UI_SystemSid SystemSidType);
  111. #define IsNTAuthority(pSid) EqualPrefixSid(pSid, QuerySystemSid(UI_SID_LocalSystem))
  112. #define IsAliasSid(pSid) EqualPrefixSid(pSid, QuerySystemSid(UI_SID_Admins))
  113. #define IsCreatorSid(pSid) EqualPrefixSid(pSid, QuerySystemSid(UI_SID_CreatorOwner))
  114. #define EqualSystemSid(pSid, uiSid) EqualSid(pSid, QuerySystemSid(uiSid))
  115. //
  116. // Possible SIDs that can be retrieved using QueryTokenSid.
  117. //
  118. enum UI_TokenSid
  119. {
  120. UI_TSID_CurrentProcessUser = 0, // Always the logged on user SID
  121. UI_TSID_CurrentProcessOwner, // Generally logged on user SID, but sometimes not (e.g. Administrators)
  122. UI_TSID_CurrentProcessPrimaryGroup,
  123. UI_TSID_Count,
  124. UI_TSID_Invalid = -1
  125. };
  126. #define COUNT_TOKEN_SID_TYPES ((int)UI_TSID_Count)
  127. PSID QueryTokenSid(UI_TokenSid TokenSidType);
  128. PSID GetAuthenticationID(LPCWSTR pszServer);
  129. int CopyUnicodeString(LPTSTR pszDest, ULONG cchDest, PLSA_UNICODE_STRING pSrc);
  130. int CopyUnicodeString(LPTSTR *ppszResult, PLSA_UNICODE_STRING pSrc);
  131. BOOL IsSameGUID(const GUID *p1, const GUID *p2);
  132. #define IsNullGUID(p) (!(p) || IsSameGUID((p), &GUID_NULL))
  133. //
  134. //Get the count of inheritable aces in the acl
  135. //
  136. DWORD GetCountOfInheritableAces(PACL pAcl);
  137. DWORD GetCountOfInheritableAces(PSECURITY_DESCRIPTOR pSD);
  138. BOOL IsAclBloated(HWND hDlg, SECURITY_INFORMATION si, PSECURITY_DESCRIPTOR pSD, DWORD dwOrgInheritAceCount, BOOL bShowHelp);
  139. HRESULT MakeBold (HWND hwnd, HFONT * phNewFont);
  140. BOOL
  141. DoDisabledCheck(IN HWND hWnd,
  142. IN PDS_SELECTION_LIST pDsSelList);
  143. BOOL
  144. IsCallBackAcePresentInSD(PSECURITY_DESCRIPTOR pSD);
  145. BOOL
  146. IsCallBackAcePresentInAcl(PACL pAcl);
  147. #endif // _MISC_H_