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.

298 lines
8.3 KiB

  1. // GetPropTestDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "GetPropTest.h"
  5. #include "GetPropTestDlg.h"
  6. #include <sddl.h>
  7. #include "ObjCopy.h"
  8. #import "\bin\AdsProp.tlb" no_namespace
  9. #import "C:\\bin\\mcsvarsetmin.tlb" no_namespace
  10. #import "c:\\bin\\mcsDctWorkerObjects.tlb" no_namespace
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CAboutDlg dialog used for App About
  18. class CAboutDlg : public CDialog
  19. {
  20. public:
  21. CAboutDlg();
  22. // Dialog Data
  23. //{{AFX_DATA(CAboutDlg)
  24. enum { IDD = IDD_ABOUTBOX };
  25. //}}AFX_DATA
  26. // ClassWizard generated virtual function overrides
  27. //{{AFX_VIRTUAL(CAboutDlg)
  28. protected:
  29. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  30. //}}AFX_VIRTUAL
  31. // Implementation
  32. protected:
  33. //{{AFX_MSG(CAboutDlg)
  34. //}}AFX_MSG
  35. DECLARE_MESSAGE_MAP()
  36. };
  37. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  38. {
  39. //{{AFX_DATA_INIT(CAboutDlg)
  40. //}}AFX_DATA_INIT
  41. }
  42. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CDialog::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CAboutDlg)
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  49. //{{AFX_MSG_MAP(CAboutDlg)
  50. // No message handlers
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CGetPropTestDlg dialog
  55. CGetPropTestDlg::CGetPropTestDlg(CWnd* pParent /*=NULL*/)
  56. : CDialog(CGetPropTestDlg::IDD, pParent)
  57. {
  58. //{{AFX_DATA_INIT(CGetPropTestDlg)
  59. m_strClass = _T("");
  60. m_strSource = _T("");
  61. m_strTarget = _T("");
  62. m_strTargetDomain = _T("");
  63. m_strSourceDomain = _T("");
  64. m_strCont = _T("");
  65. //}}AFX_DATA_INIT
  66. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  67. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  68. }
  69. void CGetPropTestDlg::DoDataExchange(CDataExchange* pDX)
  70. {
  71. CDialog::DoDataExchange(pDX);
  72. //{{AFX_DATA_MAP(CGetPropTestDlg)
  73. DDX_Text(pDX, IDC_EDIT_SOURCE, m_strSource);
  74. DDX_Text(pDX, IDC_EDIT_TARGET, m_strTarget);
  75. DDX_Text(pDX, IDC_EDIT4, m_strTargetDomain);
  76. DDX_Text(pDX, IDC_EDIT_SourceDomain, m_strSourceDomain);
  77. DDX_Text(pDX, IDC_EDIT_CONTAINER, m_strCont);
  78. //}}AFX_DATA_MAP
  79. }
  80. BEGIN_MESSAGE_MAP(CGetPropTestDlg, CDialog)
  81. //{{AFX_MSG_MAP(CGetPropTestDlg)
  82. ON_WM_SYSCOMMAND()
  83. ON_WM_PAINT()
  84. ON_WM_QUERYDRAGICON()
  85. //}}AFX_MSG_MAP
  86. END_MESSAGE_MAP()
  87. /////////////////////////////////////////////////////////////////////////////
  88. // CGetPropTestDlg message handlers
  89. BOOL CGetPropTestDlg::OnInitDialog()
  90. {
  91. CDialog::OnInitDialog();
  92. CoInitialize(NULL);
  93. // IDM_ABOUTBOX must be in the system command range.
  94. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  95. ASSERT(IDM_ABOUTBOX < 0xF000);
  96. CMenu* pSysMenu = GetSystemMenu(FALSE);
  97. if (pSysMenu != NULL)
  98. {
  99. CString strAboutMenu;
  100. strAboutMenu.LoadString(IDS_ABOUTBOX);
  101. if (!strAboutMenu.IsEmpty())
  102. {
  103. pSysMenu->AppendMenu(MF_SEPARATOR);
  104. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  105. }
  106. }
  107. // Set the icon for this dialog. The framework does this automatically
  108. // when the application's main window is not a dialog
  109. SetIcon(m_hIcon, TRUE); // Set big icon
  110. SetIcon(m_hIcon, FALSE); // Set small icon
  111. // TODO: Add extra initialization here
  112. m_strClass = L"LDAP://devblewerg/CN=Sham,cn=Users,dc=devblewerg, dc=com";
  113. m_strCont = L"LDAP://devblewerg/OU=ShamTest, dc=devblewerg,dc=com";
  114. m_strSource = L"CN=Banu,OU=ShamTest";
  115. m_strTarget = L"CN=XShamu123";
  116. m_strSourceDomain = L"devblewerg";
  117. m_strTargetDomain = L"devblewerg";
  118. UpdateData(FALSE);
  119. return TRUE; // return TRUE unless you set the focus to a control
  120. }
  121. void CGetPropTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
  122. {
  123. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  124. {
  125. CAboutDlg dlgAbout;
  126. dlgAbout.DoModal();
  127. }
  128. else
  129. {
  130. CDialog::OnSysCommand(nID, lParam);
  131. }
  132. }
  133. // If you add a minimize button to your dialog, you will need the code below
  134. // to draw the icon. For MFC applications using the document/view model,
  135. // this is automatically done for you by the framework.
  136. void CGetPropTestDlg::OnPaint()
  137. {
  138. if (IsIconic())
  139. {
  140. CPaintDC dc(this); // device context for painting
  141. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  142. // Center icon in client rectangle
  143. int cxIcon = GetSystemMetrics(SM_CXICON);
  144. int cyIcon = GetSystemMetrics(SM_CYICON);
  145. CRect rect;
  146. GetClientRect(&rect);
  147. int x = (rect.Width() - cxIcon + 1) / 2;
  148. int y = (rect.Height() - cyIcon + 1) / 2;
  149. // Draw the icon
  150. dc.DrawIcon(x, y, m_hIcon);
  151. }
  152. else
  153. {
  154. CDialog::OnPaint();
  155. }
  156. }
  157. void ConvertOctetToSid( VARIANT var, PSID& pSid )
  158. {
  159. void HUGEP *pArray;
  160. HRESULT hr = SafeArrayAccessData( V_ARRAY(&var), &pArray );
  161. if ( SUCCEEDED(hr) )
  162. pSid = (PSID)pArray;
  163. }
  164. // The system calls this to obtain the cursor to display while the user drags
  165. // the minimized window.
  166. HCURSOR CGetPropTestDlg::OnQueryDragIcon()
  167. {
  168. return (HCURSOR) m_hIcon;
  169. }
  170. void CGetPropTestDlg::OnOK()
  171. {
  172. UpdateData();
  173. IObjPropBuilderPtr pProp(__uuidof(ObjPropBuilder));
  174. IVarSetPtr pVarset(__uuidof(VarSet));
  175. IAcctReplPtr pAcctRepl(__uuidof(AcctRepl));
  176. IUnknown * pUnk;
  177. _variant_t varX;
  178. pVarset->QueryInterface(IID_IUnknown, (void **)&pUnk);
  179. // If you need to use the pUnk outside of the scope of pVarset then do an AddRef and release on it,
  180. HRESULT hr;
  181. //CObjCopy objCopy(m_strCont);
  182. //hr = objCopy.CopyObject(m_strSource, m_strSourceDomain, m_strTarget, m_strTargetDomain);
  183. varX = L"Yes";
  184. pVarset->put("AccountOptions.CopyUsers", varX);
  185. pVarset->put("AccountOptions.CopyComputers", varX);
  186. pVarset->put("AccountOptions.CopyGlobalGroups", varX);
  187. pVarset->put("AccountOptions.CopyLocalGroups", varX);
  188. pVarset->put("AccountOptions.ReplaceExistingAccounts", varX);
  189. // pVarset->put("AccountOptions.ReplaceExistingGroupMembers", varX);
  190. // pVarset->put("AccountOptions.RemoveExistingUserRights", varX);
  191. pVarset->put("AccountOptions.CopyOUs", varX);
  192. pVarset->put("AccountOptions.DisableSourceAccounts", varX);
  193. pVarset->put("AccountOptions.GenerateStrongPasswords", varX);
  194. pVarset->put("AccountOptions.AddSidHistory", varX);
  195. varX = L"mcsfox1";
  196. pVarset->put("Options.Credentials.Domain", varX);
  197. varX = L"";
  198. pVarset->put("Options.Credentials.Password", varX);
  199. varX = L"ChautSZ";
  200. pVarset->put("Options.Credentials.UserName", varX);
  201. varX = L"c:\\password.csv";
  202. pVarset->put("AccountOptions.PasswordFile", varX);
  203. varX = L"LDAP://devraptorw2k/OU=Hello,DC=devraptorw2k,Dc=com";
  204. pVarset->put("Options.OuPath", varX);
  205. varX = L"Hello-";
  206. pVarset->put("AccountOptions.Suffix", varX);
  207. // pVarset->put("AccountOptions.Prefix", varX);
  208. varX = L"No";
  209. pVarset->put("Options.NoChange", varX);
  210. varX = L"c:\\result.csv";
  211. pVarset->put("AccountOptions.CSVResultFile", varX);
  212. varX = L"c:\\AcctSrc.txt";
  213. // varX = L"c:\\NT4Source.txt";
  214. pVarset->put("Accounts.InputFile", varX);
  215. varX = L"devblewerg";
  216. // varX = L"MCSDEV";
  217. pVarset->put("Options.SourceDomain", varX);
  218. varX = L"devRaptorW2k";
  219. pVarset->put("Options.TargetDomain", varX);
  220. varX = L"\\\\whqblewerg1";
  221. // varX = L"MCSDEVEL";
  222. pVarset->put("Options.SourceEaServer", varX);
  223. varX = L"\\\\whqraptor";
  224. pVarset->put("Options.TargetEaServer", varX);
  225. varX = "c:\\DCTLogFile.txt";
  226. pVarset->put("Options.Logfile", varX);
  227. // varX = L"LDAP://Qamain5/CN=USERS,DC=devblewerg,DC=com";
  228. // varX = L"LDAP://devrdt1/CN=Users,DC=devrdt1,DC=devblewerg,DC=com";
  229. // varX = L"LDAP://devblewerg/OU=EvenMore,OU=more,ou=ShamTest,DC=devblewerg,DC=com";
  230. varX = L"OU=HELLO";
  231. pVarset->put("Options.OuPath", varX);
  232. varX.vt = VT_UI4;
  233. varX.lVal = 15;
  234. pVarset->put("Options.LogLevel", varX);
  235. hr = pAcctRepl->Process(pUnk);
  236. pUnk->Release();
  237. /*
  238. IObjPropBuilderPtr pProp(__uuidof(ObjPropBuilder));
  239. IVarSetPtr pVarset(__uuidof(VarSet));
  240. _variant_t vt;
  241. IUnknown * pUnk;
  242. pVarset->QueryInterface(IID_IUnknown, (void**) &pUnk);
  243. pVarset->put(L"Description", L"This is from the SetVarset function");
  244. vt = (long) ADSTYPE_CASE_IGNORE_STRING;
  245. pVarset->put(L"Description.Type", vt);
  246. pProp->SetPropertiesFromVarset(L"LDAP://devblewerg/CN=SZC200,CN=Users,DC=devblewerg,DC=com", L"devblewerg", pUnk, ADS_ATTR_UPDATE);
  247. pUnk->Release();
  248. */
  249. CDialog::OnOK();
  250. }