コード例 #1
0
 protected override void InternalProcessRecord()
 {
     base.InternalProcessRecord();
     try
     {
         Server server = LocalServer.GetServer();
         PublicFolderDatabase[] e14SP1PublicFolderDatabases = this.GetE14SP1PublicFolderDatabases();
         if (e14SP1PublicFolderDatabases == null)
         {
             base.WriteVerbose(Strings.InstallFreeBusyFolderNoPublicFolderDatabase);
         }
         else if (!this.HasPublicFolderDatabase(server, e14SP1PublicFolderDatabases))
         {
             base.WriteVerbose(Strings.InstallFreeBusyFolderNoPublicFolderDatabase);
         }
         else
         {
             this.EnsureExternalFreeBusyFolder(server, e14SP1PublicFolderDatabases);
         }
     }
     catch (LocalizedException exception)
     {
         base.WriteVerbose(Strings.InstallFreeBusyFolderGeneralFailure(this.GetExceptionString(exception)));
     }
 }
コード例 #2
0
 internal static void EnsureRunningOnTargetServer(Task task, Server targetServer)
 {
     if (!targetServer.Id.Equals(LocalServer.GetServer().Id))
     {
         task.WriteError(new InvalidOperationException(Strings.CannotManipulateAlternateServiceAccountsRemotely(LocalServer.GetServer().Fqdn, targetServer.Fqdn)), ErrorCategory.InvalidOperation, targetServer.Identity);
     }
 }
コード例 #3
0
        // Token: 0x0600003F RID: 63 RVA: 0x000027AC File Offset: 0x000009AC
        public void EnsureLocalMailbox(ADUser user, bool forceRefresh)
        {
            AnchorUtil.ThrowOnNullArgument(user, "user");
            string mailboxServerFqdn = this.GetMailboxServerFqdn(user, forceRefresh);

            if (!string.Equals(mailboxServerFqdn, LocalServer.GetServer().Fqdn, StringComparison.OrdinalIgnoreCase))
            {
                throw new AnchorMailboxNotFoundOnServerException(mailboxServerFqdn, LocalServer.GetServer().Fqdn, user.DistinguishedName);
            }
        }
コード例 #4
0
        public Server GetLocalServer()
        {
            Server localServer = null;

            this.DoAdCallAndTranslateExceptions(delegate
            {
                localServer = LocalServer.GetServer();
            }, "DirectoryAccessor::GetLocalServer");
            return(localServer);
        }
コード例 #5
0
        protected T CallClientFunction <T>(Func <ILoadBalanceService, T> func)
        {
            Server server = LocalServer.GetServer();
            T      result;

            using (LoadBalancerClient loadBalancerClient = LoadBalancerClient.Create(server.Name, NullDirectory.Instance, this.logger))
            {
                this.logger.Log(MigrationEventType.Verbose, "Making WCF call to load balancer", new object[0]);
                result = func(loadBalancerClient);
            }
            return(result);
        }
コード例 #6
0
        private MailboxSession OpenSystemMailbox()
        {
            MrsTracer.Provider.Function("StorageMailbox.OpenSystemMailbox", new object[0]);
            base.CheckDisposed();
            Server          server          = LocalServer.GetServer();
            ADSystemMailbox adsystemMailbox = MapiUtils.GetADSystemMailbox(base.MdbGuid, null, null);
            MailboxSession  result;

            using (base.RHTracker.Start())
            {
                ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADSystemMailbox(ADSessionSettings.FromRootOrgScopeSet(), adsystemMailbox, server);
                result = MailboxSession.OpenAsSystemService(mailboxOwner, CultureInfo.InvariantCulture, "Client=MSExchangeMigration");
            }
            return(result);
        }
コード例 #7
0
        private static QueryFilter GetOrganizationMailboxQueryFilterForLocalServer()
        {
            Server server = LocalServer.GetServer();

            Database[] databases = server.GetDatabases();
            if (databases.Length > 0)
            {
                QueryFilter[] array = new QueryFilter[databases.Length];
                for (int i = 0; i < databases.Length; i++)
                {
                    array[i] = new ComparisonFilter(ComparisonOperator.Equal, ADMailboxRecipientSchema.Database, databases[i].Id);
                }
                return(QueryFilter.OrTogether(array));
            }
            return(new ComparisonFilter(ComparisonOperator.Equal, ADMailboxRecipientSchema.ServerName, server.Name));
        }
