protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            TDataObject       dataObject        = this.DataObject;
            ADObjectId        parent            = dataObject.Id.Parent;
            ADSessionSettings adsessionSettings = ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(parent);

            if (!parent.Equals(ADSession.GetRootDomainNamingContext(adsessionSettings.GetAccountOrResourceForestFqdn())))
            {
                IDirectorySession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, adsessionSettings, 264, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\NewAdObjectTask.cs");
                tenantOrTopologyConfigurationSession.UseConfigNC = ((IDirectorySession)base.DataSession).UseConfigNC;
                ADRawEntry adrawEntry = tenantOrTopologyConfigurationSession.ReadADRawEntry(parent, new PropertyDefinition[]
                {
                    ADObjectSchema.ExchangeVersion,
                    ADObjectSchema.ObjectClass
                });
                if (adrawEntry == null)
                {
                    if (string.IsNullOrEmpty(base.DomainController))
                    {
                        TDataObject dataObject2 = this.DataObject;
                        base.WriteError(new TaskException(Strings.ErrorParentNotFound(dataObject2.Name, parent.ToString())), (ErrorCategory)1003, null);
                    }
                    else
                    {
                        TDataObject dataObject3 = this.DataObject;
                        base.WriteError(new TaskException(Strings.ErrorParentNotFoundOnDomainController(dataObject3.Name, base.DomainController, parent.ToString(), parent.DomainId.ToString())), (ErrorCategory)1003, null);
                    }
                }
                ExchangeObjectVersion        exchangeObjectVersion = (ExchangeObjectVersion)adrawEntry[ADObjectSchema.ExchangeVersion];
                MultiValuedProperty <string> multiValuedProperty   = (MultiValuedProperty <string>)adrawEntry[ADObjectSchema.ObjectClass];
                TDataObject dataObject4 = this.DataObject;
                if (dataObject4.ExchangeVersion.IsOlderThan(exchangeObjectVersion) && !multiValuedProperty.Contains(Organization.MostDerivedClass) && this.EnforceExchangeObjectVersion)
                {
                    TDataObject dataObject5 = this.DataObject;
                    string      name        = dataObject5.Name;
                    TDataObject dataObject6 = this.DataObject;
                    base.WriteError(new TaskException(Strings.ErrorParentHasNewerVersion(name, dataObject6.ExchangeVersion.ToString(), exchangeObjectVersion.ToString())), (ErrorCategory)1004, null);
                }
            }
            if (base.IsVerboseOn)
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetConfigurableObjectChangedProperties(this.DataObject));
            }
            base.InternalProcessRecord();
            TaskLogger.LogExit();
        }
        // Token: 0x06000EEA RID: 3818 RVA: 0x0002B5C8 File Offset: 0x000297C8
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (!typeof(T).IsAssignableFrom(typeof(ExtendedSecurityPrincipal)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            IEnumerable <T> result = ExtendedSecurityPrincipalSearchHelper.PerformSearch(new ExtendedSecurityPrincipalSearcher(this.FindObjects), (IConfigDataProvider)session, rootId, (this.IncludeDomainLocalFrom != null) ? this.IncludeDomainLocalFrom.Id : null, this.Types).Cast <T>();

            TaskLogger.LogExit();
            notFoundReason = null;
            return(result);
        }
Exemple #3
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            notFoundReason = null;
            List <T> list = new List <T>();

            try
            {
                if (typeof(T) != typeof(SystemMessage))
                {
                    throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
                }
                if (session == null)
                {
                    throw new ArgumentNullException("session");
                }
                if (string.IsNullOrEmpty(base.RawIdentity))
                {
                    throw new InvalidOperationException(Strings.ErrorOperationOnInvalidObject);
                }
                if (base.InternalADObjectId != null)
                {
                    return(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
                }
                ADObjectId adobjectId = rootId;
                foreach (string unescapedCommonName in this.relativeDnParts)
                {
                    adobjectId = adobjectId.GetChildId(unescapedCommonName);
                }
                if (optionalData != null && optionalData.AdditionalFilter != null)
                {
                    throw new NotSupportedException("Supplying Additional Filters without an ADObjectId is not currently supported by this IdParameter.");
                }
                IConfigurable configurable = ((IConfigDataProvider)session).Read <T>(adobjectId);
                if (configurable != null)
                {
                    list.Add((T)((object)configurable));
                }
            }
            finally
            {
                TaskLogger.LogExit();
            }
            return(list);
        }
        // Token: 0x0600055B RID: 1371 RVA: 0x00014950 File Offset: 0x00012B50
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            if (this.Identity == null)
            {
                base.WriteError(new ArgumentNullException("Identity"), (ErrorCategory)1000, null);
            }
            else
            {
                this.dataObject = (TDataObject)((object)this.ResolveDataObject());
            }
            IVersionable versionable = this.dataObject as IVersionable;

            if (versionable != null && versionable.MaximumSupportedExchangeObjectVersion.IsOlderThan(versionable.ExchangeVersion))
            {
                base.WriteError(new TaskException(Strings.ErrorRemoveNewerObject(this.dataObject.Identity.ToString(), versionable.ExchangeVersion.ExchangeBuild.ToString())), (ErrorCategory)1004, null);
            }
            TaskLogger.LogExit();
        }
        // Token: 0x06000337 RID: 823 RVA: 0x0000CA98 File Offset: 0x0000AC98
        public bool Match(Condition conditionToMatch)
        {
            TaskLogger.LogEnter(new object[]
            {
                this,
                conditionToMatch
            });
            if (conditionToMatch == null)
            {
                throw new ArgumentNullException("conditionToMatch");
            }
            bool result = false;

            if (base.GetType() != conditionToMatch.GetType())
            {
                TaskLogger.Trace(Strings.LogConditionMatchingTypeMismacth(base.GetType(), conditionToMatch.GetType()));
            }
            else
            {
                foreach (PropertyInfo propertyInfo in base.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
                {
                    object obj  = propertyInfo.GetGetMethod().Invoke(this, null);
                    object obj2 = propertyInfo.GetGetMethod().Invoke(conditionToMatch, null);
                    TaskLogger.Trace("{0}.{1}: {2} ?=? {3}", new object[]
                    {
                        base.GetType().FullName,
                        propertyInfo.Name,
                        obj,
                        obj2
                    });
                    if ((obj != null || obj2 != null) && (obj == null || !obj.Equals(obj2)))
                    {
                        TaskLogger.Trace(Strings.LogConditionMatchingPropertyMismatch(base.GetType(), propertyInfo.Name, obj, obj2));
                        goto IL_106;
                    }
                }
                result = true;
            }
IL_106:
            TaskLogger.LogExit();
            return(result);
        }
        // Token: 0x06000C7A RID: 3194 RVA: 0x00027404 File Offset: 0x00025604
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (!(session is IConfigurationSession))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(session.GetType().Name), "type");
            }
            notFoundReason = null;
            EnumerableWrapper <T> result = EnumerableWrapper <T> .Empty;

            if (this.IsWildcardDefined(base.RawIdentity))
            {
                notFoundReason = new LocalizedString?(Strings.ErrorOrganizationWildcard);
                return(result);
            }
            OrganizationId organizationId = this.ResolveOrganizationId();

            if (!OrganizationId.ForestWideOrgId.Equals(organizationId))
            {
                ADSessionSettings adsessionSettings = ADSessionSettings.FromCustomScopeSet(ScopeSet.ResolveUnderScope(organizationId, session.SessionSettings.ScopeSet), session.SessionSettings.RootOrgId, organizationId, session.SessionSettings.ExecutingUserOrganizationId, false);
                adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
                ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(session.DomainController, session.ReadOnly, session.ConsistencyMode, session.NetworkCredential, adsessionSettings, 257, "GetObjects", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\IdentityParameter\\TenantRelocationRequestIdParameter.cs");
                tenantConfigurationSession.UseConfigNC      = session.UseConfigNC;
                tenantConfigurationSession.UseGlobalCatalog = session.UseGlobalCatalog;
                if (typeof(TenantRelocationRequest).Equals(typeof(T)) && organizationId.ConfigurationUnit != null)
                {
                    List <TenantRelocationRequest> list  = new List <TenantRelocationRequest>();
                    TenantRelocationRequest[]      array = tenantConfigurationSession.Find <TenantRelocationRequest>(organizationId.ConfigurationUnit, QueryScope.SubTree, TenantRelocationRequest.TenantRelocationRequestFilter, null, 1);
                    if (array != null && array.Length > 0)
                    {
                        list.Add(array[0]);
                        result = EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) list, this.GetEnumerableFilter <T>());
                    }
                }
            }
            TaskLogger.LogExit();
            return(result);
        }
        // Token: 0x06000977 RID: 2423 RVA: 0x000208F0 File Offset: 0x0001EAF0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            IEnumerable <T> enumerable = null;

            notFoundReason = null;
            if (typeof(T) != typeof(DetailsTemplate))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            try
            {
                if (base.InternalADObjectId != null)
                {
                    return(base.GetADObjectIdObjects <T>(base.InternalADObjectId, rootId, subTreeSession, optionalData));
                }
                ADObjectId  childId = ((IConfigurationSession)session).GetOrgContainerId().GetChildId("Addressing").GetChildId("Display-Templates");
                QueryFilter filter  = null;
                if (this.language != null)
                {
                    childId = childId.GetChildId(this.language.LCID.ToString("X"));
                }
                if (this.type != null)
                {
                    filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, this.type);
                }
                enumerable = base.PerformPrimarySearch <T>(filter, childId, session, true, optionalData);
                EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(enumerable);

                if (wrapper.HasElements())
                {
                    return(wrapper);
                }
                enumerable = base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason);
            }
            finally
            {
                TaskLogger.LogExit();
            }
            return(enumerable);
        }
