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.

107 lines
4.0 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. #include <string>
  20. #include <map>
  21. #import "VarSet.tlb" no_namespace rename("property", "aproperty")
  22. #import "MsPwdMig.tlb" no_namespace
  23. typedef std::basic_string<WCHAR> tstring;
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CSetPassword
  26. class ATL_NO_VTABLE CSetPassword :
  27. public CComObjectRootEx<CComMultiThreadModel>,
  28. public CComCoClass<CSetPassword, &CLSID_SetPassword>,
  29. public IDispatchImpl<IExtendAccountMigration, &IID_IExtendAccountMigration, &LIBID_SETTARGETPASSWORDLib>
  30. {
  31. public:
  32. CSetPassword() : m_bTriedToOpenFile(false)
  33. {
  34. m_sName = L"Set Target Password";
  35. m_sDesc = L"Sets the target password and other related options.";
  36. m_Sequence = AREXT_LATER_SEQUENCE_NUMBER;
  37. m_bEstablishedSession = false;
  38. m_bUCCPFlagSet = false;
  39. m_bUMCPNLFlagSet = false;
  40. m_bPNEFlagSet = false;
  41. m_pTgtCrypt = NULL;
  42. m_sUndoneUsers = L",";
  43. m_lPwdHistoryLength = -1;
  44. }
  45. ~CSetPassword()
  46. {
  47. mUCCPMap.clear();
  48. mMigTimeMap.clear();
  49. m_passwordLog.LogClose();
  50. delete m_pTgtCrypt;
  51. }
  52. DECLARE_REGISTRY_RESOURCEID(IDR_SETPASSWORD)
  53. DECLARE_PROTECT_FINAL_CONSTRUCT()
  54. BEGIN_COM_MAP(CSetPassword)
  55. COM_INTERFACE_ENTRY(IExtendAccountMigration)
  56. COM_INTERFACE_ENTRY(IDispatch)
  57. END_COM_MAP()
  58. // IExtendAccountMigration
  59. public:
  60. STDMETHOD(ProcessUndo)(/*[in]*/ IUnknown * pSource, /*[in]*/ IUnknown * pTarget, /*[in]*/ IUnknown * pMainSettings, /*[in, out]*/ IUnknown ** pPropToSet);
  61. STDMETHOD(PreProcessObject)(/*[in]*/ IUnknown * pSource, /*[in]*/ IUnknown * pTarget, /*[in]*/ IUnknown * pMainSettings, /*[in,out]*/ IUnknown ** ppPropsToSet);
  62. STDMETHOD(ProcessObject)(/*[in]*/ IUnknown * pSource, /*[in]*/ IUnknown * pTarget, /*[in]*/ IUnknown * pMainSettings, /*[in,out]*/ IUnknown ** ppPropsToSet);
  63. STDMETHOD(get_sDesc)(/*[out, retval]*/ BSTR *pVal);
  64. STDMETHOD(put_sDesc)(/*[in]*/ BSTR newVal);
  65. STDMETHOD(get_sName)(/*[out, retval]*/ BSTR *pVal);
  66. STDMETHOD(put_sName)(/*[in]*/ BSTR newVal);
  67. STDMETHOD(get_SequenceNumber)(/*[out, retval]*/ LONG * value) { (*value) = m_Sequence; return S_OK; }
  68. private:
  69. _bstr_t m_sDesc;
  70. _bstr_t m_sName;
  71. CommaDelimitedLog m_passwordLog; //Password file
  72. bool m_bTriedToOpenFile;
  73. long m_Sequence;
  74. bool m_bEstablishedSession;
  75. CTargetCrypt * m_pTgtCrypt;
  76. bool m_bUCCPFlagSet;
  77. bool m_bUMCPNLFlagSet;
  78. bool m_bPNEFlagSet;
  79. long m_lPwdHistoryLength;
  80. typedef std::map<tstring,bool> CUCCPMap;
  81. CUCCPMap mUCCPMap;
  82. typedef std::map<tstring,_variant_t> CMigTimeMap;
  83. CMigTimeMap mMigTimeMap;
  84. _bstr_t m_sUndoneUsers;
  85. IPasswordMigrationPtr m_pPwdMig;
  86. BOOL GetDirectory(WCHAR* filename);
  87. bool IsValidPassword(LPCWSTR pwszPassword);
  88. HRESULT CopyPassword(_bstr_t srcServer, _bstr_t tgtServer, _bstr_t srcName, _bstr_t tgtName, _bstr_t password);
  89. void SetUserMustChangePwdFlag(IUnknown *pTarget);
  90. void RecordPwdFlags(LPCWSTR pwszMach, LPCWSTR pwszUser);
  91. void ResetPwdFlags(IUnknown *pTarget, LPCWSTR pwszMach, LPCWSTR pwszUser);
  92. void ClearUserCanChangePwdFlag(LPCWSTR pwszMach, LPCWSTR pwszUser);
  93. BOOL CanCopyPassword(IVarSet * pVarSet, LPCWSTR pwszMach, LPCWSTR pwszUser);
  94. };
  95. #endif //__SETPASSWORD_H_