コード例 #8
0
        static PFRuleEvaluationContext()
        {
            string fqdn = LocalServer.GetServer().Fqdn;

            PFRuleEvaluationContext.localServerFqdn = fqdn;
            try
            {
                IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
                PFRuleEvaluationContext.localServerNetworkAddress = hostEntry.AddressList[0];
            }
            catch (SocketException ex)
            {
                ExTraceGlobals.SessionTracer.TraceError <string>(0L, "Start failed: {0}", ex.ToString());
                StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_PFRuleConfigGetLocalIPFailure, null, new object[]
                {
                    ex
                });
                throw new InvalidRuleException(ex.Message, ex);
            }
        }
コード例 #9
0
        // Token: 0x0600015E RID: 350 RVA: 0x00006CCC File Offset: 0x00004ECC
        private ADSystemAttendantMailbox GetSystemAttendant()
        {
            string            text = LocalServer.GetServer().ExchangeLegacyDN + "/cn=Microsoft System Attendant";
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 571, "GetSystemAttendant", "f:\\15.00.1497\\sources\\dev\\assistants\\src\\Assistants\\DatabaseInfo.cs");
            ADRecipient       adrecipient = null;

            try
            {
                adrecipient = tenantOrRootOrgRecipientSession.FindByLegacyExchangeDN(text);
            }
            catch (DataValidationException arg)
            {
                ExTraceGlobals.DatabaseInfoTracer.TraceError <DataValidationException>((long)this.GetHashCode(), "{0}: Invalid system attendant mailbox: {1}", arg);
            }
            if (adrecipient == null || !(adrecipient is ADSystemAttendantMailbox))
            {
                ExTraceGlobals.DatabaseInfoTracer.TraceError <DatabaseInfo, string>((long)this.GetHashCode(), "{0}: Unable to find valid SA mailbox with legDN: {1}", this, text);
                return(null);
            }
            return((ADSystemAttendantMailbox)adrecipient);
        }
コード例 #10
0
 // Token: 0x0600081C RID: 2076 RVA: 0x00021544 File Offset: 0x0001F744
 private void CheckDownLevelServerForest()
 {
     if (!HttpProxyBackEndHelper.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Cafe.NoCrossForestServerLocate.Enabled)
     {
         return;
     }
     if (MailboxServerLocator.InjectRemoteForestDownLevelServerException.Value)
     {
         throw new RemoteForestDownLevelServerException(this.DatabaseGuid.ToString(), this.ResourceForestFqdn);
     }
     if (this.masterServer.VersionNumber >= Server.E15MinVersion)
     {
         return;
     }
     if (string.Equals(LocalServer.GetServer().Id.DomainId.DistinguishedName, this.masterServer.Id.DomainId.DistinguishedName, StringComparison.OrdinalIgnoreCase))
     {
         return;
     }
     this.Tracer.TraceWarning <Guid, string>((long)this.GetHashCode(), "[MailboxServerLocator.CheckDownLevelServerForest] Master server {1} for down level database {0} is not in local forest.", this.DatabaseGuid, this.masterServer.Fqdn);
     throw new RemoteForestDownLevelServerException(this.DatabaseGuid.ToString(), this.ResourceForestFqdn);
 }
コード例 #11
0
        // Token: 0x06000160 RID: 352 RVA: 0x00005AAC File Offset: 0x00003CAC
        protected ICollection <Guid> GetLocalActiveDatabases()
        {
            List <Guid> list = new List <Guid>();

            try
            {
                using (ExRpcAdmin exRpcAdmin = ExRpcAdmin.Create("Client=AnchorService", LocalServer.GetServer().Fqdn, null, null, null))
                {
                    MdbStatus[] array = exRpcAdmin.ListMdbStatus(true);
                    if (array != null)
                    {
                        foreach (MdbStatus mdbStatus in array)
                        {
                            if ((mdbStatus.Status & MdbStatusFlags.Online) != MdbStatusFlags.Offline && (mdbStatus.Status & MdbStatusFlags.InRecoverySG) == MdbStatusFlags.Offline)
                            {
                                list.Add(mdbStatus.MdbGuid);
                            }
                        }
                    }
                }
            }
            catch (MapiRetryableException ex)
            {
                base.Context.Logger.Log(MigrationEventType.Warning, "error when looking for local databases {0}", new object[]
                {
                    ex
                });
                throw new MigrationLocalDatabasesNotFoundException(ex);
            }
            catch (MapiPermanentException ex2)
            {
                base.Context.Logger.Log(MigrationEventType.Error, "error when looking for local databases {0}", new object[]
                {
                    ex2
                });
                throw new MigrationLocalDatabasesNotFoundException(ex2);
            }
            return(list);
        }