Exemple #8
0
        protected virtual void WriteResult()
        {
            object[]    array      = new object[1];
            object[]    array2     = array;
            int         num        = 0;
            TDataObject dataObject = this.DataObject;

            array2[num] = dataObject.Identity;
            TaskLogger.LogEnter(array);
            TDataObject dataObject2 = this.DataObject;

            base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(dataObject2.Identity, base.DataSession, typeof(TDataObject)));
            IConfigurable configurable = null;

            try
            {
                using (TaskPerformanceData.ReadResult.StartRequestTimer())
                {
                    IConfigDataProvider dataSession = base.DataSession;
                    TDataObject         dataObject3 = this.DataObject;
                    configurable = dataSession.Read <TDataObject>(dataObject3.Identity);
                }
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
            }
            if (configurable == null)
            {
                TDataObject   dataObject4 = this.DataObject;
                Exception     exception   = new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(this.ResolveIdentityString(dataObject4.Identity), typeof(TDataObject).ToString(), (base.DataSession != null) ? base.DataSession.Source : null));
                ErrorCategory category    = (ErrorCategory)1003;
                TDataObject   dataObject5 = this.DataObject;
                base.WriteError(exception, category, dataObject5.Identity);
            }
            using (TaskPerformanceData.WriteResult.StartRequestTimer())
            {
                this.WriteResult(configurable);
            }
            TaskLogger.LogExit();
        }
