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.

106 lines
4.4 KiB

  1. //---------------------------------------------------------------------------
  2. // SetPass.h
  3. //
  4. // Comment: This is a COM object extension for the MCS DCTAccountReplicator.
  5. // This object implements the IExtendAccountMigration interface.
  6. // The process method of this object sets the password for the
  7. // target account according to the users specification.
  8. //
  9. // (c) Copyright 1995-1998, Mission Critical Software, Inc., All Rights Reserved
  10. //
  11. // Proprietary and confidential to Mission Critical Software, Inc.
  12. //---------------------------------------------------------------------------
  13. #ifndef __SETPASSWORD_H_
  14. #define __SETPASSWORD_H_
  15. #include "resource.h" // main symbols
  16. #include "CommaLog.hpp"
  17. #include "ExtSeq.h"
  18. #include "ADMTCrypt.h"
  19. #import "VarSet.tlb" no_namespace rename("property", "aproperty")
  20. #import "MsPwdMig.tlb" no_namespace
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CSetPassword
  23. class ATL_NO_VTABLE CSetPassword :
  24. public CComObjectRootEx<CComMultiThreadModel>,
  25. public CComCoClass<CSetPassword, &CLSID_SetPassword>,
  26. public IDispatchImpl<IExtendAccountMigration, &IID_IExtendAccountMigration, &LIBID_SETTARGETPASSWORDLib>
  27. {
  28. public:
  29. CSetPassword() : m_bTriedToOpenFile(false)
  30. {
  31. m_sName = L"Set Target Password";
  32. m_sDesc = L"Sets the target password and other related options.";
  33. m_Sequence = AREXT_LATER_SEQUENCE_NUMBER;
  34. m_bEstablishedSession = false;
  35. m_bUCCPFlagSet = false;
  36. m_bUMCPNLFlagSet = false;
  37. m_bPNEFlagSet = false;
  38. m_pTgtCrypt = NULL;
  39. m_sUndoneUsers = L",";
  40. m_lPwdHistoryLength = -1;
  41. m_nPasswordServerVersion = 0;
  42. }
  43. ~CSetPassword()
  44. {
  45. mUCCPMap.RemoveAll();
  46. mMigTimeMap.RemoveAll();
  47. m_passwordLog.LogClose();
  48. delete m_pTgtCrypt;
  49. }
  50. DECLARE_REGISTRY_RESOURCEID(IDR_SETPASSWORD)
  51. DECLARE_PROTECT_FINAL_CONSTRUCT()
  52. BEGIN_COM_MAP(CSetPassword)
  53. COM_INTERFACE_ENTRY(IExtendAccountMigration)
  54. COM_INTERFACE_ENTRY(IDispatch)
  55. END_COM_MAP()
  56. // IExtendAccountMigration
  57. public:
  58. STDMETHOD(ProcessUndo)(/*[in]*/ IUnknown * pSource, /*[in]*/ IUnknown * pTarget, /*[in]*/ IUnknown * pMainSettings, /*[in, out]*/ IUnknown ** pPropToSet, /*[in,out]*/ EAMAccountStats* pStats);
  59. STDMETHOD(PreProcessObject)(/*[in]*/ IUnknown * pSource, /*[in]*/ IUnknown * pTarget, /*[in]*/ IUnknown * pMainSettings, /*[in,out]*/ IUnknown ** ppPropsToSet, /*[in,out]*/ EAMAccountStats* pStats);
  60. STDMETHOD(ProcessObject)(/*[in]*/ IUnknown * pSource, /*[in]*/ IUnknown * pTarget, /*[in]*/ IUnknown * pMainSettings, /*[in,out]*/ IUnknown ** ppPropsToSet, /*[in,out]*/ EAMAccountStats* pStats);
  61. STDMETHOD(get_sDesc)(/*[out, retval]*/ BSTR *pVal);
  62. STDMETHOD(put_sDesc)(/*[in]*/ BSTR newVal);
  63. STDMETHOD(get_sName)(/*[out, retval]*/ BSTR *pVal);
  64. STDMETHOD(put_sName)(/*[in]*/ BSTR newVal);
  65. STDMETHOD(get_SequenceNumber)(/*[out, retval]*/ LONG * value) { (*value) = m_Sequence; return S_OK; }
  66. private:
  67. _bstr_t m_sDesc;
  68. _bstr_t m_sName;
  69. CPasswordLog m_passwordLog; //Password file
  70. bool m_bTriedToOpenFile;
  71. long m_Sequence;
  72. bool m_bEstablishedSession;
  73. CTargetCrypt * m_pTgtCrypt;
  74. bool m_bUCCPFlagSet;
  75. bool m_bUMCPNLFlagSet;
  76. bool m_bPNEFlagSet;
  77. long m_lPwdHistoryLength;
  78. int m_nPasswordServerVersion;
  79. CMapStringToString mUCCPMap;
  80. CMapStringToString mMigTimeMap;
  81. _bstr_t m_sUndoneUsers;
  82. IPasswordMigrationPtr m_pPwdMig;
  83. BOOL GetDirectory(WCHAR* filename);
  84. bool IsValidPassword(LPCWSTR pwszPassword);
  85. HRESULT CopyPassword(_bstr_t srcServer, _bstr_t tgtServer, _bstr_t srcName, _bstr_t tgtName, _bstr_t password, EAMAccountStats* pStats);
  86. void SetUserMustChangePwdFlag(IUnknown *pTarget);
  87. void RecordPwdFlags(LPCWSTR pwszMach, LPCWSTR pwszUser);
  88. void ResetPwdFlags(IUnknown *pTarget, LPCWSTR pwszMach, LPCWSTR pwszUser);
  89. void ClearUserCanChangePwdFlag(LPCWSTR pwszMach, LPCWSTR pwszUser);
  90. BOOL CanCopyPassword(IVarSet * pVarSet, LPCWSTR pwszMach, LPCWSTR pwszUser, UINT& uMsgId);
  91. void MarkAccountError(IVarSet* pVarSet);
  92. };
  93. #endif //__SETPASSWORD_H_