コード例 #12
0
        // Token: 0x06000154 RID: 340 RVA: 0x000067F4 File Offset: 0x000049F4
        private void Initialize(Guid guid, string databaseName, string databaseLegacyDN, bool isPublic)
        {
            this.guid = guid;
            this.systemMailboxName = "SystemMailbox{" + this.guid + "}";
            this.databaseName      = databaseName;
            this.isPublic          = isPublic;
            this.displayName       = string.Concat(new object[]
            {
                this.databaseName,
                " (",
                this.guid,
                ")"
            });
            Exception ex = null;

            if (!this.isPublic)
            {
                try
                {
                    this.systemMailboxPrincipal = ExchangePrincipal.FromADSystemMailbox(ADSessionSettings.FromRootOrgScopeSet(), this.FindSystemMailbox(), LocalServer.GetServer());
                }
                catch (DataValidationException ex2)
                {
                    ex = ex2;
                }
                catch (ObjectNotFoundException ex3)
                {
                    ex = ex3;
                }
                catch (ADExternalException ex4)
                {
                    ex = ex4;
                }
                if (ex != null)
                {
                    ExTraceGlobals.DatabaseInfoTracer.TraceError <DatabaseInfo, Exception>((long)this.GetHashCode(), "{0}: Unable to find valid system mailbox. Exception: {1}", this, ex);
                    throw new MissingSystemMailboxException(this.DisplayName, ex, base.Logger);
                }
                Guid guid2 = Guid.Empty;
                try
                {
                    ADSystemAttendantMailbox systemAttendant = this.GetSystemAttendant();
                    if (systemAttendant != null && systemAttendant.Database != null)
                    {
                        guid2 = systemAttendant.Database.ObjectGuid;
                        this.systemAttendantMailboxGuid = ((systemAttendant.ExchangeGuid == Guid.Empty) ? systemAttendant.Guid : systemAttendant.ExchangeGuid);
                        ExTraceGlobals.DatabaseInfoTracer.TraceDebug <DatabaseInfo, Guid, Guid>((long)this.GetHashCode(), "{0}: System Attendant Mailbox: Database GUID: {1}, Mailbox GUID: {2}", this, guid2, this.systemAttendantMailboxGuid);
                    }
                }
                catch (DataValidationException ex5)
                {
                    ex = ex5;
                }
                catch (ObjectNotFoundException ex6)
                {
                    ex = ex6;
                }
                if (ex != null)
                {
                    base.TracePfd("PFD AIS {0} {1}: System Attendant Mailbox: Database GUID: {2}, Mailbox GUID: {3}", new object[]
                    {
                        30551,
                        this,
                        ex
                    });
                    throw new MissingSystemMailboxException(this.DisplayName, ex, base.Logger);
                }
                this.systemAttendantMailboxPresent = (this.guid == guid2);
                ExTraceGlobals.DatabaseInfoTracer.TraceDebug <DatabaseInfo>((long)this.GetHashCode(), "{0}: Created database info", this);
            }
            base.TracePfd("PFD AIS {0} {1}: Created database info Sucessfully", new object[]
            {
                19287,
                this
            });
        }
