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

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. LMOAcces.hxx
  7. This file contains the NEW_LM_OBJ rendition of the NetAccess APIs.
  8. FILE HISTORY:
  9. 06-Aug-1991 Johnl Reworked from Rustan's ACCPERM class
  10. 21-Aug-1991 rustanl Changed BufferQuery[...] methods to
  11. QueryBuffer[...].
  12. 07-Oct-1991 terryk type changes for NT
  13. 17-Oct-1991 terryk change the Required size of the
  14. structure
  15. 21-Oct-1991 terryk type changes for NT
  16. */
  17. #ifndef _LMOACCES_HXX_
  18. #define _LMOACCES_HXX_
  19. #include "lmobj.hxx"
  20. extern "C"
  21. {
  22. #include <lmaccess.h>
  23. }
  24. #include "string.hxx"
  25. #include "strlst.hxx"
  26. typedef UINT PERM;
  27. #define PERM_NO_SETTING (0x0000)
  28. #define PERM_READ ACCESS_READ
  29. #define PERM_WRITE ACCESS_WRITE
  30. #define PERM_EXEC ACCESS_EXEC
  31. #define PERM_CREATE ACCESS_CREATE
  32. #define PERM_DELETE ACCESS_DELETE
  33. #define PERM_ATTRIB ACCESS_ATRIB // sic.
  34. #define PERM_PERM ACCESS_PERM
  35. #define PERM_DENY_ACCESS ACCESS_GROUP // Note, the PERM_ deny access
  36. // bit uses the ACCESS_
  37. // group bit, since the PERM_
  38. // bits don't include a
  39. // group bit, and vice versa.
  40. /*************************************************************************
  41. NAME: NET_ACCESS
  42. SYNOPSIS: Base class for the NET_ACCESS LM objects
  43. INTERFACE:
  44. Delete
  45. Deletes the ACL from the resource.
  46. PARENT:
  47. USES:
  48. CAVEATS:
  49. NOTES:
  50. HISTORY:
  51. **************************************************************************/
  52. DLL_CLASS NET_ACCESS : public LOC_LM_OBJ
  53. {
  54. private:
  55. NLS_STR _nlsServer ;
  56. NLS_STR _nlsResource ;
  57. protected:
  58. NET_ACCESS( const TCHAR * pszServer, const TCHAR * pszResource );
  59. ~NET_ACCESS() ;
  60. public:
  61. virtual const TCHAR * QueryName( VOID ) const;
  62. const TCHAR * QueryServerName( VOID ) const;
  63. APIERR SetName( const TCHAR * pszResName ) ;
  64. APIERR SetServerName( const TCHAR * pszServerName ) ;
  65. APIERR Delete( void ) ;
  66. }; // class NET_ACCESS
  67. enum PERMNAME_TYPE // nametype (for Name Type)
  68. {
  69. PERMNAME_USER,
  70. PERMNAME_GROUP
  71. }; // enum PERMNAME_TYPE
  72. /*************************************************************************
  73. NAME: NET_ACCESS_1
  74. SYNOPSIS: LM OBJ class that encapsulates the NetAccess APIs at info
  75. level 1
  76. INTERFACE:
  77. PARENT: NET_ACCESS
  78. USES:
  79. CAVEATS:
  80. NOTES:
  81. HISTORY:
  82. Johnl 06-Aug-1991 Reworked from Rustan's LM_OBJ class
  83. KeithMo 29-Oct-1991 Changed _cACE from ULONG to UINT.
  84. **************************************************************************/
  85. DLL_CLASS NET_ACCESS_1 : public NET_ACCESS
  86. {
  87. private:
  88. UINT _cACE;
  89. access_list * FindACE( const TCHAR * pszName, enum PERMNAME_TYPE nametype ) const;
  90. #ifdef WIN32
  91. UINT QueryRequiredSpace( UINT cACE ) const
  92. { return ( sizeof( access_info_1 ) + MAX_PATH*sizeof(TCHAR) + sizeof(TCHAR) +
  93. cACE *( sizeof( access_list ) + UNLEN*sizeof(TCHAR) + sizeof(TCHAR) )); }
  94. /* Under Win32, the account names are not stored as inline arrays but
  95. * pointers into the API buffer. If we add new names we will create
  96. * new NLS_STRs and store them in here.
  97. */
  98. STRLIST _strlstAccountNames ;
  99. #else
  100. UINT QueryRequiredSpace( UINT cACE ) const
  101. { return ( sizeof( access_info_1 ) + cACE * (sizeof(access_list) )); }
  102. #endif
  103. APIERR I_WriteInfoAux( VOID ) ;
  104. protected:
  105. // Note, Clone does the same thing as GetInfo does, only it gets
  106. // the info from another object, rather than from the network.
  107. virtual APIERR I_GetInfo( VOID );
  108. //virtual APIERR I_Clone( const ACCPERM & accpermSource );
  109. virtual APIERR I_WriteInfo( VOID );
  110. virtual APIERR I_CreateNew( VOID ) ;
  111. virtual APIERR I_WriteNew( VOID ) ;
  112. public:
  113. NET_ACCESS_1( const TCHAR * pszServer, const TCHAR * pszResource );
  114. ~NET_ACCESS_1() ;
  115. // The following nametype parameter indicates whether the pszName
  116. // is the name of a group or a user.
  117. PERM QueryPerm( const TCHAR * pszName, enum PERMNAME_TYPE nametype ) const;
  118. APIERR SetPerm( const TCHAR * pszName, enum PERMNAME_TYPE nametype, PERM perm );
  119. /* Copies the access permissions from the passed NET_ACCESS_1
  120. * parameter to this.
  121. */
  122. APIERR CopyAccessPerms( const NET_ACCESS_1 & netaccess1Src ) ;
  123. /* The following method removes all ACEs
  124. */
  125. APIERR ClearPerms( VOID );
  126. UINT QueryACECount( VOID ) const;
  127. APIERR QueryFailingName( NLS_STR * pnls, enum PERMNAME_TYPE * pnametype ) const;
  128. #ifdef WIN32
  129. access_list * QueryACE( UINT uiACE ) const
  130. { return (access_list *) (((BYTE*) QueryBufferPtr()) +
  131. ( sizeof( access_info_1 ) + uiACE * sizeof( access_list ))) ; }
  132. #else
  133. access_list * QueryACE( UINT uiACE ) const
  134. { return (access_list *)
  135. (((TCHAR *)QueryBufferPtr()) + QueryRequiredSpace( uiACE )); }
  136. #endif
  137. BOOL CompareACL( NET_ACCESS_1 * pnetacc1 ) ;
  138. UINT QueryAuditFlags( VOID ) const
  139. { return ((access_info_1 *)QueryBufferPtr())->acc1_attr ; }
  140. APIERR SetAuditFlags( short sAuditFlags ) ;
  141. }; // class NET_ACCESS_1
  142. #endif // _LMOACCES_HXX_