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.

246 lines
6.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. lmomisc.cxx
  7. Misc. objects
  8. LOGON_USER - wrapper class which handles NetWkstaSetUID2() net
  9. api call
  10. TIME_DAY_SERVER - wrapper class which handles NetRemoteTOD() net
  11. api
  12. LM_MESSAGE - wrapper class which handles NetMessageBuffSend()
  13. net api
  14. FILE HISTORY:
  15. terryk 04-Sep-91 Created
  16. terryk 11-Sep-91 Code review changed. Attend: terryk jimh
  17. yi-hsins jonn
  18. terryk 19-Sep-91 Move LOGON_USER from lmouser.hxx to
  19. here.
  20. terryk 07-Oct-91 type changes for NT
  21. terryk 17-Oct-91 Change TIME_OF_DAY's variable to pointer
  22. terryk 21-Oct-91 Remove LOGON_USER from NT
  23. */
  24. #ifndef _LMOMISC_HXX_
  25. #define _LMOMISC_HXX_
  26. #include "lmobj.hxx"
  27. #ifndef WIN32
  28. enum LOGON_USER_STATE
  29. {
  30. INVALID_STATE,
  31. LOGGED_ON,
  32. LOGGED_OFF
  33. };
  34. /*************************************************************************
  35. NAME: LOGON_USER
  36. SYNOPSIS: user object for logon and logoff the network
  37. INTERFACE:
  38. LOGON_USER() - constructor
  39. Logon() - logon the user to the network
  40. Logoff() - logoff the user from the network
  41. Query functions which calls after Logon call:
  42. TCHAR * QueryLogonComputer() - logon computer name
  43. const TCHAR * QueryLogonDomain() - logon domain name
  44. QueryPriv() - privilege level. It will return:
  45. USER_PRIV_GUESST - guest privilege
  46. USER_PRIV_USER - user privilege
  47. USER_PRIV_ADMIN - admin privilege
  48. LONG QueryPasswdAge() - password age. Specifies the
  49. time (in seconds) since the user password was
  50. changed
  51. ULONG QueryPasswdCanChange() - specifies the time when
  52. the user is allowed to change the password. This value
  53. is stored as the number of seconds elapsed since
  54. 00:00:00, January 1, 1970. A value of -1 means the
  55. user can never change the password.
  56. ULONG QueryPasswdMustChange() - specifies the time when
  57. the user must change the passwd. The value is stored as
  58. the number of seconds elapsed since 00:00:00, January 1,
  59. 1970.
  60. // QueryLogoffXXX()
  61. ULONG QueryLogoffDuration() - specifies the number of
  62. seconds elapsed since the user logged on.
  63. ULONG QueryLogoffNumLogons() - specifies the number of
  64. times this user is logged on. A value of -1 means the
  65. number of logons is unknown.
  66. PARENT: BASE
  67. USES: NLS_STR
  68. CAVEATS:
  69. NOTES: CODEWORK: if we need more logon information, we will
  70. need to implement more QueryLogonXXX() functions.
  71. HISTORY:
  72. terryk 6-Sep-91 Created
  73. terryk 20-Sep-91 Change from USER to BASE
  74. **************************************************************************/
  75. DLL_CLASS LOGON_USER : public BASE
  76. {
  77. private:
  78. enum LOGON_USER_STATE _state;
  79. TCHAR *_pszPasswd;
  80. BOOL _fValid;
  81. NLS_STR _nlsUsername;
  82. NLS_STR _nlsDomain;
  83. BUFFER _buffer;
  84. protected:
  85. struct user_logon_info_1 * QueryLogonInfo() const;
  86. struct user_logoff_info_1 * QueryLogoffInfo() const;
  87. public:
  88. LOGON_USER( const TCHAR * pszUsername, const TCHAR * pszDomain );
  89. APIERR Logon( const TCHAR * pszPasswd, APIERR *pLogonRetCode );
  90. APIERR Logoff( UINT uslogoff_level, APIERR *pLogoffRetCode );
  91. const TCHAR * QueryUsername() const
  92. { return _nlsUsername.QueryPch(); }
  93. // QueryLogonXXX()
  94. const TCHAR * QueryLogonComputer() const;
  95. const TCHAR * QueryLogonDomain() const;
  96. UINT QueryPriv() const;
  97. LONG QueryPasswdAge() const;
  98. ULONG QueryPasswdCanChange() const;
  99. ULONG QueryPasswdMustChange() const;
  100. // QueryLogoffXXX()
  101. ULONG QueryLogoffDuration() const;
  102. ULONG QueryLogoffNumLogons() const;
  103. };
  104. #endif
  105. /*************************************************************************
  106. NAME: LM_MESSAGE
  107. SYNOPSIS: class for message sending
  108. INTERFACE:
  109. LM_MESSAGE() - constructor
  110. SendBuffer() - send out the message to the recipient
  111. PARENT: LOC_LM_OBJ
  112. CAVEATS:
  113. NOTES:
  114. HISTORY:
  115. terryk 6-Sep-91 Created
  116. **************************************************************************/
  117. DLL_CLASS LM_MESSAGE: public LOC_LM_OBJ
  118. {
  119. public:
  120. LM_MESSAGE( const TCHAR * pszLocation = NULL );
  121. LM_MESSAGE( enum LOCATION_TYPE loctype );
  122. LM_MESSAGE( LOCATION & loc );
  123. APIERR SendBuffer( const TCHAR * pszRecipient, const BUFFER & buffer );
  124. APIERR SendBuffer( const TCHAR * pszRecipient, const TCHAR * pbBuffer,
  125. UINT cbBuffer );
  126. };
  127. /*************************************************************************
  128. NAME: TIME_OF_DAY
  129. SYNOPSIS: This object will get the remote server time/date
  130. information after the GetInfo functionc call.
  131. INTERFACE:
  132. TIME_OF_DAY() - constructor
  133. QueryElapsedt() - return the elapsed time
  134. QueryMsecs() - return the msecs
  135. QueryHours() - return the hours
  136. QueryMins() - return the mins
  137. QuerySecs() - return the secs
  138. QueryHunds() - return the hunds
  139. QueryTimezone() - return the time zone
  140. QueryTInterval() - return the time interval
  141. QueryDay() - return the day
  142. QueryMonth() - return the Month
  143. QueryYear() - return the Year
  144. QueyWeekday() - return the Weekday
  145. PARENT: LOC_LM_OBJ
  146. HISTORY:
  147. terryk 5-Sep-91 Created
  148. **************************************************************************/
  149. DLL_CLASS TIME_OF_DAY: public LOC_LM_OBJ
  150. {
  151. private:
  152. struct time_of_day_info *_ptodi;
  153. protected:
  154. virtual APIERR I_GetInfo();
  155. public:
  156. TIME_OF_DAY( const TCHAR *pszLocation );
  157. TIME_OF_DAY( enum LOCATION_TYPE loctype );
  158. TIME_OF_DAY( LOCATION & loc );
  159. ~TIME_OF_DAY();
  160. ULONG QueryElapsedt() const
  161. { CHECK_OK( 0 );
  162. return _ptodi->tod_elapsedt; }
  163. ULONG QueryMsecs() const
  164. { CHECK_OK( 0 );
  165. return _ptodi->tod_msecs; }
  166. ULONG QueryHours() const
  167. { CHECK_OK( 0 );
  168. return _ptodi->tod_hours; }
  169. ULONG QueryMins() const
  170. { CHECK_OK( 0 );
  171. return _ptodi->tod_mins; }
  172. ULONG QuerySecs() const
  173. { CHECK_OK( 0 );
  174. return _ptodi->tod_secs; }
  175. ULONG QueryHunds() const
  176. { CHECK_OK( 0 );
  177. return _ptodi->tod_hunds; }
  178. ULONG QueryTimezone() const
  179. { CHECK_OK( 0 );
  180. return _ptodi->tod_timezone; }
  181. ULONG QueryTInterval() const
  182. { CHECK_OK( 0 );
  183. return _ptodi->tod_tinterval; }
  184. ULONG QueryDay() const
  185. { CHECK_OK( 0 );
  186. return _ptodi->tod_day; }
  187. ULONG QueryMonth() const
  188. { CHECK_OK( 0 );
  189. return _ptodi->tod_month; }
  190. ULONG QueryYear() const
  191. { CHECK_OK( 0 );
  192. return _ptodi->tod_year; }
  193. ULONG QueryWeekday() const
  194. { CHECK_OK( 0 );
  195. return _ptodi->tod_weekday; }
  196. };
  197. #endif // _LMOMISC_HXX_