コード例 #13
0
        private bool GetDbLocationInfoByRegistry(Guid databaseId, out DatabaseLocationInfo databaseLocationInfo)
        {
            databaseLocationInfo = null;
            if (this.m_key == null)
            {
                this.m_key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\ActiveManager\\TestOverride", RegistryKeyPermissionCheck.ReadSubTree);
                if (this.m_key == null)
                {
                    ExTraceGlobals.ActiveManagerClientTracer.TraceDebug((long)this.GetHashCode(), "GetServerForDatabase failed opening the registry override key!");
                    return(false);
                }
                ExTraceGlobals.ActiveManagerClientTracer.TraceDebug((long)this.GetHashCode(), "Found registry override entry");
            }
            object value = this.m_key.GetValue(databaseId.ToString());

            if (value == null)
            {
                return(false);
            }
            string text = value as string;

            if (text == null)
            {
                throw new ArgumentException("Registry override for active server should be a string-typed value", "regValue");
            }
            string[] array = text.Split(new char[]
            {
                '|'
            });
            int num = array.Length;

            if (num == 3)
            {
                databaseLocationInfo = new DatabaseLocationInfo(array[0], array[1], ActiveManagerUtil.GetServerSiteFromServer(LocalServer.GetServer()), new ServerVersion(int.Parse(array[2], CultureInfo.InvariantCulture)), false);
                return(true);
            }
            if (num != 9)
            {
                throw new ArgumentException("Registry override for active server should be in a \"<fqdn>|<legacyDN>|<version>|<lastMountedServerFqdn>|<lastMountedServerLegacyDN>|<databaseLegacyDN>|<mountedTime>|<serverVersion>|<isHA>\" format", "databaseId");
            }
            databaseLocationInfo = new DatabaseLocationInfo(array[0], array[1], array[2], array[3], array[4], array[1], string.Empty, false, false, string.IsNullOrEmpty(array[5]) ? Guid.Empty : new Guid(array[5]), DateTime.Parse(array[6]), null, ActiveManagerUtil.GetServerSiteFromServer(LocalServer.GetServer()), new ServerVersion(int.Parse(array[7], CultureInfo.InvariantCulture)), MailboxRelease.None, DatabaseLocationInfoResult.Success, bool.Parse(array[8]));
            return(true);
        }