Exemple #9
0
        // Token: 0x060005BD RID: 1469 RVA: 0x000159B4 File Offset: 0x00013BB4
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ADRecipient adrecipient = (ADRecipient)base.PrepareDataObject();

            if (adrecipient.IsChanged(ADRecipientSchema.PrimarySmtpAddress) && adrecipient.PrimarySmtpAddress != adrecipient.OriginalPrimarySmtpAddress && adrecipient.EmailAddressPolicyEnabled)
            {
                this.WriteWarning(Strings.WarningCannotSetPrimarySmtpAddressWhenEapEnabled);
            }
            if (RecipientTaskHelper.IsMailEnabledRecipientType(adrecipient.RecipientType) && !adrecipient.EmailAddressPolicyEnabled && adrecipient.WindowsEmailAddress != adrecipient.OriginalWindowsEmailAddress && adrecipient.PrimarySmtpAddress == adrecipient.OriginalPrimarySmtpAddress)
            {
                adrecipient.PrimarySmtpAddress = adrecipient.WindowsEmailAddress;
            }
            if (adrecipient.RecipientType == RecipientType.MailUser && (RecipientTypeDetails)adrecipient[ADRecipientSchema.RecipientTypeDetailsValue] == RecipientTypeDetails.None)
            {
                adrecipient.RecipientTypeDetails = RecipientTypeDetails.MailUser;
            }
            RecipientTaskHelper.RemoveEmptyValueFromEmailAddresses(adrecipient);
            TaskLogger.LogExit();
            return(adrecipient);
        }
        // Token: 0x060005D8 RID: 1496 RVA: 0x000163E4 File Offset: 0x000145E4
        protected override IConfigurable ResolveDataObject()
        {
            TaskLogger.LogEnter();
            IConfigurable[] array = null;
            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(TDataObject), this.InternalFilter, this.RootId, this.DeepSearch));
            try
            {
                array = base.DataSession.Find <TDataObject>(this.InternalFilter, this.RootId, this.DeepSearch, null);
            }
            catch (DataSourceTransientException exception)
            {
                base.WriteError(exception, (ErrorCategory)1002, null);
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
            }
            if (array == null)
            {
                array = new IConfigurable[0];
            }
            IConfigurable result = null;

            switch (array.Length)
            {
            case 0:
                base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(null, typeof(TDataObject).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, null);
                break;

            case 1:
                result = array[0];
                break;

            default:
                base.WriteError(new ManagementObjectAmbiguousException(Strings.ExceptionObjectAmbiguous(typeof(TDataObject).ToString())), (ErrorCategory)1003, null);
                break;
            }
            TaskLogger.LogExit();
            return(result);
        }
