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.

323 lines
7.6 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. // PROPERTY_RW(AccountDisabled, boolean, 1) I
  14. // PROPERTY_RW(AccountExpirationDate, DATE, 2) I
  15. // PROPERTY_RW(GraceLoginsAllowed, long, 5) NI
  16. // PROPERTY_RW(GraceLoginsRemaining, long, 6) NI
  17. // PROPERTY_RW(IsAccountLocked, boolean, 7) I
  18. // PROPERTY_RW(IsAdmin, boolean, 8) I
  19. // PROPERTY_RW(LoginHours, VARIANT, 9) I
  20. // PROPERTY_RW(LoginWorkstations, VARIANT, 10) I
  21. // PROPERTY_RW(MaxLogins, long, 11) I
  22. // PROPERTY_RW(MaxStorage, long, 12) I
  23. // PROPERTY_RW(PasswordExpirationDate, DATE, 13) I
  24. // PROPERTY_RW(PasswordRequired, boolean, 14) I
  25. // PROPERTY_RW(RequireUniquePassword,boolean, 15) I
  26. //
  27. //
  28. //----------------------------------------------------------------------------
  29. #include "nds.hxx"
  30. #pragma hdrstop
  31. // Class CNDSUser
  32. STDMETHODIMP
  33. CNDSUser::get_AccountDisabled(THIS_ VARIANT_BOOL FAR* retval)
  34. {
  35. GET_PROPERTY_VARIANT_BOOL((IADsUser *)this, AccountDisabled);
  36. }
  37. STDMETHODIMP
  38. CNDSUser::put_AccountDisabled(THIS_ VARIANT_BOOL fAccountDisabled)
  39. {
  40. PUT_PROPERTY_VARIANT_BOOL((IADsUser *)this, AccountDisabled);
  41. }
  42. STDMETHODIMP
  43. CNDSUser::get_AccountExpirationDate(THIS_ DATE FAR* retval)
  44. {
  45. GET_PROPERTY_DATE((IADsUser *)this, AccountExpirationDate);
  46. }
  47. STDMETHODIMP
  48. CNDSUser::put_AccountExpirationDate(THIS_ DATE daAccountExpirationDate)
  49. {
  50. PUT_PROPERTY_DATE((IADsUser *)this, AccountExpirationDate);
  51. }
  52. STDMETHODIMP
  53. CNDSUser::get_GraceLoginsAllowed(THIS_ long FAR* retval)
  54. {
  55. GET_PROPERTY_LONG((IADsUser *)this, GraceLoginsAllowed);
  56. }
  57. STDMETHODIMP
  58. CNDSUser::put_GraceLoginsAllowed(THIS_ long lGraceLoginsAllowed)
  59. {
  60. PUT_PROPERTY_LONG((IADsUser *)this, GraceLoginsAllowed);
  61. }
  62. STDMETHODIMP
  63. CNDSUser::get_GraceLoginsRemaining(THIS_ long FAR* retval)
  64. {
  65. GET_PROPERTY_LONG((IADsUser *)this, GraceLoginsRemaining);
  66. }
  67. STDMETHODIMP
  68. CNDSUser::put_GraceLoginsRemaining(THIS_ long lGraceLoginsRemaining)
  69. {
  70. PUT_PROPERTY_LONG((IADsUser *)this, GraceLoginsRemaining);
  71. }
  72. STDMETHODIMP
  73. CNDSUser::get_IsAccountLocked(THIS_ VARIANT_BOOL FAR* retval)
  74. {
  75. GET_PROPERTY_VARIANT_BOOL((IADsUser *)this, IsAccountLocked);
  76. }
  77. STDMETHODIMP
  78. CNDSUser::put_IsAccountLocked(THIS_ VARIANT_BOOL fIsAccountLocked)
  79. {
  80. PUT_PROPERTY_VARIANT_BOOL((IADsUser *)this, IsAccountLocked);
  81. }
  82. STDMETHODIMP
  83. CNDSUser::get_LoginHours(THIS_ VARIANT FAR* retval)
  84. {
  85. GET_PROPERTY_VARIANT((IADsUser *)this,LoginHours);
  86. }
  87. STDMETHODIMP
  88. CNDSUser::put_LoginHours(THIS_ VARIANT vLoginHours)
  89. {
  90. PUT_PROPERTY_VARIANT((IADsUser *)this,LoginHours);
  91. }
  92. STDMETHODIMP
  93. CNDSUser::get_LoginWorkstations(THIS_ VARIANT FAR* retval)
  94. {
  95. GET_PROPERTY_VARIANT((IADsUser *)this,LoginWorkstations);
  96. }
  97. STDMETHODIMP
  98. CNDSUser::put_LoginWorkstations(THIS_ VARIANT vLoginWorkstations)
  99. {
  100. PUT_PROPERTY_VARIANT((IADsUser *)this,LoginWorkstations);
  101. }
  102. STDMETHODIMP
  103. CNDSUser::get_MaxLogins(THIS_ long FAR* retval)
  104. {
  105. GET_PROPERTY_LONG((IADsUser *)this, MaxLogins);
  106. }
  107. STDMETHODIMP
  108. CNDSUser::put_MaxLogins(THIS_ long lMaxLogins)
  109. {
  110. PUT_PROPERTY_LONG((IADsUser *)this, MaxLogins);
  111. }
  112. STDMETHODIMP
  113. CNDSUser::get_MaxStorage(THIS_ long FAR* retval)
  114. {
  115. GET_PROPERTY_LONG((IADsUser *)this, MaxStorage);
  116. }
  117. STDMETHODIMP
  118. CNDSUser::put_MaxStorage(THIS_ long lMaxStorage)
  119. {
  120. PUT_PROPERTY_LONG((IADsUser *)this, MaxStorage);
  121. }
  122. STDMETHODIMP
  123. CNDSUser::get_PasswordExpirationDate(THIS_ DATE FAR* retval)
  124. {
  125. GET_PROPERTY_DATE((IADsUser *)this, PasswordExpirationDate);
  126. }
  127. STDMETHODIMP
  128. CNDSUser::put_PasswordExpirationDate(THIS_ DATE daPasswordExpirationDate)
  129. {
  130. PUT_PROPERTY_DATE((IADsUser *)this, PasswordExpirationDate);
  131. }
  132. STDMETHODIMP
  133. CNDSUser::get_PasswordRequired(THIS_ VARIANT_BOOL FAR* retval)
  134. {
  135. GET_PROPERTY_VARIANT_BOOL((IADsUser *)this, PasswordRequired);
  136. }
  137. STDMETHODIMP
  138. CNDSUser::put_PasswordRequired(THIS_ VARIANT_BOOL fPasswordRequired)
  139. {
  140. PUT_PROPERTY_VARIANT_BOOL((IADsUser *)this, PasswordRequired);
  141. }
  142. STDMETHODIMP
  143. CNDSUser::get_PasswordMinimumLength(THIS_ LONG FAR* retval)
  144. {
  145. GET_PROPERTY_LONG((IADsUser *)this, PasswordMinimumLength);
  146. }
  147. STDMETHODIMP
  148. CNDSUser::put_PasswordMinimumLength(THIS_ LONG lPasswordMinimumLength)
  149. {
  150. PUT_PROPERTY_LONG((IADsUser *)this, PasswordMinimumLength);
  151. }
  152. STDMETHODIMP
  153. CNDSUser::get_RequireUniquePassword(THIS_ VARIANT_BOOL FAR* retval)
  154. {
  155. GET_PROPERTY_VARIANT_BOOL((IADsUser *)this, RequireUniquePassword);
  156. }
  157. STDMETHODIMP
  158. CNDSUser::put_RequireUniquePassword(THIS_ VARIANT_BOOL fRequireUniquePassword)
  159. {
  160. PUT_PROPERTY_VARIANT_BOOL((IADsUser *)this, RequireUniquePassword);
  161. }
  162. STDMETHODIMP
  163. CNDSUser::ChangePassword(
  164. THIS_ BSTR bstrOldPassword,
  165. BSTR bstrNewPassword
  166. )
  167. {
  168. HRESULT hr = S_OK;
  169. BSTR bstrADsPath = NULL, bstrName = NULL;
  170. LPWSTR pszNDSTreeName = NULL, pszNDSDn = NULL;
  171. NDS_CONTEXT_HANDLE hADsContext = NULL;
  172. hr = _pADs->get_ADsPath(
  173. &bstrADsPath
  174. );
  175. BAIL_ON_FAILURE(hr);
  176. hr = _pADs->get_Name(
  177. &bstrName
  178. );
  179. BAIL_ON_FAILURE(hr);
  180. hr = BuildNDSPathFromADsPath2(
  181. bstrADsPath,
  182. &pszNDSTreeName,
  183. &pszNDSDn
  184. );
  185. BAIL_ON_FAILURE(hr);
  186. hr = ADsNdsOpenContext(
  187. pszNDSTreeName,
  188. _Credentials,
  189. &hADsContext
  190. );
  191. BAIL_ON_FAILURE(hr);
  192. hr = ADsNdsChangeObjectPassword(
  193. hADsContext,
  194. // bstrName,
  195. pszNDSDn,
  196. OT_USER,
  197. bstrOldPassword,
  198. bstrNewPassword
  199. );
  200. BAIL_ON_FAILURE(hr);
  201. error:
  202. if (hADsContext) {
  203. ADsNdsCloseContext(hADsContext);
  204. }
  205. if (bstrADsPath) {
  206. ADsFreeString(bstrADsPath);
  207. }
  208. if (bstrName) {
  209. ADsFreeString(bstrName);
  210. }
  211. FreeADsMem(pszNDSDn);
  212. FreeADsMem(pszNDSTreeName);
  213. RRETURN(hr);
  214. }
  215. STDMETHODIMP
  216. CNDSUser::SetPassword(THIS_ BSTR NewPassword)
  217. {
  218. HRESULT hr = S_OK;
  219. BSTR bstrADsPath = NULL, bstrName = NULL;
  220. LPWSTR pszNDSTreeName = NULL, pszNDSDn = NULL;
  221. NDS_CONTEXT_HANDLE hADsContext = NULL;
  222. hr = _pADs->get_ADsPath(
  223. &bstrADsPath
  224. );
  225. BAIL_ON_FAILURE(hr);
  226. hr = _pADs->get_Name(
  227. &bstrName
  228. );
  229. BAIL_ON_FAILURE(hr);
  230. hr = BuildNDSPathFromADsPath2(
  231. bstrADsPath,
  232. &pszNDSTreeName,
  233. &pszNDSDn
  234. );
  235. BAIL_ON_FAILURE(hr);
  236. hr = ADsNdsOpenContext(
  237. pszNDSTreeName,
  238. _Credentials,
  239. &hADsContext
  240. );
  241. BAIL_ON_FAILURE(hr);
  242. hr = ADsNdsChangeObjectPassword(
  243. hADsContext,
  244. // bstrName,
  245. pszNDSDn,
  246. OT_USER,
  247. NULL,
  248. NewPassword
  249. );
  250. BAIL_ON_FAILURE(hr);
  251. error:
  252. if (hADsContext) {
  253. ADsNdsCloseContext(hADsContext);
  254. }
  255. if (bstrADsPath) {
  256. ADsFreeString(bstrADsPath);
  257. }
  258. if (bstrName) {
  259. ADsFreeString(bstrName);
  260. }
  261. FreeADsMem(pszNDSDn);
  262. FreeADsMem(pszNDSTreeName);
  263. RRETURN(hr);
  264. }