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.

270 lines
6.9 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995
  5. //
  6. // File: cuar.cxx
  7. //
  8. // Contents: Account Restrictions Propset for the User object
  9. //
  10. // History: 11-1-95 krishnag Created.
  11. // 8-5-96 ramv Modified to be consistent with spec
  12. //
  13. //
  14. // PROPERTY_RW(AccountDisabled, boolean, 1) NI
  15. // PROPERTY_RW(AccountExpirationDate, DATE, 2) NI
  16. // PROPERTY_RO(AccountCanExpire, boolean, 3) NI
  17. // PROPERTY_RO(PasswordCanExpire, boolean, 4) NI
  18. // PROPERTY_RW(GraceLoginsAllowed, long, 5) NI
  19. // PROPERTY_RW(GraceLoginsRemaining, long, 6) NI
  20. // PROPERTY_RW(IsAccountLocked, boolean, 7) NI
  21. // PROPERTY_RW(IsAdmin, boolean, 8) NI
  22. // PROPERTY_RW(LoginHours, VARIANT, 9) NI
  23. // PROPERTY_RW(LoginWorkstations, VARIANT, 10) NI
  24. // PROPERTY_RW(MaxLogins, long, 11) NI
  25. // PROPERTY_RW(MaxStorage, long, 12) NI
  26. // PROPERTY_RW(PasswordExpirationDate, DATE, 13) NI
  27. // PROPERTY_RW(PasswordRequired, boolean, 14) NI
  28. // PROPERTY_RW(RequireUniquePassword,boolean, 15) NI
  29. //
  30. //
  31. //----------------------------------------------------------------------------
  32. #include "NWCOMPAT.hxx"
  33. #pragma hdrstop
  34. // Class CNWCOMPATUser
  35. /* IADsFSUserAccountRestrictions methods */
  36. STDMETHODIMP
  37. CNWCOMPATUser::get_AccountDisabled(THIS_ VARIANT_BOOL FAR* retval)
  38. {
  39. GET_PROPERTY_VARIANT_BOOL((IADsUser *)this, AccountDisabled);
  40. }
  41. STDMETHODIMP
  42. CNWCOMPATUser::put_AccountDisabled(THIS_ VARIANT_BOOL fAccountDisabled)
  43. {
  44. PUT_PROPERTY_VARIANT_BOOL((IADsUser *)this, AccountDisabled);
  45. }
  46. STDMETHODIMP
  47. CNWCOMPATUser::get_AccountExpirationDate(THIS_ DATE FAR* retval)
  48. {
  49. GET_PROPERTY_DATE((IADsUser *)this, AccountExpirationDate);
  50. }
  51. STDMETHODIMP
  52. CNWCOMPATUser::put_AccountExpirationDate(THIS_ DATE daAccountExpirationDate)
  53. {
  54. PUT_PROPERTY_DATE((IADsUser *)this, AccountExpirationDate);
  55. }
  56. STDMETHODIMP
  57. CNWCOMPATUser::get_GraceLoginsAllowed(THIS_ long FAR* retval)
  58. {
  59. GET_PROPERTY_LONG((IADsUser *)this, GraceLoginsAllowed);
  60. }
  61. STDMETHODIMP
  62. CNWCOMPATUser::put_GraceLoginsAllowed(THIS_ long lGraceLoginsAllowed)
  63. {
  64. PUT_PROPERTY_LONG((IADsUser *)this, GraceLoginsAllowed);
  65. }
  66. STDMETHODIMP
  67. CNWCOMPATUser::get_GraceLoginsRemaining(THIS_ long FAR* retval)
  68. {
  69. GET_PROPERTY_LONG((IADsUser *)this, GraceLoginsRemaining);
  70. }
  71. STDMETHODIMP
  72. CNWCOMPATUser::put_GraceLoginsRemaining(THIS_ long lGraceLoginsRemaining)
  73. {
  74. PUT_PROPERTY_LONG((IADsUser *)this, GraceLoginsRemaining);
  75. }
  76. STDMETHODIMP
  77. CNWCOMPATUser::get_IsAccountLocked(THIS_ VARIANT_BOOL FAR* retval)
  78. {
  79. GET_PROPERTY_VARIANT_BOOL((IADsUser *)this, IsAccountLocked);
  80. }
  81. STDMETHODIMP
  82. CNWCOMPATUser::put_IsAccountLocked(THIS_ VARIANT_BOOL fIsAccountLocked)
  83. {
  84. PUT_PROPERTY_VARIANT_BOOL((IADsUser *)this, IsAccountLocked);
  85. }
  86. STDMETHODIMP
  87. CNWCOMPATUser::get_LoginHours(THIS_ VARIANT FAR* retval)
  88. {
  89. GET_PROPERTY_VARIANT((IADsUser *)this, LoginHours);
  90. }
  91. STDMETHODIMP
  92. CNWCOMPATUser::put_LoginHours(THIS_ VARIANT vLoginHours)
  93. {
  94. PUT_PROPERTY_VARIANT((IADsUser *)this, LoginHours);
  95. }
  96. STDMETHODIMP
  97. CNWCOMPATUser::get_LoginWorkstations(THIS_ VARIANT FAR* retval)
  98. {
  99. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  100. }
  101. STDMETHODIMP
  102. CNWCOMPATUser::put_LoginWorkstations(THIS_ VARIANT vLoginWorkstations)
  103. {
  104. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  105. }
  106. STDMETHODIMP
  107. CNWCOMPATUser::get_MaxLogins(THIS_ long FAR* retval)
  108. {
  109. GET_PROPERTY_LONG((IADsUser *)this, MaxLogins);
  110. }
  111. STDMETHODIMP
  112. CNWCOMPATUser::put_MaxLogins(THIS_ long lMaxLogins)
  113. {
  114. PUT_PROPERTY_LONG((IADsUser *)this, MaxLogins);
  115. }
  116. STDMETHODIMP
  117. CNWCOMPATUser::get_MaxStorage(THIS_ long FAR* retval)
  118. {
  119. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  120. }
  121. STDMETHODIMP
  122. CNWCOMPATUser::put_MaxStorage(THIS_ long lMaxStorage)
  123. {
  124. RRETURN_EXP_IF_ERR(E_NOTIMPL);
  125. }
  126. STDMETHODIMP
  127. CNWCOMPATUser::get_PasswordExpirationDate(THIS_ DATE FAR* retval)
  128. {
  129. GET_PROPERTY_DATE((IADsUser *)this, PasswordExpirationDate);
  130. }
  131. STDMETHODIMP
  132. CNWCOMPATUser::put_PasswordExpirationDate(THIS_ DATE daPasswordExpirationDate)
  133. {
  134. PUT_PROPERTY_DATE((IADsUser *)this, PasswordExpirationDate);
  135. }
  136. STDMETHODIMP
  137. CNWCOMPATUser::get_PasswordMinimumLength(THIS_ long FAR* retval)
  138. {
  139. GET_PROPERTY_LONG((IADsUser *)this, PasswordMinimumLength);
  140. }
  141. STDMETHODIMP
  142. CNWCOMPATUser::put_PasswordMinimumLength(THIS_ long lPasswordMinimumLength)
  143. {
  144. PUT_PROPERTY_LONG((IADsUser *)this, PasswordMinimumLength);
  145. }
  146. STDMETHODIMP
  147. CNWCOMPATUser::get_PasswordRequired(THIS_ VARIANT_BOOL FAR* retval)
  148. {
  149. GET_PROPERTY_VARIANT_BOOL((IADsUser *)this, PasswordRequired);
  150. }
  151. STDMETHODIMP
  152. CNWCOMPATUser::put_PasswordRequired(THIS_ VARIANT_BOOL fPasswordRequired)
  153. {
  154. PUT_PROPERTY_VARIANT_BOOL((IADsUser *)this, PasswordRequired);
  155. }
  156. STDMETHODIMP
  157. CNWCOMPATUser::get_RequireUniquePassword(THIS_ VARIANT_BOOL FAR* retval)
  158. {
  159. GET_PROPERTY_VARIANT_BOOL((IADsUser *)this, RequireUniquePassword);
  160. }
  161. STDMETHODIMP
  162. CNWCOMPATUser::put_RequireUniquePassword(THIS_ VARIANT_BOOL fRequireUniquePassword)
  163. {
  164. PUT_PROPERTY_VARIANT_BOOL((IADsUser *)this, RequireUniquePassword);
  165. }
  166. STDMETHODIMP
  167. CNWCOMPATUser::SetPassword(THIS_ BSTR NewPassword)
  168. {
  169. HRESULT hr = S_OK ;
  170. NWOBJ_ID ObjectID;
  171. NW_USER_INFO NwUserInfo = {NULL, NULL, NULL, NULL};
  172. //
  173. // We dont care what state the object is in, since all we need is
  174. // already there from core init.
  175. //
  176. hr = NWApiMakeUserInfo(
  177. _ServerName,
  178. _Name,
  179. NewPassword,
  180. &NwUserInfo
  181. );
  182. BAIL_ON_FAILURE(hr);
  183. hr = NWApiSetUserPassword(
  184. &NwUserInfo,
  185. &ObjectID,
  186. NULL
  187. ) ;
  188. error:
  189. (void) NWApiFreeUserInfo(
  190. &NwUserInfo
  191. );
  192. RRETURN_EXP_IF_ERR(hr) ;
  193. }
  194. STDMETHODIMP
  195. CNWCOMPATUser::ChangePassword(THIS_ BSTR bstrOldPassword, BSTR bstrNewPassword)
  196. {
  197. HRESULT hr = S_OK ;
  198. NWOBJ_ID ObjectID;
  199. NW_USER_INFO NwUserInfo = {NULL, NULL, NULL, NULL};
  200. //
  201. // We dont care what state the object is in, since all we need is
  202. // already there from core init.
  203. //
  204. hr = NWApiMakeUserInfo(
  205. _ServerName,
  206. _Name,
  207. bstrNewPassword,
  208. &NwUserInfo
  209. );
  210. BAIL_ON_FAILURE(hr);
  211. hr = NWApiSetUserPassword(
  212. &NwUserInfo,
  213. &ObjectID,
  214. (LPWSTR) bstrOldPassword
  215. ) ;
  216. error:
  217. (void) NWApiFreeUserInfo(
  218. &NwUserInfo
  219. );
  220. RRETURN_EXP_IF_ERR(hr) ;
  221. }