Exemple #11
0
 // Token: 0x060003DE RID: 990 RVA: 0x0000E678 File Offset: 0x0000C878
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.Identity
     });
     if (this.Identity != null && this.InternalIgnoreDefaultScope)
     {
         ADObjectId adobjectId;
         if (!RecipientTaskHelper.IsValidDistinguishedName(this.Identity, out adobjectId))
         {
             base.WriteError(new ArgumentException(Strings.ErrorOnlyDNSupportedWithIgnoreDefaultScope), (ErrorCategory)1000, this.Identity);
         }
         IConfigurable dataObject = RecipientTaskHelper.ResolveDataObject <TDataObject>(base.DataSession, null, base.ServerSettings, this.Identity, this.RootId, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <TDataObject>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
         this.WriteResult(dataObject);
     }
     else
     {
         base.InternalProcessRecord();
     }
     TaskLogger.LogExit();
 }
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            notFoundReason = null;
            IEnumerable <T> result = new List <T>();

            if (typeof(Database).IsAssignableFrom(typeof(T)) && !string.IsNullOrEmpty(base.RawIdentity))
            {
                LegacyDN legacyDN = null;
                if (LegacyDN.TryParse(base.RawIdentity, out legacyDN))
                {
                    QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, DatabaseSchema.ExchangeLegacyDN, base.RawIdentity);
                    result = base.PerformPrimarySearch <T>(filter, rootId, session, true, optionalData);
                }
            }
            else
            {
                result = base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason);
            }
            TaskLogger.LogExit();
            return(result);
        }
Exemple #13
0
        protected ManageService()
        {
            TaskLogger.LogEnter();
            InstallContext installContext = new InstallContext();

            installContext.Parameters["logtoconsole"] = "false";
            installContext.Parameters["assemblypath"] = base.GetType().Assembly.Location;
            this.serviceInstaller                = new ServiceInstaller();
            this.serviceInstaller.Context        = installContext;
            this.serviceInstaller.ServiceName    = this.Name;
            this.serviceInstaller.StartType      = ServiceStartMode.Manual;
            this.serviceProcessInstaller         = new ServiceProcessInstaller();
            this.serviceProcessInstaller.Context = installContext;
            this.serviceProcessInstaller.Account = ServiceAccount.NetworkService;
            this.serviceProcessInstaller.Installers.Add(this.serviceInstaller);
            this.ServicesDependedOn = new string[]
            {
                ManagedServiceName.ActiveDirectoryTopologyService
            };
            this.serviceFirewallRules = new List <ExchangeFirewallRule>(2);
            TaskLogger.LogExit();
        }
Exemple #14
0
 // Token: 0x06000596 RID: 1430 RVA: 0x00015494 File Offset: 0x00013694
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     if (!this.IsObjectStateChanged())
     {
         bool flag = false;
         if (!base.TryGetVariableValue <bool>("ExchangeDisableNotChangedWarning", out flag) || !flag)
         {
             TDataObject dataObject = this.DataObject;
             if (dataObject.Identity != null)
             {
                 TDataObject dataObject2 = this.DataObject;
                 this.WriteWarning(Strings.WarningForceMessageWithId(dataObject2.Identity.ToString()));
             }
             else
             {
                 this.WriteWarning(Strings.WarningForceMessage);
             }
         }
     }
     base.InternalProcessRecord();
     TaskLogger.LogExit();
 }
