protected override void InternalProcessRecord()
        {
            if (this.Data == null)
            {
                throw new ArgumentNullException("Data");
            }
            TaskLogger.LogEnter();
            this.directoryInfo = new DirectoryBindingInfo((NetworkCredential)this.Credential);
            DirectoryObjectCollection organizationalUnit = this.Data.OrganizationalUnit;

            organizationalUnit.AddRange(this.Data.ConfigurationUnit);
            OrganizationConfigurationTree organizationConfigurationTree = OrganizationMigrationManager.CalculateImportOrder(organizationalUnit);

            organizationConfigurationTree.WriteVerboseDelegate = new Task.TaskVerboseLoggingDelegate(base.WriteVerbose);
            organizationConfigurationTree.WriteErrorDelegate   = new Task.TaskErrorLoggingDelegate(base.WriteError);
            organizationConfigurationTree.WriteWarningDelegate = new Task.TaskWarningLoggingDelegate(this.WriteWarning);
            OrganizationMigrationManager.UpdateDirectoryObjectProperties(organizationalUnit, this.directoryInfo);
            OrganizationMigrationManager.Import(this.directoryInfo, organizationalUnit, organizationConfigurationTree, this.Data.SourceFqdn, this.directoryInfo.Credential.Domain, this.Data.RootOrgName, base.RootOrgContainerId.ToString(), this.Data.SourceADSite, this.site.Name);
            TaskLogger.LogExit();
        }
Exemple #2
0
        public static void Import(DirectoryBindingInfo directoryInfo, DirectoryObjectCollection exportedItems, OrganizationConfigurationTree tree, string sourcedomain, string targetdomain, string sourceOrg, string targetOrg, string sourceSiteName, string targetSiteName)
        {
            string[] array = sourcedomain.Split(new char[]
            {
                '.'
            });
            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 0; i < array.Length; i++)
            {
                stringBuilder.Append("DC=");
                stringBuilder.Append(array[i]);
                if (i != array.Length - 1)
                {
                    stringBuilder.Append(',');
                }
            }
            array = targetdomain.Split(new char[]
            {
                '.'
            });
            StringBuilder stringBuilder2 = new StringBuilder();

            for (int j = 0; j < array.Length; j++)
            {
                stringBuilder2.Append("DC=");
                stringBuilder2.Append(array[j]);
                if (j != array.Length - 1)
                {
                    stringBuilder2.Append(',');
                }
            }
            string text     = stringBuilder.ToString();
            string text2    = stringBuilder2.ToString();
            string oldValue = "CN=" + sourceOrg + ",CN=Microsoft Exchange,CN=Services,CN=Configuration," + text;
            string newValue = "CN=" + targetOrg + ",CN=Microsoft Exchange,CN=Services,CN=Configuration," + text2;

            if (string.Compare(sourceOrg, targetOrg) != 0)
            {
                tree.Replace(null, oldValue, newValue);
            }
            string text3 = "CN=" + sourceSiteName + ",CN=Sites,CN=Configuration," + text;
            string text4 = "CN=" + targetSiteName + ",CN=Sites,CN=Configuration," + text2;

            if (string.Compare(text3, text4) != 0)
            {
                tree.Replace(null, text3, text4);
            }
            tree.Replace(null, text, text2);
            tree.Replace(null, sourcedomain, targetdomain);
            tree.Import(null, directoryInfo);
            tree.UpdateDelayedProperties(null, directoryInfo);
        }