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.

106 lines
3.5 KiB

  1. //---------------------------------------------------------------------------
  2. // UPDTUPN.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 on this object updates the userPrincipalName
  7. // property on the user object.
  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 __UPDTUPN_H_
  14. #define __UPDTUPN_H_
  15. #include "resource.h" // main symbols
  16. #include "ExtSeq.h"
  17. #include <string>
  18. #include <map>
  19. typedef std::basic_string<WCHAR> tstring;
  20. //#import "\bin\McsVarSetMin.tlb" no_namespace
  21. #import "VarSet.tlb" no_namespace rename("property", "aproperty")
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CUpdtUPN
  24. class ATL_NO_VTABLE CUpdtUPN :
  25. public CComObjectRootEx<CComSingleThreadModel>,
  26. public CComCoClass<CUpdtUPN, &CLSID_UpdtUPN>,
  27. public IDispatchImpl<IExtendAccountMigration, &IID_IExtendAccountMigration, &LIBID_UPNUPDTLib>
  28. {
  29. public:
  30. CUpdtUPN()
  31. {
  32. m_sName = L"UpnUpdate";
  33. m_sDesc = L"";
  34. m_sUPNSuffix = L"";
  35. m_Sequence = AREXT_DEFAULT_SEQUENCE_NUMBER;
  36. }
  37. ~CUpdtUPN()
  38. {
  39. mUPNMap.clear();
  40. }
  41. DECLARE_REGISTRY_RESOURCEID(IDR_UPDTUPN)
  42. DECLARE_PROTECT_FINAL_CONSTRUCT()
  43. BEGIN_COM_MAP(CUpdtUPN)
  44. COM_INTERFACE_ENTRY(IExtendAccountMigration)
  45. COM_INTERFACE_ENTRY(IDispatch)
  46. END_COM_MAP()
  47. // IExtendAccountMigration
  48. public:
  49. STDMETHOD(ProcessUndo)(/*[in]*/ IUnknown * pSource, /*[in]*/ IUnknown * pTarget, /*[in]*/ IUnknown * pMainSettings, /*[in, out]*/ IUnknown ** pPropToSet);
  50. STDMETHOD(PreProcessObject)(/*[in]*/ IUnknown * pSource, /*[in]*/ IUnknown * pTarget, /*[in]*/ IUnknown * pMainSettings, /*[in,out]*/ IUnknown ** ppPropsToSet);
  51. STDMETHOD(ProcessObject)(/*[in]*/ IUnknown * pSource, /*[in]*/ IUnknown * pTarget, /*[in]*/ IUnknown * pMainSettings, /*[in,out]*/ IUnknown ** ppPropsToSet);
  52. STDMETHOD(get_sDesc)(/*[out, retval]*/ BSTR *pVal);
  53. STDMETHOD(put_sDesc)(/*[in]*/ BSTR newVal);
  54. STDMETHOD(get_sName)(/*[out, retval]*/ BSTR *pVal);
  55. STDMETHOD(put_sName)(/*[in]*/ BSTR newVal);
  56. STDMETHOD(get_SequenceNumber)(/*[out, retval]*/ LONG * value) { (*value) = m_Sequence; return S_OK; }
  57. private:
  58. //define a structure to hold the UPN name and whether it conflicted in the map below
  59. struct SUPNStruc {
  60. SUPNStruc() :
  61. bConflicted(false)
  62. {
  63. }
  64. SUPNStruc(const SUPNStruc& UPNData)
  65. {
  66. bConflicted = UPNData.bConflicted;
  67. sName = UPNData.sName;
  68. sOldName = UPNData.sOldName;
  69. }
  70. SUPNStruc& operator =(const SUPNStruc& UPNData)
  71. {
  72. bConflicted = UPNData.bConflicted;
  73. sName = UPNData.sName;
  74. sOldName = UPNData.sOldName;
  75. return *this;
  76. }
  77. bool bConflicted;
  78. tstring sName;
  79. tstring sOldName;
  80. };
  81. typedef std::map<tstring,SUPNStruc> CUPNMap;
  82. CUPNMap mUPNMap;
  83. bool RenamedWithPrefixSuffix(_bstr_t sSourceSam, _bstr_t sTargetSam, _bstr_t sPrefix, _bstr_t sSuffix);
  84. void GetUniqueUPN(_bstr_t& sUPN, IVarSetPtr pVs, bool bUsingSamName, _bstr_t sAdsPath);
  85. bool GetDefaultUPNSuffix(_bstr_t sDomainDNS, _bstr_t sTargetOU);
  86. _bstr_t GetUPNSuffix(_bstr_t sUPNName);
  87. _bstr_t ChangeUPNSuffix(_bstr_t sUPNName, _bstr_t sNewSuffix);
  88. _bstr_t m_sDesc;
  89. _bstr_t m_sName;
  90. _bstr_t m_sUPNSuffix;
  91. long m_Sequence;
  92. };
  93. #endif //__UPDTUPN_H_