Exemple #15
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.DataObject
     });
     try
     {
         base.Validate(this.DataObject);
         if (base.HasErrors)
         {
             return;
         }
         TDataObject dataObject = this.DataObject;
         if (dataObject.Identity != null)
         {
             base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(this.DataObject, base.DataSession, typeof(TDataObject)));
         }
         using (TaskPerformanceData.SaveResult.StartRequestTimer())
         {
             base.DataSession.Save(this.DataObject);
         }
     }
     catch (DataSourceTransientException exception)
     {
         base.WriteError(exception, (ErrorCategory)1002, null);
     }
     finally
     {
         TDataObject dataObject2 = this.DataObject;
         if (dataObject2.Identity != null)
         {
             base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
         }
     }
     TaskLogger.LogExit();
 }
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            TDataObject tdataObject = (TDataObject)((object)base.PrepareDataObject());

            if (this.TemplateInstance != null)
            {
                TDataObject tdataObject2 = Activator.CreateInstance <TDataObject>();
                this.InitializeDataObject(tdataObject2);
                tdataObject2.ProvisionalClone(new PSObjectWrapper(this.TemplateInstance));
                tdataObject2.CopyChangesFrom(tdataObject);
                tdataObject = tdataObject2;
            }
            if (base.CurrentOrganizationId != null)
            {
                tdataObject.OrganizationId = base.CurrentOrganizationId;
            }
            else
            {
                tdataObject.OrganizationId = base.ExecutingUserOrganizationId;
            }
            TaskLogger.LogExit();
            return(tdataObject);
        }
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (!typeof(ADRecipient).IsAssignableFrom(typeof(T)) && !typeof(ReducedRecipient).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type");
            }
            if (Globals.IsConsumerOrganization(session.SessionSettings.CurrentOrganizationId) && ADSessionFactory.UseAggregateSession(session.SessionSettings))
            {
                return(ConsumerMailboxIdParameter.Parse(base.RawIdentity).GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            }
            EnumerableWrapper <T> enumerableWrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (!enumerableWrapper.HasElements() && session is IRecipientSession)
            {
                enumerableWrapper = base.GetEnumerableWrapper <T>(enumerableWrapper, this.GetObjectsByAccountName <T>(base.RawIdentity, rootId, (IRecipientSession)session, optionalData));
            }
            if (enumerableWrapper.HasUnfilteredElements() && !enumerableWrapper.HasElements())
            {
                notFoundReason = new LocalizedString?(this.GetErrorMessageForWrongType(this.ToString()));
            }
            TaskLogger.LogExit();
            return(enumerableWrapper);
        }
        // Token: 0x06000AFC RID: 2812 RVA: 0x00023724 File Offset: 0x00021924
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            TaskLogger.LogEnter();
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (!(session is IConfigurationSession))
            {
                throw new ArgumentException(Strings.ErrorInvalidType(session.GetType().Name), "session");
            }
            if (((typeof(T) == typeof(ADOrganizationalUnit) && session.UseConfigNC) || (typeof(T) == typeof(ExchangeConfigurationUnit) && !session.UseConfigNC)) && !Environment.StackTrace.Contains("Microsoft.Exchange.Management.Deployment.OrganizationTaskHelper.GetExchangeConfigUnitFromOrganizationId"))
            {
                throw new ArgumentException("Session is using the wrong Naming Context for the desired search");
            }
            notFoundReason = null;
            EnumerableWrapper <T> result = EnumerableWrapper <T> .Empty;

            if (base.IsMultitenancyEnabled())
            {
                if (this.IsWildcardDefined(base.RawIdentity))
                {
                    if (null == this.AccountPartition)
                    {
                        notFoundReason = new LocalizedString?(Strings.ErrorOrganizationWildcard);
                        return(result);
                    }
                    IEnumerable <ExchangeConfigurationUnit> configurationUnits = this.GetConfigurationUnits((IConfigurationSession)session, base.RawIdentity);
                    return(EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) configurationUnits, this.GetEnumerableFilter <T>()));
                }
                else
                {
                    OrganizationId organizationId = this.ResolveOrganizationId(session.SessionSettings.CurrentOrganizationId);
                    if (!OrganizationId.ForestWideOrgId.Equals(organizationId))
                    {
                        ADSessionSettings adsessionSettings = ADSessionSettings.FromCustomScopeSet(ScopeSet.ResolveUnderScope(organizationId, session.SessionSettings.ScopeSet), session.SessionSettings.RootOrgId, organizationId, session.SessionSettings.ExecutingUserOrganizationId, true);
                        adsessionSettings.TenantConsistencyMode = TenantConsistencyMode.IncludeRetiredTenants;
                        bool flag = TaskHelper.ShouldPassDomainControllerToSession(session.DomainController, adsessionSettings);
                        ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(flag ? session.DomainController : null, session.ReadOnly, session.ConsistencyMode, flag ? session.NetworkCredential : null, adsessionSettings, 314, "GetObjects", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\IdentityParameter\\organizationidparameter.cs");
                        tenantConfigurationSession.UseConfigNC      = session.UseConfigNC;
                        tenantConfigurationSession.UseGlobalCatalog = session.UseGlobalCatalog;
                        if (typeof(ExchangeConfigurationUnit) == typeof(T) && organizationId.ConfigurationUnit != null)
                        {
                            List <ExchangeConfigurationUnit> list = new List <ExchangeConfigurationUnit>();
                            ExchangeConfigurationUnit        exchangeConfigurationUnit = tenantConfigurationSession.Read <ExchangeConfigurationUnit>(organizationId.ConfigurationUnit);
                            if (exchangeConfigurationUnit != null)
                            {
                                list.Add(exchangeConfigurationUnit);
                                result = EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) list, this.GetEnumerableFilter <T>());
                            }
                        }
                        else if (organizationId.OrganizationalUnit != null)
                        {
                            List <ADOrganizationalUnit> list2 = new List <ADOrganizationalUnit>();
                            ADOrganizationalUnit        adorganizationalUnit = tenantConfigurationSession.Read <ADOrganizationalUnit>(organizationId.OrganizationalUnit);
                            if (adorganizationalUnit != null)
                            {
                                list2.Add(adorganizationalUnit);
                                result = EnumerableWrapper <T> .GetWrapper((IEnumerable <T>) list2, this.GetEnumerableFilter <T>());
                            }
                        }
                    }
                }
            }
            TaskLogger.LogExit();
            return(result);
        }