コード例 #14
0
        protected sealed override void InternalProcessRecord()
        {
            TaskLogger.LogEnter(new object[]
            {
                this.DataObject
            });
            if (this.DataObject.MajorVersion != LocalServer.GetServer().MajorVersion)
            {
                base.WriteError(new CannotModifyCrossVersionObjectException(this.DataObject.Id.DistinguishedName), ErrorCategory.InvalidOperation, null);
                return;
            }
            ClientAccessServer clientAccessServer = new ClientAccessServer(this.DataObject);

            if (base.Fields.IsModified("ClientAccessArray"))
            {
                ClientAccessArray clientAccessArrayFromIdParameter = this.GetClientAccessArrayFromIdParameter();
                if (clientAccessArrayFromIdParameter == null)
                {
                    clientAccessServer.ClientAccessArray = null;
                }
                else
                {
                    if (clientAccessArrayFromIdParameter.IsPriorTo15ExchangeObjectVersion)
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorCannotSetToOldClientAccessArray(clientAccessArrayFromIdParameter.ExchangeVersion.ToString(), ClientAccessArray.MinimumSupportedExchangeObjectVersion.ToString())), ErrorCategory.InvalidOperation, this.Identity);
                        return;
                    }
                    clientAccessServer.ClientAccessArray = (ADObjectId)clientAccessArrayFromIdParameter.Identity;
                }
            }
            bool flag = false;
            ADServiceConnectionPoint adserviceConnectionPoint = null;
            ADObjectId childId = clientAccessServer.Id.GetChildId("Protocols").GetChildId("Autodiscover").GetChildId(clientAccessServer.Name);

            if (base.Fields.IsModified("AutoDiscoverServiceInternalUri") && this.AutoDiscoverServiceInternalUri == null && base.Fields.IsModified("AutoDiscoverSiteScope") && this.AutoDiscoverSiteScope == null)
            {
                adserviceConnectionPoint = new ADServiceConnectionPoint();
                adserviceConnectionPoint.SetId(childId);
                base.DataSession.Delete(adserviceConnectionPoint);
                ADObjectId  parent      = adserviceConnectionPoint.Id.Parent;
                ADContainer adcontainer = new ADContainer();
                adcontainer.SetId(parent);
                base.DataSession.Delete(adcontainer);
                flag = true;
            }
            else
            {
                adserviceConnectionPoint = ((IConfigurationSession)base.DataSession).Read <ADServiceConnectionPoint>(childId);
                if (adserviceConnectionPoint == null)
                {
                    adserviceConnectionPoint = new ADServiceConnectionPoint();
                    adserviceConnectionPoint.SetId(childId);
                    if (!base.Fields.IsModified("AutoDiscoverServiceInternalUri"))
                    {
                        string text = ComputerInformation.DnsFullyQualifiedDomainName;
                        if (string.IsNullOrEmpty(text))
                        {
                            text = ComputerInformation.DnsPhysicalHostName;
                        }
                        adserviceConnectionPoint.ServiceBindingInformation.Add("https://" + text + "/Autodiscover/Autodiscover.xml");
                    }
                    if (!base.Fields.IsModified("AutoDiscoverSiteScope"))
                    {
                        adserviceConnectionPoint.Keywords.Add("77378F46-2C66-4aa9-A6A6-3E7A48B19596");
                        string siteName = NativeHelpers.GetSiteName(false);
                        if (!string.IsNullOrEmpty(siteName))
                        {
                            adserviceConnectionPoint.Keywords.Add("Site=" + siteName);
                        }
                    }
                    adserviceConnectionPoint.ServiceDnsName   = ComputerInformation.DnsPhysicalHostName;
                    adserviceConnectionPoint.ServiceClassName = "ms-Exchange-AutoDiscover-Service";
                    flag = true;
                }
                if (base.Fields.IsModified("AutoDiscoverServiceInternalUri"))
                {
                    adserviceConnectionPoint.ServiceBindingInformation.Clear();
                    if (this.AutoDiscoverServiceInternalUri != null)
                    {
                        adserviceConnectionPoint.ServiceBindingInformation.Add(this.AutoDiscoverServiceInternalUri.ToString());
                    }
                    flag = true;
                }
                if (base.Fields.IsModified("AutoDiscoverSiteScope"))
                {
                    adserviceConnectionPoint.Keywords.Clear();
                    adserviceConnectionPoint.Keywords.Add("77378F46-2C66-4aa9-A6A6-3E7A48B19596");
                    if (this.AutoDiscoverSiteScope != null)
                    {
                        foreach (string str in this.AutoDiscoverSiteScope)
                        {
                            adserviceConnectionPoint.Keywords.Add("Site=" + str);
                        }
                    }
                    flag = true;
                }
                if (flag)
                {
                    ADObjectId parent2 = adserviceConnectionPoint.Id.Parent;
                    if (((IConfigurationSession)base.DataSession).Read <ADContainer>(parent2) == null)
                    {
                        ADContainer adcontainer2 = new ADContainer();
                        adcontainer2.SetId(parent2);
                        base.DataSession.Save(adcontainer2);
                    }
                    base.DataSession.Save(adserviceConnectionPoint);
                }
            }
            bool flag2 = false;

            if (this.CleanUpInvalidAlternateServiceAccountCredentials.ToBool() && this.alternateServiceAccountCredentialsToRemove.Count > 0)
            {
                foreach (AlternateServiceAccountCredential credential in this.alternateServiceAccountCredentialsToRemove)
                {
                    this.alternateServiceAccountConfiguration.RemoveCredential(credential);
                }
                flag2 = true;
            }
            if (this.RemoveAlternateServiceAccountCredentials.ToBool())
            {
                flag2 = this.alternateServiceAccountConfiguration.RemoveAllCredentials();
                flag2 = true;
            }
            if (this.AlternateServiceAccountCredential != null)
            {
                for (int i = this.AlternateServiceAccountCredential.Length - 1; i >= 0; i--)
                {
                    this.alternateServiceAccountConfiguration.AddCredential(this.AlternateServiceAccountCredential[i]);
                    flag2 = true;
                }
            }
            if (this.DataObject.ObjectState != ObjectState.Unchanged)
            {
                base.InternalProcessRecord();
            }
            else if (!flag && !flag2)
            {
                this.WriteWarning(Strings.WarningForceMessage);
            }
            TaskLogger.LogExit();
        }
コード例 #15
0
ファイル: PstMailbox.cs プロジェクト: YHZX2013/exchange_diff
 private void ValidateCodePageAndSetEncoding()
 {
     if (this.contentCodePage != null)
     {
         Exception ex = null;
         try
         {
             this.contentEncoding = Encoding.GetEncoding(this.contentCodePage.Value);
         }
         catch (ArgumentException ex2)
         {
             ex = ex2;
         }
         catch (NotSupportedException ex3)
         {
             ex = ex3;
         }
         if (ex != null)
         {
             throw new NotSupportedCodePagePermanentException(this.contentCodePage.Value, LocalServer.GetServer().Name);
         }
     }
 }
コード例 #16
0
 protected virtual IDirectoryProvider CreateDirectoryInstance()
 {
     return(new DirectoryProvider(this.ClientFactory, LocalServer.GetServer(), this.Settings, this.GetDirectoryListeners(), base.Logger, this));
 }