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.

204 lines
4.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1990, 1991 **/
  4. /**********************************************************************/
  5. /*
  6. Subject.hxx
  7. This file contains the SUBJECT class definition. A subject is a
  8. user or group and the information need to uniquely identify that
  9. user or group.
  10. FILE HISTORY:
  11. Johnl 05-Aug-1991 Created
  12. */
  13. #ifndef _SUBJECT_HXX_
  14. #define _SUBJECT_HXX_
  15. #include <security.hxx>
  16. #include <string.hxx>
  17. #include <ntacutil.hxx>
  18. /* Subject types map to NT Sid Types but work for Lanman also.
  19. */
  20. enum SUBJECT_TYPE
  21. {
  22. SubjTypeUser = SidTypeUser,
  23. SubjTypeGroup = SidTypeGroup,
  24. SubjTypeAlias = SidTypeAlias,
  25. SubjTypeWellKnownGroup = SidTypeWellKnownGroup,
  26. SubjTypeUnknown = SidTypeUnknown,
  27. SubjTypeDeletedAccount = SidTypeDeletedAccount,
  28. SubjTypeRemote = 0xff
  29. } ;
  30. /*************************************************************************
  31. NAME: SUBJECT
  32. SYNOPSIS: Base subject class. A subject is a user/group on a secure
  33. system (such as NT or LM).
  34. INTERFACE:
  35. QueryDisplayName
  36. UI name to show the user (doesn't need to be unique)
  37. QuerySystemSubjectType
  38. Returns the subject type (SID type) if this subject is a well
  39. known subject (i.e., UI_SID_World, UI_SID_Network etc.).
  40. PARENT:
  41. USES:
  42. CAVEATS: IsGroup and IsUser should be used only on the Lanman side
  43. of things.
  44. NOTES:
  45. HISTORY:
  46. Johnl 05-Aug-1991 Created
  47. Johnl 11-Mar-1992 Changed to use SUBJECT_TYPE to help accomodate
  48. NT.
  49. **************************************************************************/
  50. class SUBJECT : public BASE
  51. {
  52. private:
  53. SUBJECT_TYPE _SubjType ;
  54. protected:
  55. SUBJECT( SUBJECT_TYPE SubjType ) ;
  56. public:
  57. virtual const TCHAR * QueryDisplayName( void ) const = 0 ;
  58. virtual UI_SystemSid QuerySystemSubjectType( void ) const ;
  59. BOOL IsGroup( void ) const
  60. { return _SubjType == SubjTypeGroup ; }
  61. BOOL IsUser( void ) const
  62. { return _SubjType == SubjTypeUser ; }
  63. BOOL IsAlias( void ) const
  64. { return _SubjType == SubjTypeAlias ; }
  65. SUBJECT_TYPE QueryType( void ) const
  66. { return _SubjType ; }
  67. void SetSubjectType( enum SUBJECT_TYPE SubjType )
  68. { _SubjType = SubjType ; }
  69. BOOL virtual IsEqual( const SUBJECT * psubj ) const = 0 ;
  70. APIERR virtual IsEveryoneGroup( BOOL * pfIsEveryone ) const ;
  71. virtual ~SUBJECT() ;
  72. } ;
  73. /*************************************************************************
  74. NAME: LM_SUBJECT
  75. SYNOPSIS: Lanman user/group
  76. INTERFACE:
  77. PARENT:
  78. USES:
  79. CAVEATS:
  80. NOTES:
  81. HISTORY:
  82. Johnl 05-Aug-1991 Created
  83. **************************************************************************/
  84. class LM_SUBJECT : public SUBJECT
  85. {
  86. private:
  87. NLS_STR _nlsDisplayName ;
  88. public:
  89. LM_SUBJECT( const TCHAR * pszUserGroupName, BOOL fIsGroup ) ;
  90. virtual ~LM_SUBJECT() ;
  91. virtual const TCHAR * QueryDisplayName( void ) const ;
  92. BOOL virtual IsEqual( const SUBJECT * psubj ) const ;
  93. } ;
  94. /*************************************************************************
  95. NAME: NT_SUBJECT
  96. SYNOPSIS: This class represents an "Account" in the NT SAM
  97. INTERFACE:
  98. PARENT:
  99. USES:
  100. CAVEATS:
  101. NOTES: If pszSubjectName is NULL, then the name will be retrieved
  102. from the LSA.
  103. HISTORY:
  104. JohnL 20-Dec-1991 Created
  105. **************************************************************************/
  106. class NT_SUBJECT : public SUBJECT
  107. {
  108. private:
  109. NLS_STR _nlsDisplayName ;
  110. OS_SID _ossid ;
  111. enum UI_SystemSid _SystemSidType ;
  112. /* When we construct an NT_SUBJECT, we have to check if the SID is one
  113. * of the well known sids that we special case (World, Creator Owner,
  114. * Interactive and Network). Rather then comparing all the time, we
  115. * will only compare if the sub-authority count of the SID is less
  116. * then or equal to the maximum sub-authority count of the SIDs that we
  117. * special case.
  118. */
  119. static UCHAR _cMaxWellKnownSubAuthorities ;
  120. public:
  121. NT_SUBJECT( PSID psidSubject,
  122. const TCHAR * pszSubjectName = NULL,
  123. SID_NAME_USE type = SidTypeUnknown,
  124. UI_SystemSid SystemSidType = UI_SID_Invalid ) ;
  125. ~NT_SUBJECT() ;
  126. APIERR SetDisplayName( const TCHAR * pszDisplayName )
  127. { _nlsDisplayName=pszDisplayName; return _nlsDisplayName.QueryError();}
  128. void SetNameUse( SID_NAME_USE type )
  129. { SetSubjectType( (SUBJECT_TYPE) type ) ; }
  130. virtual const TCHAR * QueryDisplayName( void ) const ;
  131. virtual UI_SystemSid QuerySystemSubjectType( void ) const ;
  132. BOOL virtual IsEqual( const SUBJECT * psubj ) const ;
  133. APIERR virtual IsEveryoneGroup( BOOL * pfIsEveryone ) const ;
  134. const OS_SID * QuerySID( void ) const
  135. { return &_ossid ; }
  136. } ;
  137. #endif // _SUBJECT_HXX_