Exemple #19
0
        // Token: 0x060005C3 RID: 1475 RVA: 0x00015CAC File Offset: 0x00013EAC
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            OrganizationId currentOrganizationId = base.CurrentOrganizationId;
            TDataObject    dataObject            = this.DataObject;

            if (!currentOrganizationId.Equals(dataObject.OrganizationId))
            {
                this.CurrentOrgState = new LazilyInitialized <SharedTenantConfigurationState>(delegate()
                {
                    TDataObject dataObject17 = this.DataObject;
                    return(SharedConfiguration.GetSharedConfigurationState(dataObject17.OrganizationId));
                });
            }
            ADRecipient adrecipient = this.DataObject;
            bool        flag        = adrecipient != null && adrecipient.RecipientSoftDeletedStatus > 0;

            if (RecipientTaskHelper.IsMailEnabledRecipientType(this.DesiredRecipientType) && !flag)
            {
                if (!base.IsProvisioningLayerAvailable)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorNoProvisioningHandlerAvailable), (ErrorCategory)1001, null);
                }
                TDataObject dataObject2 = this.DataObject;
                if (dataObject2.IsModified(ADRecipientSchema.EmailAddresses))
                {
                    TDataObject dataObject3 = this.DataObject;
                    if (dataObject3.EmailAddresses.Count > 0)
                    {
                        if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && this.ShouldCheckAcceptedDomains())
                        {
                            IDirectorySession     configurationSession  = this.ConfigurationSession;
                            TDataObject           dataObject4           = this.DataObject;
                            IConfigurationSession configurationSession2 = (IConfigurationSession)TaskHelper.UnderscopeSessionToOrganization(configurationSession, dataObject4.OrganizationId, true);
                            IConfigurationSession cfgSession            = configurationSession2;
                            TDataObject           dataObject5           = this.DataObject;
                            RecipientTaskHelper.ValidateSmtpAddress(cfgSession, dataObject5.EmailAddresses, this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache);
                        }
                        ADObjectId        rootOrgContainerId = base.RootOrgContainerId;
                        TDataObject       dataObject6        = this.DataObject;
                        ADSessionSettings sessionSettings    = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(rootOrgContainerId, dataObject6.OrganizationId, base.ExecutingUserOrganizationId, false);
                        IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, string.IsNullOrEmpty(base.DomainController) ? null : base.NetCredential, sessionSettings, 557, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\SetAdObjectTask.cs");
                        IRecipientSession tenantCatalogSession            = tenantOrRootOrgRecipientSession;
                        TDataObject       dataObject7 = this.DataObject;
                        RecipientTaskHelper.ValidateEmailAddressErrorOut(tenantCatalogSession, dataObject7.EmailAddresses, this.DataObject, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerReThrowDelegate(this.WriteError));
                    }
                }
            }
            TDataObject dataObject8 = this.DataObject;

            if (dataObject8.IsChanged(ADObjectSchema.Id))
            {
                IDirectorySession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, base.OrgWideSessionSettings, ConfigScopes.TenantSubTree, 579, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\SetAdObjectTask.cs");
                tenantOrTopologyConfigurationSession.UseConfigNC = ((IDirectorySession)base.DataSession).UseConfigNC;
                TDataObject dataObject9 = this.DataObject;
                ADObjectId  parent      = dataObject9.Id.Parent;
                ADRawEntry  adrawEntry  = tenantOrTopologyConfigurationSession.ReadADRawEntry(parent, new PropertyDefinition[]
                {
                    ADObjectSchema.ExchangeVersion
                });
                ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)adrawEntry[ADObjectSchema.ExchangeVersion];
                TDataObject           dataObject10          = this.DataObject;
                if (dataObject10.ExchangeVersion.IsOlderThan(exchangeObjectVersion))
                {
                    TDataObject dataObject11 = this.DataObject;
                    string      name         = dataObject11.Name;
                    TDataObject dataObject12 = this.DataObject;
                    base.WriteError(new TaskException(Strings.ErrorParentHasNewerVersion(name, dataObject12.ExchangeVersion.ToString(), exchangeObjectVersion.ToString())), (ErrorCategory)1004, null);
                }
            }
            TDataObject dataObject13 = this.DataObject;

            if (dataObject13.RecipientType != this.DesiredRecipientType && this.DesiredRecipientType != RecipientType.Invalid)
            {
                TDataObject   dataObject14 = this.DataObject;
                string        id           = dataObject14.Identity.ToString();
                string        oldType      = this.DesiredRecipientType.ToString();
                TDataObject   dataObject15 = this.DataObject;
                Exception     exception    = new InvalidOperationException(Strings.ErrorSetTaskChangeRecipientType(id, oldType, dataObject15.RecipientType.ToString()));
                ErrorCategory category     = (ErrorCategory)1000;
                TDataObject   dataObject16 = this.DataObject;
                base.WriteError(exception, category, dataObject16.Identity);
            }
            base.InternalProcessRecord();
            TaskLogger.LogExit();
        }
Exemple #20
0
        protected sealed override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            TDataObject tdataObject = (TDataObject)((object)base.PrepareDataObject());

            if (string.IsNullOrEmpty(tdataObject.Alias))
            {
                using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "RecipientTaskHelper.GenerateUniqueAlias", LoggerHelper.CmdletPerfMonitors))
                {
                    tdataObject.Alias = RecipientTaskHelper.GenerateUniqueAlias(base.TenantGlobalCatalogSession, base.CurrentOrganizationId, base.Name, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                }
            }
            if (!this.GetEmailAddressPolicyEnabledDefaultValue(tdataObject))
            {
                tdataObject.EmailAddressPolicyEnabled = false;
            }
            if (string.IsNullOrEmpty(tdataObject.DisplayName))
            {
                tdataObject.DisplayName = tdataObject.Name;
            }
            if (base.IsProvisioningLayerAvailable)
            {
                ProvisioningLayer.UpdateAffectedIConfigurable(this, this.ConvertDataObjectToPresentationObject(tdataObject), false);
            }
            else
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorNoProvisioningHandlerAvailable), (ErrorCategory)1001, null);
            }
            if (tdataObject.EmailAddresses.Count > 0)
            {
                using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "NewRecipientObjectTask<TDataObject>.VerifyProxyAddress", LoggerHelper.CmdletPerfMonitors))
                {
                    ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, tdataObject.OrganizationId, base.ExecutingUserOrganizationId, false);
                    IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, string.IsNullOrEmpty(base.DomainController) ? null : base.NetCredential, sessionSettings, 867, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\NewAdObjectTask.cs");
                    bool flag = base.Fields["SoftDeletedObject"] != null;
                    if (flag)
                    {
                        RecipientTaskHelper.StripInvalidSMTPAddress(this.ConfigurationSession, tdataObject, base.ProvisioningCache, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerReThrowDelegate(this.WriteError));
                        RecipientTaskHelper.StripConflictEmailAddress(tenantOrRootOrgRecipientSession, tdataObject, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerReThrowDelegate(this.WriteError));
                    }
                    else
                    {
                        if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && this.ShouldCheckAcceptedDomains())
                        {
                            RecipientTaskHelper.ValidateSmtpAddress(this.ConfigurationSession, tdataObject.EmailAddresses, tdataObject, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache);
                        }
                        RecipientTaskHelper.ValidateEmailAddressErrorOut(tenantOrRootOrgRecipientSession, tdataObject.EmailAddresses, tdataObject, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerReThrowDelegate(this.WriteError));
                    }
                }
            }
            if (VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled)
            {
                ADRecipient adrecipient = tdataObject;
                if ((RecipientTaskHelper.GetAcceptedRecipientTypes() & adrecipient.RecipientTypeDetails) != RecipientTypeDetails.None && string.IsNullOrEmpty(adrecipient.ExternalDirectoryObjectId))
                {
                    adrecipient.ExternalDirectoryObjectId = Guid.NewGuid().ToString("D");
                }
            }
            TaskLogger.LogExit();
            return(tdataObject);
        }
Exemple #21
0
        protected void Install()
        {
            TaskLogger.LogEnter(new object[]
            {
                this.Name
            });
            Hashtable hashtable = new Hashtable();

            if (!ServiceControllerUtils.IsInstalled(this.Name))
            {
                try
                {
                    TaskLogger.Trace("Installing service", new object[0]);
                    this.serviceProcessInstaller.Install(hashtable);
                }
                catch (Win32Exception ex)
                {
                    if (1072 == ex.NativeErrorCode)
                    {
                        Thread.Sleep(10000);
                        hashtable = new Hashtable();
                        this.serviceProcessInstaller.Install(hashtable);
                    }
                    else
                    {
                        base.WriteError(new TaskWin32Exception(ex), ErrorCategory.WriteError, null);
                    }
                }
                base.ConfigureServiceSidType();
                if (this.serviceFirewallRules.Count > 0)
                {
                    foreach (ExchangeFirewallRule exchangeFirewallRule in this.serviceFirewallRules)
                    {
                        TaskLogger.Trace("Adding Windows Firewall Rule for Service {0}", new object[]
                        {
                            this.Name
                        });
                        exchangeFirewallRule.Add();
                    }
                }
                this.serviceProcessInstaller.Commit(hashtable);
            }
            else
            {
                TaskLogger.Trace("Service is already installed.", new object[0]);
            }
            if (this.Description != null)
            {
                try
                {
                    using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(ManageService.serviceRegPath + this.Name, true))
                    {
                        registryKey.SetValue(ManageService.descriptionSubKeyName, this.Description);
                    }
                    goto IL_197;
                }
                catch (SecurityException inner)
                {
                    base.WriteError(new SecurityException(Strings.ErrorOpenKeyDeniedForWrite(ManageService.serviceRegPath + this.Name), inner), ErrorCategory.WriteError, null);
                    goto IL_197;
                }
            }
            TaskLogger.Trace("No service description", new object[0]);
IL_197:
            if (this.EventMessageFile != null)
            {
                RegistryKey registryKey2 = null;
                try
                {
                    try
                    {
                        registryKey2 = Registry.LocalMachine.OpenSubKey(ManageService.eventLogRegPath + this.Name, true);
                        if (registryKey2 == null)
                        {
                            registryKey2 = Registry.LocalMachine.CreateSubKey(ManageService.eventLogRegPath + this.Name, RegistryKeyPermissionCheck.ReadWriteSubTree);
                        }
                        registryKey2.SetValue(ManageService.eventMessageFileSubKeyName, this.EventMessageFile);
                        registryKey2.SetValue(ManageService.categoryMessageFileSubKeyName, this.EventMessageFile);
                        registryKey2.SetValue(ManageService.categoryCountSubKeyName, this.CategoryCount);
                        registryKey2.SetValue(ManageService.typesSupportedSubKeyName, 7);
                    }
                    catch (SecurityException inner2)
                    {
                        base.WriteError(new SecurityException(Strings.ErrorOpenKeyDeniedForWrite(ManageService.serviceRegPath + this.Name), inner2), ErrorCategory.WriteError, null);
                    }
                    goto IL_281;
                }
                finally
                {
                    if (registryKey2 != null)
                    {
                        registryKey2.Close();
                        registryKey2 = null;
                    }
                }
            }
            TaskLogger.Trace("No event message file", new object[0]);
IL_281:
            if (base.FirstFailureActionType != ServiceActionType.None)
            {
                base.ConfigureFailureActions();
                base.ConfigureFailureActionsFlag();
            }
            else
            {
                TaskLogger.Trace("No failure actions", new object[0]);
            }
            TaskLogger.LogExit();
        }
Exemple #22
0
 protected override void InternalBeginProcessing()
 {
     base.InternalBeginProcessing();
     this.ResolveCurrentOrgIdBasedOnIdentity(this.Identity);
     TaskLogger.LogExit();
 }