Ejemplo n.º 1
0
        internal static MultiValuedProperty <TRawId> ConvertCollectionToMultiValedProperty <TIdentity, TRawId>(IEnumerable <TIdentity> identities, Utils.IdentityToRawIdDelegate <TIdentity, TRawId> identityToRawIdDelegate, object delegateParam, MultiValuedProperty <TRawId> existingProperty, Task.TaskErrorLoggingDelegate writeErrorDelegate, string parameterName)
        {
            if (identities == null)
            {
                return(existingProperty);
            }
            MultiValuedProperty <TRawId> multiValuedProperty = existingProperty ?? new MultiValuedProperty <TRawId>();

            foreach (TIdentity identity in identities)
            {
                TRawId item = identityToRawIdDelegate(identity, delegateParam);
                if (!multiValuedProperty.Contains(item))
                {
                    multiValuedProperty.Add(item);
                }
                else
                {
                    writeErrorDelegate(new MailboxSearchTaskException(Strings.CollectionConflictionError(identity.ToString(), parameterName)), ErrorCategory.InvalidArgument, null);
                }
            }
            return(multiValuedProperty);
        }
Ejemplo n.º 2
0
        internal static MultiValuedProperty <ADRecipient> ResolveAndSeparateMessageDeliveryRestrictionRecipientIdentities(MultiValuedProperty <DeliveryRecipientIdParameter> identities, string parameterName, IRecipientSession recipientSession, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.ErrorLoggerDelegate writeError, out MultiValuedProperty <ADObjectId> resolvedGroups, out MultiValuedProperty <ADObjectId> resolvedIndividuals)
        {
            resolvedGroups      = null;
            resolvedIndividuals = null;
            MultiValuedProperty <ADRecipient> multiValuedProperty = new MultiValuedProperty <ADRecipient>();

            foreach (RecipientIdParameter recipientIdParameter in identities)
            {
                ADRecipient adrecipient = (ADRecipient)getDataObject(recipientIdParameter, recipientSession, null, null, new LocalizedString?(Strings.ErrorRecipientNotFound(recipientIdParameter.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(recipientIdParameter.ToString())), ExchangeErrorCategory.Client);
                multiValuedProperty.Add(adrecipient);
                if ((resolvedGroups != null && resolvedGroups.Contains(adrecipient.Id)) || (resolvedIndividuals != null && resolvedIndividuals.Contains(adrecipient.Id)))
                {
                    writeError(new RecipientTaskException(Strings.ErrorRecipientIdParamElementsNotUnique(parameterName, adrecipient.Id.ToString())), ExchangeErrorCategory.Client, recipientIdParameter);
                }
                bool flag  = ADRecipient.IsAllowedDeliveryRestrictionGroup(adrecipient.RecipientType);
                bool flag2 = ADRecipient.IsAllowedDeliveryRestrictionIndividual(adrecipient.RecipientType);
                if (!flag && !flag2)
                {
                    writeError(new RecipientTaskException(Strings.ErrorGroupOrIndividualRecipientNeeded(recipientIdParameter.ToString())), ExchangeErrorCategory.Client, recipientIdParameter);
                }
                if (flag)
                {
                    if (resolvedGroups == null)
                    {
                        resolvedGroups = new MultiValuedProperty <ADObjectId>();
                    }
                    resolvedGroups.Add(adrecipient.Id);
                }
                else
                {
                    if (resolvedIndividuals == null)
                    {
                        resolvedIndividuals = new MultiValuedProperty <ADObjectId>();
                    }
                    resolvedIndividuals.Add(adrecipient.Id);
                }
            }
            return(multiValuedProperty);
        }
Ejemplo n.º 3
0
        internal static MultiValuedProperty <ADObjectId> ConvertTo(IRecipientSession recipientSession, MultiValuedProperty <MailboxIdParameter> mailboxIds, DataAccessHelper.GetDataObjectDelegate getDataObject, Task.TaskErrorLoggingDelegate writeError)
        {
            if (mailboxIds == null)
            {
                return(null);
            }
            MultiValuedProperty <ADObjectId> multiValuedProperty = new MultiValuedProperty <ADObjectId>();

            foreach (MailboxIdParameter mailboxIdParameter in mailboxIds)
            {
                ADRecipient adrecipient = (ADRecipient)getDataObject(mailboxIdParameter, recipientSession, null, null, new LocalizedString?(Strings.ExceptionUserObjectNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorSearchUserNotUnique(mailboxIdParameter.ToString())));
                if (Array.IndexOf <RecipientTypeDetails>(MailboxAuditLogSearch.SupportedRecipientTypes, adrecipient.RecipientTypeDetails) == -1)
                {
                    writeError(new ArgumentException(Strings.ErrorInvalidRecipientType(adrecipient.ToString(), adrecipient.RecipientTypeDetails.ToString())), ErrorCategory.InvalidArgument, null);
                }
                if (!multiValuedProperty.Contains(adrecipient.Id))
                {
                    multiValuedProperty.Add(adrecipient.Id);
                }
            }
            return(multiValuedProperty);
        }
Ejemplo n.º 4
0
        protected override void InternalProcessRecord()
        {
            ADObjectId childId    = this.ConfigurationSession.GetOrgContainerId().GetChildId(AuthConfig.ContainerName);
            ADRawEntry adrawEntry = this.ConfigurationSession.ReadADRawEntry(childId, new ADPropertyDefinition[]
            {
                ADObjectSchema.ObjectClass
            });

            if (adrawEntry == null)
            {
                base.InternalProcessRecord();
                return;
            }
            MultiValuedProperty <string> source = adrawEntry[ADObjectSchema.ObjectClass] as MultiValuedProperty <string>;

            if (!source.Contains(AuthConfig.ObjectClassName, StringComparer.OrdinalIgnoreCase))
            {
                Container container = this.ConfigurationSession.Read <Container>(childId);
                container.propertyBag.SetField(ADObjectSchema.ExchangeVersion, container.MaximumSupportedExchangeObjectVersion);
                ((IConfigurationSession)base.DataSession).DeleteTree(container, null);
                base.InternalProcessRecord();
            }
        }
Ejemplo n.º 5
0
        public static MultiValuedProperty <ADObjectId> ValidateServers(ADPropertyDefinition propertyDefinition, IConfigDataProvider session, MultiValuedProperty <ServerIdParameter> servers, HybridConfigurationTaskUtility.GetUniqueObject getServer, Task.TaskErrorLoggingDelegate writeError, params HybridConfigurationTaskUtility.ServerCriterion[] serverCriteria)
        {
            MultiValuedProperty <ADObjectId> multiValuedProperty = new MultiValuedProperty <ADObjectId>(false, propertyDefinition, new object[0]);

            if (servers != null)
            {
                foreach (ServerIdParameter serverIdParameter in servers)
                {
                    if (serverIdParameter != null)
                    {
                        Server server = getServer(serverIdParameter, session, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString()))) as Server;
                        if (server != null)
                        {
                            if (serverCriteria != null)
                            {
                                foreach (HybridConfigurationTaskUtility.ServerCriterion serverCriterion in serverCriteria)
                                {
                                    if (!serverCriterion.DoesMeet(server))
                                    {
                                        writeError(new InvalidOperationException(serverCriterion.Error(server.ToString())), ErrorCategory.InvalidOperation, server.ToString());
                                    }
                                }
                            }
                            if (multiValuedProperty.Contains((ADObjectId)server.Identity))
                            {
                                writeError(new InvalidOperationException(HybridStrings.ErrorHybridServerAlreadyAssigned(server.Identity.ToString())), ErrorCategory.InvalidOperation, server.ToString());
                            }
                            else
                            {
                                multiValuedProperty.Add(((ADObjectId)server.Identity).DistinguishedName);
                            }
                        }
                    }
                }
            }
            return(multiValuedProperty);
        }
Ejemplo n.º 6
0
        internal static MultiValuedProperty <SmtpAddress> GetUpdatedNotificationEmails(Task task, IRecipientSession recipientSession, IEnumerable <SmtpAddress> originalEmails)
        {
            MultiValuedProperty <SmtpAddress> multiValuedProperty = new MultiValuedProperty <SmtpAddress>();
            ADObjectId entryId;

            if (task.TryGetExecutingUserId(out entryId))
            {
                ADUser aduser = (ADUser)recipientSession.Read(entryId);
                if (aduser != null)
                {
                    SmtpAddress windowsEmailAddress = aduser.WindowsEmailAddress;
                    if (windowsEmailAddress.Length > 0)
                    {
                        multiValuedProperty.Add(windowsEmailAddress);
                    }
                }
            }
            else if (task.ExchangeRunspaceConfig.DelegatedPrincipal != null)
            {
                multiValuedProperty.Add(new SmtpAddress(task.ExchangeRunspaceConfig.DelegatedPrincipal.UserId));
            }
            if (originalEmails == null && multiValuedProperty.Count <= 0)
            {
                return(null);
            }
            if (originalEmails != null)
            {
                foreach (SmtpAddress item in originalEmails)
                {
                    if (!multiValuedProperty.Contains(item))
                    {
                        multiValuedProperty.Add(item);
                    }
                }
            }
            return(multiValuedProperty);
        }
Ejemplo n.º 7
0
        internal static MultiValuedProperty <ADObjectId> ValidateVirtualDirectory(IConfigDataProvider session, VirtualDirectoryIdParameter[] virtualDirectories, OfflineAddressBookTaskUtility.GetUniqueObject getOabVirtualDirectory, OfflineAddressBook target, Task.TaskErrorLoggingDelegate writeError)
        {
            MultiValuedProperty <ADObjectId> multiValuedProperty = new MultiValuedProperty <ADObjectId>(false, OfflineAddressBookSchema.VirtualDirectories, new object[0]);

            foreach (VirtualDirectoryIdParameter virtualDirectoryIdParameter in virtualDirectories)
            {
                if (virtualDirectoryIdParameter != null)
                {
                    IConfigurable configurable = getOabVirtualDirectory(virtualDirectoryIdParameter, session, null, new LocalizedString?(Strings.OabVirtualDirectoryNotExisting(virtualDirectoryIdParameter.ToString())), new LocalizedString?(Strings.OabVirtualDirectoryAmbiguous(virtualDirectoryIdParameter.ToString())));
                    if (configurable != null)
                    {
                        if (multiValuedProperty.Contains((ADObjectId)configurable.Identity))
                        {
                            writeError(new InvalidOperationException(Strings.ErrorOabVDirAlreadyAssigned((target.Identity != null) ? target.Identity.ToString() : target.Name, configurable.Identity.ToString())), ErrorCategory.InvalidOperation, target.Identity);
                        }
                        else
                        {
                            multiValuedProperty.Add((ADObjectId)configurable.Identity);
                        }
                    }
                }
            }
            return(multiValuedProperty);
        }
Ejemplo n.º 8
0
        // Token: 0x060003B5 RID: 949 RVA: 0x00015440 File Offset: 0x00013640
        internal static ADObject CreateAndInitializeRecipientObject <TRecipientObject>(ADPropertyBag propertyBag, ADRawEntry dummyObject, IRecipientSession recipientSession) where TRecipientObject : IConfigurable, new()
        {
            ArgumentValidator.ThrowIfNull("propertyBag", propertyBag);
            ArgumentValidator.ThrowIfNull("dummyObject", dummyObject);
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADObjectSchema.ObjectClass];
            ADObject adobject;

            if (dummyObject is OWAMiniRecipient)
            {
                adobject = new OWAMiniRecipient();
            }
            else if (dummyObject is ActiveSyncMiniRecipient)
            {
                adobject = new ActiveSyncMiniRecipient();
            }
            else if (dummyObject is StorageMiniRecipient)
            {
                adobject = new StorageMiniRecipient();
            }
            else if (dummyObject is TransportMiniRecipient)
            {
                adobject = new TransportMiniRecipient();
            }
            else if (dummyObject is LoadBalancingMiniRecipient)
            {
                adobject = new LoadBalancingMiniRecipient();
            }
            else if (dummyObject is MiniRecipientWithTokenGroups)
            {
                adobject = new MiniRecipientWithTokenGroups();
            }
            else if (dummyObject is FrontEndMiniRecipient)
            {
                adobject = new FrontEndMiniRecipient();
            }
            else if (dummyObject is MiniRecipient)
            {
                adobject = new MiniRecipient();
            }
            else if (dummyObject is RemovedMailbox)
            {
                adobject = new RemovedMailbox();
            }
            else if (dummyObject is DeletedRecipient)
            {
                adobject = new DeletedRecipient();
            }
            else if (multiValuedProperty.Contains(ADComputerRecipient.MostDerivedClass))
            {
                adobject = new ADComputerRecipient();
            }
            else if (multiValuedProperty.Contains(ADUser.MostDerivedClass))
            {
                adobject = new ADUser();
            }
            else if (multiValuedProperty.Contains(ADContact.MostDerivedClass))
            {
                adobject = new ADContact();
            }
            else if (multiValuedProperty.Contains(ADGroup.MostDerivedClass))
            {
                adobject = new ADGroup();
            }
            else if (multiValuedProperty.Contains(ADDynamicGroup.MostDerivedClass))
            {
                adobject = new ADDynamicGroup();
            }
            else if (multiValuedProperty.Contains(ADPublicFolder.MostDerivedClass))
            {
                adobject = new ADPublicFolder();
            }
            else if (multiValuedProperty.Contains(ADSystemAttendantMailbox.MostDerivedClass))
            {
                adobject = new ADSystemAttendantMailbox();
            }
            else if (multiValuedProperty.Contains(ADSystemMailbox.MostDerivedClass))
            {
                adobject = new ADSystemMailbox();
            }
            else if (multiValuedProperty.Contains(ADPublicDatabase.MostDerivedClass))
            {
                adobject = new ADPublicDatabase();
            }
            else
            {
                if (!multiValuedProperty.Contains(ADMicrosoftExchangeRecipient.MostDerivedClass))
                {
                    string objectClass = string.Empty;
                    foreach (string text in multiValuedProperty)
                    {
                        objectClass = text;
                    }
                    ObjectValidationError error = new ObjectValidationError(DirectoryStrings.UnsupportedObjectClass(objectClass), (ADObjectId)propertyBag[ADObjectSchema.Id], string.Empty);
                    ADProviderPerf.UpdateProcessCounter(Counter.ProcessRateCriticalValidationFailures, UpdateType.Update, 1U);
                    Globals.LogEvent(DirectoryEventLogConstants.Tuple_DSC_EVENT_VALIDATION_FAILED_FCO_MODE_RECIPIENT, ((ADObjectId)propertyBag[ADObjectSchema.Id]).ToString(), new object[]
                    {
                        ((ADObjectId)propertyBag[ADObjectSchema.Id]).ToDNString()
                    });
                    throw new DataValidationException(error);
                }
                adobject = new ADMicrosoftExchangeRecipient();
            }
            adobject.m_Session   = recipientSession;
            adobject.propertyBag = propertyBag;
            adobject.Initialize();
            adobject.ResetChangeTracking(true);
            if (recipientSession != null)
            {
                adobject.SetIsReadOnly(recipientSession.ReadOnly);
            }
            ExTraceGlobals.ADReadDetailsTracer.TraceDebug <string, RecipientType>((long)((recipientSession != null) ? recipientSession.GetHashCode() : 0), "ADRecipientObjectSession::CreateObject - Got {0} as {1}", adobject.DistinguishedName, (RecipientType)adobject[ADRecipientSchema.RecipientType]);
            return(adobject);
        }
Ejemplo n.º 9
0
        public UnifiedGroupMemberType GetMembershipType()
        {
            if (this.DenyCurrentLogon())
            {
                GroupMailboxAuthorizationHandler.Tracer.TraceWarning <string>(0L, "Not OWA logon and flight not enabled for group. ClientInfoString:{0} ", this.clientInfoString);
                return(UnifiedGroupMemberType.Unknown);
            }
            IRecipientSession recipientSession = AccessingUserInfo.GetRecipientSession(this.organizationId);

            ArgumentValidator.ThrowIfNull("recipientSession", recipientSession);
            ArgumentValidator.ThrowIfInvalidValue <IRecipientSession>("recipientSession.ReadOnly", recipientSession, (IRecipientSession x) => x.ReadOnly);
            if (this.accessingUserInfo.UserObjectId != null)
            {
                ADRecipient adrecipient = recipientSession.FindByExchangeGuid(this.groupMailboxToLogon.MailboxInfo.MailboxGuid);
                if (adrecipient != null)
                {
                    recipientSession.DomainController = adrecipient.OriginatingServer;
                    MultiValuedProperty <ADObjectId> multiValuedProperty = (MultiValuedProperty <ADObjectId>)adrecipient[ADUserSchema.Owners];
                    if (multiValuedProperty.Contains(this.accessingUserInfo.UserObjectId))
                    {
                        this.TraceMembershipType(UnifiedGroupMemberType.Owner);
                        return(UnifiedGroupMemberType.Owner);
                    }
                }
                if (this.groupMailboxToLogon.ModernGroupType == ModernGroupObjectType.Public)
                {
                    this.TraceMembershipType(UnifiedGroupMemberType.Member);
                    return(UnifiedGroupMemberType.Member);
                }
                if (this.groupMailboxToLogon.ModernGroupType == ModernGroupObjectType.Private)
                {
                    QueryFilter  queryFilter  = new ComparisonFilter(ComparisonOperator.Equal, IUnifiedGroupMailboxSchema.UnifiedGroupMembersLink, this.accessingUserInfo.UserObjectId);
                    QueryFilter  queryFilter2 = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, this.groupMailboxToLogon.ObjectId);
                    ADRawEntry[] array        = recipientSession.Find(null, QueryScope.SubTree, new AndFilter(new QueryFilter[]
                    {
                        queryFilter2,
                        queryFilter
                    }), null, 0, GroupMailboxAuthorizationHandler.PropertiesToReturnForGroupQuery);
                    if (array != null && array.Length == 1)
                    {
                        this.TraceMembershipType(UnifiedGroupMemberType.Member);
                        return(UnifiedGroupMemberType.Member);
                    }
                }
            }
            else
            {
                GroupMailboxAuthorizationHandler.Tracer.TraceError <string>((long)this.GetHashCode(), "Unable to retrieve object identity of user {0} from AD", this.accessingUserInfo.Identity);
            }
            if (this.groupMailboxToLogon.ModernGroupType == ModernGroupObjectType.Public)
            {
                this.TraceMembershipType(UnifiedGroupMemberType.Member);
                return(UnifiedGroupMemberType.Member);
            }
            if (this.groupMailboxToLogon.ModernGroupType == ModernGroupObjectType.Private && this.IsGroupMemberInMailboxAssociation())
            {
                this.TraceMembershipType(UnifiedGroupMemberType.Member);
                return(UnifiedGroupMemberType.Member);
            }
            this.TraceMembershipType(UnifiedGroupMemberType.None);
            return(UnifiedGroupMemberType.None);
        }
        public static SiteMailboxAddressesTemplate GetSiteMailboxAddressesTemplate(IConfigurationSession cfgSession, ProvisioningCache provisioningCache)
        {
            if (cfgSession == null)
            {
                throw new ArgumentNullException("cfgSession");
            }
            if (provisioningCache == null)
            {
                throw new ArgumentNullException("provisioningCache");
            }
            OrganizationId orgId = cfgSession.GetOrgContainer().OrganizationId;

            return(provisioningCache.TryAddAndGetOrganizationData <SiteMailboxAddressesTemplate>(CannedProvisioningCacheKeys.OrganizationSiteMailboxAddressesTemplate, orgId, delegate()
            {
                ADObjectId rootId = orgId.ConfigurationUnit ?? provisioningCache.TryAddAndGetGlobalData <ADObjectId>(CannedProvisioningCacheKeys.FirstOrgContainerId, () => cfgSession.GetOrgContainerId());
                MultiValuedProperty <SmtpDomain> multiValuedProperty = null;
                ADPagedReader <OnPremisesOrganization> adpagedReader = cfgSession.FindPaged <OnPremisesOrganization>(rootId, QueryScope.SubTree, null, null, 0);
                using (IEnumerator <OnPremisesOrganization> enumerator = adpagedReader.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        OnPremisesOrganization onPremisesOrganization = enumerator.Current;
                        multiValuedProperty = onPremisesOrganization.HybridDomains;
                    }
                }
                QueryFilter filter = new NotFilter(new BitMaskAndFilter(AcceptedDomainSchema.AcceptedDomainFlags, 1UL));
                ADPagedReader <AcceptedDomain> adpagedReader2 = cfgSession.FindPaged <AcceptedDomain>(rootId, QueryScope.SubTree, filter, new SortBy(ADObjectSchema.Name, SortOrder.Ascending), 0);
                bool flag = false;
                string text = string.Empty;
                string text2 = string.Empty;
                string text3 = string.Empty;
                foreach (AcceptedDomain acceptedDomain in adpagedReader2)
                {
                    if (acceptedDomain.AuthenticationType != AuthenticationType.Federated && (string.IsNullOrEmpty(text) || acceptedDomain.Default))
                    {
                        text = acceptedDomain.DomainName.Domain;
                    }
                    if ((multiValuedProperty == null || multiValuedProperty.Count == 0 || multiValuedProperty.Contains(acceptedDomain.DomainName.SmtpDomain)) && (string.IsNullOrEmpty(text2) || acceptedDomain.Default))
                    {
                        text2 = acceptedDomain.DomainName.Domain;
                    }
                    if (acceptedDomain.IsCoexistenceDomain && string.IsNullOrEmpty(text3))
                    {
                        text3 = acceptedDomain.DomainName.Domain;
                    }
                    flag = (flag || acceptedDomain.Default);
                    if (flag && !string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3))
                    {
                        break;
                    }
                }
                SiteMailboxAddressesTemplate siteMailboxAddressesTemplate = new SiteMailboxAddressesTemplate();
                siteMailboxAddressesTemplate.UserPrincipalNameDomain = text;
                if (!string.IsNullOrEmpty(text2))
                {
                    siteMailboxAddressesTemplate.AddressTemplates.Add(new SmtpProxyAddressTemplate(string.Format("@{0}", text2), true));
                    if (!string.IsNullOrEmpty(text3) && !string.Equals(text2, text3, StringComparison.OrdinalIgnoreCase))
                    {
                        siteMailboxAddressesTemplate.AddressTemplates.Add(new SmtpProxyAddressTemplate(string.Format("@{0}", text3), false));
                    }
                }
                if (!siteMailboxAddressesTemplate.IsValid)
                {
                    throw new ErrorSiteMailboxCannotLoadAddressTemplateException();
                }
                return siteMailboxAddressesTemplate;
            }));
        }
Ejemplo n.º 11
0
 private bool DoesExist(ADRecipient recipient, MultiValuedProperty <string> existingAddress)
 {
     return(existingAddress != null && existingAddress.Count != 0 && existingAddress.Contains(recipient.LegacyExchangeDN));
 }
Ejemplo n.º 12
0
        private static MultiValuedProperty <Capability> GetEffectivePersistedCapabilities(IPropertyBag propertyBag)
        {
            MultiValuedProperty <AssignedPlanValue> multiValuedProperty  = (MultiValuedProperty <AssignedPlanValue>)propertyBag[SyncCompanySchema.AssignedPlan];
            MultiValuedProperty <Capability>        multiValuedProperty2 = new MultiValuedProperty <Capability>();

            if (multiValuedProperty != null && multiValuedProperty.Count != 0)
            {
                foreach (AssignedPlanValue assignedPlanValue in multiValuedProperty)
                {
                    Capability exchangeCapability = SyncUser.GetExchangeCapability(assignedPlanValue.Capability);
                    if (assignedPlanValue.CapabilityStatus != AssignedCapabilityStatus.Deleted && exchangeCapability != Capability.None && !multiValuedProperty2.Contains(exchangeCapability))
                    {
                        multiValuedProperty2.Add(exchangeCapability);
                    }
                }
            }
            return(multiValuedProperty2);
        }
Ejemplo n.º 13
0
        internal static object LiveIdAuthenticationGetter(IPropertyBag propertyBag)
        {
            MultiValuedProperty <AuthenticationMethod> multiValuedProperty = (MultiValuedProperty <AuthenticationMethod>)propertyBag[ADVirtualDirectorySchema.InternalAuthenticationMethods];

            return(multiValuedProperty.Contains(AuthenticationMethod.LiveIdFba));
        }
Ejemplo n.º 14
0
        // Token: 0x060005CC RID: 1484 RVA: 0x0001614C File Offset: 0x0001434C
        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 dataObject8 = this.DataObject;
                    return(SharedConfiguration.GetSharedConfigurationState(dataObject8.OrganizationId));
                });
            }
            if (SharedConfigurationTaskHelper.ShouldPrompt(this, this.SharedTenantConfigurationMode, this.CurrentOrgState) && !base.InternalForce)
            {
                TDataObject dataObject2 = this.DataObject;
                if (!base.ShouldContinue(Strings.ConfirmSharedConfiguration(dataObject2.OrganizationId.OrganizationalUnit.Name)))
                {
                    TaskLogger.LogExit();
                    return;
                }
            }
            TDataObject dataObject3 = this.DataObject;

            if (dataObject3.IsChanged(ADObjectSchema.Id))
            {
                IDirectorySession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, base.OrgWideSessionSettings, ConfigScopes.TenantSubTree, 702, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\BaseTasks\\SetAdObjectTask.cs");
                tenantOrTopologyConfigurationSession.UseConfigNC = ((IDirectorySession)base.DataSession).UseConfigNC;
                TDataObject dataObject4 = this.DataObject;
                ADObjectId  parent      = dataObject4.Id.Parent;
                ADRawEntry  adrawEntry  = tenantOrTopologyConfigurationSession.ReadADRawEntry(parent, new PropertyDefinition[]
                {
                    ADObjectSchema.ExchangeVersion,
                    ADObjectSchema.ObjectClass
                });
                ExchangeObjectVersion        exchangeObjectVersion = (ExchangeObjectVersion)adrawEntry[ADObjectSchema.ExchangeVersion];
                MultiValuedProperty <string> multiValuedProperty   = (MultiValuedProperty <string>)adrawEntry[ADObjectSchema.ObjectClass];
                TDataObject dataObject5 = this.DataObject;
                if (dataObject5.ExchangeVersion.IsOlderThan(exchangeObjectVersion) && !multiValuedProperty.Contains(Organization.MostDerivedClass))
                {
                    TDataObject dataObject6 = this.DataObject;
                    string      name        = dataObject6.Name;
                    TDataObject dataObject7 = this.DataObject;
                    base.WriteError(new TaskException(Strings.ErrorParentHasNewerVersion(name, dataObject7.ExchangeVersion.ToString(), exchangeObjectVersion.ToString())), (ErrorCategory)1004, null);
                }
            }
            base.InternalProcessRecord();
            TaskLogger.LogExit();
        }
        private static QueryFilter GenerateTargetFilterForUserAndNonDomainLocalGroup(MultiValuedProperty <SecurityPrincipalType> types)
        {
            List <CompositeFilter> list = new List <CompositeFilter>();

            foreach (SecurityPrincipalType securityPrincipalType in types)
            {
                CompositeFilter compositeFilter = null;
                switch (securityPrincipalType)
                {
                case SecurityPrincipalType.User:
                    compositeFilter = new AndFilter(new QueryFilter[]
                    {
                        new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.ObjectCategory, ADUser.ObjectCategoryNameInternal),
                        ADObject.ObjectClassFilter(ADUser.MostDerivedClass, true)
                    });
                    break;

                case SecurityPrincipalType.Group:
                    compositeFilter = new AndFilter(new QueryFilter[]
                    {
                        new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.ObjectCategory, ADGroup.MostDerivedClass),
                        new BitMaskOrFilter(ADGroupSchema.GroupType, (ulong)int.MinValue),
                        new NotFilter(new BitMaskAndFilter(ADGroupSchema.GroupType, 4UL))
                    });
                    break;

                case SecurityPrincipalType.UniversalSecurityGroup:
                    if (!types.Contains(SecurityPrincipalType.Group))
                    {
                        compositeFilter = ExtendedSecurityPrincipalSearchHelper.GenerateTargetFilterForSecurityGroup(GroupTypeFlags.Universal);
                    }
                    break;

                case SecurityPrincipalType.GlobalSecurityGroup:
                    if (!types.Contains(SecurityPrincipalType.Group))
                    {
                        compositeFilter = ExtendedSecurityPrincipalSearchHelper.GenerateTargetFilterForSecurityGroup(GroupTypeFlags.Global);
                    }
                    break;
                }
                if (compositeFilter != null)
                {
                    if (Datacenter.IsMicrosoftHostedOnly(true) && (securityPrincipalType == SecurityPrincipalType.Group || securityPrincipalType == SecurityPrincipalType.UniversalSecurityGroup))
                    {
                        compositeFilter = new AndFilter(new QueryFilter[]
                        {
                            compositeFilter,
                            new OrFilter(new QueryFilter[]
                            {
                                new NotFilter(new BitMaskAndFilter(ADGroupSchema.GroupType, 8UL)),
                                new AndFilter(new QueryFilter[]
                                {
                                    new BitMaskAndFilter(ADGroupSchema.GroupType, 8UL),
                                    new OrFilter(new QueryFilter[]
                                    {
                                        new ExistsFilter(ADRecipientSchema.Alias),
                                        Filters.GetRecipientTypeDetailsFilterOptimization(RecipientTypeDetails.RoleGroup)
                                    })
                                })
                            })
                        });
                    }
                    list.Add(compositeFilter);
                }
            }
            return(new OrFilter(list.ToArray()));
        }
Ejemplo n.º 16
0
        // Token: 0x060003B6 RID: 950 RVA: 0x0001573C File Offset: 0x0001393C
        internal static ADObject CreateAndInitializeConfigObject <TConfigObject>(ADPropertyBag propertyBag, ADRawEntry dummyObject, IDirectorySession directorySession) where TConfigObject : IConfigurable, new()
        {
            ArgumentValidator.ThrowIfNull("propertyBag", propertyBag);
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADObjectSchema.ObjectClass];
            ADObject adobject;

            if (dummyObject is MiniTopologyServer)
            {
                adobject = new MiniTopologyServer();
            }
            else if (dummyObject is MiniVirtualDirectory)
            {
                adobject = new MiniVirtualDirectory();
            }
            else if (dummyObject is MiniEmailTransport)
            {
                adobject = new MiniEmailTransport();
            }
            else if (dummyObject is MiniReceiveConnector)
            {
                adobject = new MiniReceiveConnector();
            }
            else if (multiValuedProperty.Contains(ADWebServicesVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADWebServicesVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADE12UMVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADE12UMVirtualDirectory();
            }
            else if (multiValuedProperty.Contains("msExchMobileVirtualDirectory"))
            {
                adobject = new ADMobileVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADOwaVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADOwaVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADRpcHttpVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADRpcHttpVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADMapiVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADMapiVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADAvailabilityForeignConnectorVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADAvailabilityForeignConnectorVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADOabVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADOabVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADEcpVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADEcpVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(Pop3AdConfiguration.MostDerivedClass))
            {
                adobject = new Pop3AdConfiguration();
            }
            else if (multiValuedProperty.Contains(Imap4AdConfiguration.MostDerivedClass))
            {
                adobject = new Imap4AdConfiguration();
            }
            else if (multiValuedProperty.Contains("mailGateway"))
            {
                if (multiValuedProperty.Contains(SmtpSendConnectorConfig.MostDerivedClass))
                {
                    adobject = new SmtpSendConnectorConfig();
                }
                else if (multiValuedProperty.Contains(DeliveryAgentConnector.MostDerivedClass))
                {
                    adobject = new DeliveryAgentConnector();
                }
                else if (propertyBag.Contains(ForeignConnectorSchema.DropDirectory))
                {
                    adobject = new ForeignConnector();
                }
                else
                {
                    adobject = new LegacyGatewayConnector();
                }
            }
            else if (multiValuedProperty.Contains("msExchEdgeSyncEhfConnector"))
            {
                adobject = new EdgeSyncEhfConnector();
            }
            else
            {
                if (!multiValuedProperty.Contains("msExchEdgeSyncMservConnector"))
                {
                    return(ADObjectFactory.CreateAndInitializeObject <TConfigObject>(propertyBag, directorySession));
                }
                adobject = new EdgeSyncMservConnector();
            }
            adobject.m_Session   = directorySession;
            adobject.propertyBag = propertyBag;
            adobject.Initialize();
            adobject.ResetChangeTracking(true);
            if (directorySession != null)
            {
                adobject.SetIsReadOnly(directorySession.ReadOnly);
            }
            return(adobject);
        }
 protected override void InternalApplyChangeAndValidate()
 {
     TaskLogger.LogEnter();
     if (!this.DataObject.IsUnscopedTopLevel && this.UnScopedTopLevel)
     {
         base.WriteError(new InvalidOperationException(Strings.ParameterAllowedOnlyForTopLevelRoleManipulation("UnScopedTopLevel", RoleType.UnScoped.ToString())), ErrorCategory.InvalidOperation, null);
     }
     string[] parameters = null;
     this.originalEntry = RoleHelper.GetMandatoryRoleEntry(this.DataObject, this.Identity.CmdletOrScriptName, this.Identity.PSSnapinName, new Task.TaskErrorLoggingDelegate(base.WriteError));
     string[] parameters2;
     if (!this.AddParameter.IsPresent && !this.RemoveParameter.IsPresent)
     {
         parameters2 = this.Parameters;
         parameters  = this.Parameters;
     }
     else
     {
         MultiValuedProperty <string> multiValuedProperty = new MultiValuedProperty <string>();
         foreach (string item in this.originalEntry.Parameters)
         {
             multiValuedProperty.Add(item);
         }
         if (this.Parameters != null)
         {
             List <string> list = null;
             if (this.AddParameter.IsPresent)
             {
                 parameters = this.Parameters;
                 foreach (string item2 in this.Parameters)
                 {
                     if (multiValuedProperty.Contains(item2))
                     {
                         if (list == null)
                         {
                             list = new List <string>();
                         }
                         list.Add(item2);
                     }
                     else
                     {
                         multiValuedProperty.Add(item2);
                     }
                 }
             }
             else
             {
                 foreach (string item3 in this.Parameters)
                 {
                     if (!multiValuedProperty.Contains(item3))
                     {
                         if (list == null)
                         {
                             list = new List <string>();
                         }
                         list.Add(item3);
                     }
                     else
                     {
                         multiValuedProperty.Remove(item3);
                     }
                 }
             }
             if (list != null && 0 < list.Count)
             {
                 LocalizedString value = this.AddParameter.IsPresent ? Strings.ErrorAddExistentParameters(this.Identity.RoleId.ToString(), this.Identity.CmdletOrScriptName, string.Join(",", list.ToArray())) : Strings.ErrorRemoveNonExistentParameters(this.Identity.RoleId.ToString(), this.Identity.CmdletOrScriptName, string.Join(",", list.ToArray()));
                 base.WriteError(new InvalidOperationException(value), ErrorCategory.InvalidOperation, this.DataObject.Id);
             }
         }
         parameters2 = multiValuedProperty.ToArray();
     }
     try
     {
         if (this.originalEntry is CmdletRoleEntry)
         {
             string pssnapinName = ((CmdletRoleEntry)this.originalEntry).PSSnapinName;
             if (base.IsEntryValidationRequired())
             {
                 base.VerifyCmdletEntry(this.originalEntry.Name, pssnapinName, parameters);
             }
             this.modifiedEntry = new CmdletRoleEntry(this.originalEntry.Name, pssnapinName, parameters2);
         }
         else if (this.originalEntry is ScriptRoleEntry)
         {
             if (base.IsEntryValidationRequired())
             {
                 base.VerifyScriptEntry(this.originalEntry.Name, parameters, this.SkipScriptExistenceCheck);
             }
             this.modifiedEntry = new ScriptRoleEntry(this.originalEntry.Name, parameters2);
         }
         else if (this.originalEntry is ApplicationPermissionRoleEntry)
         {
             this.modifiedEntry = new ApplicationPermissionRoleEntry(this.originalEntry.Name, parameters2);
         }
         else
         {
             if (!(this.originalEntry is WebServiceRoleEntry))
             {
                 throw new NotSupportedException("this.originalEntry is not a valid type.");
             }
             base.WriteError(new InvalidOperationException(Strings.CannotSetWebServiceRoleEntry(this.originalEntry.Name)), ErrorCategory.InvalidOperation, null);
         }
     }
     catch (FormatException ex)
     {
         base.WriteError(new ArgumentException(new LocalizedString(ex.Message)), ErrorCategory.InvalidArgument, this.DataObject.Id);
     }
     if (!this.modifiedEntry.Equals(this.originalEntry))
     {
         if (null != this.originalEntry)
         {
             this.DataObject.RoleEntries.Remove(this.originalEntry);
         }
         this.DataObject.RoleEntries.Add(this.modifiedEntry);
         this.DataObject.ApplyChangesToDownlevelData(base.ParentRole ?? this.DataObject);
     }
     TaskLogger.LogExit();
 }
Ejemplo n.º 18
0
        internal static bool GetAuthenticationMethodHelper(IPropertyBag propertyBag, AuthenticationMethod method)
        {
            MultiValuedProperty <AuthenticationMethod> multiValuedProperty = (MultiValuedProperty <AuthenticationMethod>)propertyBag[ADVirtualDirectorySchema.InternalAuthenticationMethods];

            return(multiValuedProperty.Contains(method));
        }
        internal static bool UpdateAuthenticationSettingsAndProviders(ServerManager serverManager, string siteName, string virtualPath, MultiValuedProperty <AuthenticationMethod> authMethods)
        {
            bool                 flag = false;
            string               text = siteName + virtualPath;
            Configuration        applicationHostConfiguration = serverManager.GetApplicationHostConfiguration();
            ConfigurationSection section = applicationHostConfiguration.GetSection("system.webServer/security/authentication/anonymousAuthentication", text);

            flag   |= IISConfigurationUtilities.UpdateSectionAttribute(section, "enabled", false);
            section = applicationHostConfiguration.GetSection("system.webServer/security/authentication/basicAuthentication", text);
            bool flag2 = authMethods.Contains(AuthenticationMethod.Basic);

            flag   |= IISConfigurationUtilities.UpdateSectionAttribute(section, "enabled", flag2);
            section = applicationHostConfiguration.GetSection("system.webServer/security/authentication/clientCertificateMappingAuthentication", text);
            flag2   = authMethods.Contains(AuthenticationMethod.Certificate);
            flag   |= IISConfigurationUtilities.UpdateSectionAttribute(section, "enabled", flag2);
            section = applicationHostConfiguration.GetSection("system.webServer/security/authentication/digestAuthentication", text);
            flag2   = authMethods.Contains(AuthenticationMethod.Digest);
            flag   |= IISConfigurationUtilities.UpdateSectionAttribute(section, "enabled", flag2);
            section = applicationHostConfiguration.GetSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", text);
            flag   |= IISConfigurationUtilities.UpdateSectionAttribute(section, "enabled", false);
            section = applicationHostConfiguration.GetSection("system.webServer/security/authentication/windowsAuthentication", text);
            bool flag3 = authMethods.Contains(AuthenticationMethod.Negotiate);
            bool flag4 = authMethods.Contains(AuthenticationMethod.Kerberos);
            bool flag5 = authMethods.Contains(AuthenticationMethod.Ntlm);
            bool flag6 = authMethods.Contains(AuthenticationMethod.LiveIdNegotiate);

            flag2 = (flag3 || flag4 || flag5 || flag6);
            flag |= IISConfigurationUtilities.UpdateSectionAttribute(section, "enabled", flag2);
            flag |= IISConfigurationUtilities.UpdateSectionAttribute(section, "useKernelMode", false);
            if (flag2)
            {
                ConfigurationElementCollection collection = section.GetCollection("providers");
                int  num   = (flag3 ? 1 : 0) + (flag4 ? 1 : 0) + (flag5 ? 1 : 0);
                bool flag7 = false;
                if (collection.Count != num)
                {
                    flag7 = true;
                }
                else
                {
                    int num2 = 0;
                    if (flag6)
                    {
                        flag7 |= ((string)collection[num2].Attributes["value"].Value != "Negotiate:MSOIDSSP");
                        num2++;
                    }
                    if (flag3)
                    {
                        flag7 |= ((string)collection[num2].Attributes["value"].Value != "Negotiate");
                        num2++;
                    }
                    if (flag4)
                    {
                        flag7 |= ((string)collection[num2].Attributes["value"].Value != "Negotiate:Kerberos");
                        num2++;
                    }
                    if (flag5)
                    {
                        flag7 |= ((string)collection[num2].Attributes["value"].Value != "NTLM");
                        num2++;
                    }
                }
                if (flag7)
                {
                    flag = true;
                    collection.Clear();
                    if (flag6)
                    {
                        ConfigurationElement configurationElement = collection.CreateElement("add");
                        configurationElement["value"] = "Negotiate:MSOIDSSP";
                        collection.Add(configurationElement);
                    }
                    if (flag3)
                    {
                        ConfigurationElement configurationElement2 = collection.CreateElement("add");
                        configurationElement2["value"] = "Negotiate";
                        collection.Add(configurationElement2);
                    }
                    if (flag4)
                    {
                        ConfigurationElement configurationElement3 = collection.CreateElement("add");
                        configurationElement3["value"] = "Negotiate:Kerberos";
                        collection.Add(configurationElement3);
                    }
                    if (flag5)
                    {
                        ConfigurationElement configurationElement4 = collection.CreateElement("add");
                        configurationElement4["value"] = "NTLM";
                        collection.Add(configurationElement4);
                    }
                }
            }
            return(flag);
        }
        internal static bool UpdateAuthenticationModules(ServerManager serverManager, string siteName, string virtualPath, MultiValuedProperty <AuthenticationMethod> authMethods, bool useApplicationHostConfigForModules)
        {
            bool   flag = false;
            string text = siteName + virtualPath;
            ConfigurationSection section;

            if (useApplicationHostConfigForModules)
            {
                Configuration configuration = serverManager.GetApplicationHostConfiguration();
                section = configuration.GetSection("system.webServer/modules", text);
            }
            else
            {
                Configuration configuration = serverManager.Sites[siteName].Applications[virtualPath].GetWebConfiguration();
                section = configuration.GetSection("system.webServer/modules");
            }
            if (section == null)
            {
                throw new WebObjectNotFoundException(Strings.ExceptionWebObjectNotFound(siteName + "/" + virtualPath + "/system.webServer/modules"));
            }
            ConfigurationElementCollection collection = section.GetCollection();

            if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.WindowsLiveID.Enabled)
            {
                flag |= IISConfigurationUtilities.UpdateWebServerModule(collection, "LiveIdBasicAuthModule", "Microsoft.Exchange.Security.Authentication.LiveIdBasicAuthModule, Microsoft.Exchange.Security, Version=15.0.0.0, Culture=neutral, publicKeyToken=31bf3856ad364e35", authMethods.Contains(AuthenticationMethod.LiveIdBasic));
                flag |= IISConfigurationUtilities.UpdateWebServerModule(collection, "LiveIdNegotiateAuxiliaryModule", "Microsoft.Exchange.Security.Authentication.LiveIdNegotiateAuxiliaryModule, Microsoft.Exchange.Security, Version=15.0.0.0, Culture=neutral, publicKeyToken=31bf3856ad364e35", authMethods.Contains(AuthenticationMethod.LiveIdNegotiate));
            }
            return(flag | IISConfigurationUtilities.UpdateWebServerModule(collection, "OAuthAuthModule", typeof(OAuthHttpModule).AssemblyQualifiedName, authMethods.Contains(AuthenticationMethod.OAuth)));
        }
        private void CheckRbac()
        {
            ADScopeException             ex = null;
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>) this.DataObject[ADObjectSchema.ObjectClass];

            if (multiValuedProperty.Contains("person") || multiValuedProperty.Contains("msExchDynamicDistributionList") || multiValuedProperty.Contains("group") || multiValuedProperty.Contains("publicFolder") || multiValuedProperty.Contains("msExchPublicMDB") || multiValuedProperty.Contains("msExchSystemMailbox") || multiValuedProperty.Contains(ADMicrosoftExchangeRecipient.MostDerivedClass) || multiValuedProperty.Contains("exchangeAdminService") || multiValuedProperty.Contains("computer"))
            {
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromCustomScopeSet(base.ScopeSet, this.DataObject.Id, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true), 581, "CheckRbac", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\permission\\SetADPermissionTaskBase.cs");
                ADRecipient       adrecipient = tenantOrRootOrgRecipientSession.Read(this.DataObject.Id);
                if (adrecipient == null)
                {
                    base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
                }
                if (!tenantOrRootOrgRecipientSession.TryVerifyIsWithinScopes(adrecipient, true, out ex))
                {
                    base.WriteError(new TaskInvalidOperationException(Strings.ErrorCannotChangeObjectOutOfWriteScope(adrecipient.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ExchangeErrorCategory.Client, adrecipient.Identity);
                    return;
                }
            }
            else
            {
                ADObject adobject = null;
                bool     flag     = false;
                IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromCustomScopeSet(base.ScopeSet, this.DataObject.Id, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true), 620, "CheckRbac", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\permission\\SetADPermissionTaskBase.cs");
                if (multiValuedProperty.Contains("msExchOabVirtualDirectory"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <ADOabVirtualDirectory>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("ServiceConnectionPoint"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <ADServiceConnectionPoint>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("RpcClientAccess"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <ExchangeRpcClientAccess>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("msExchProtocolCfgHTTPContainer"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <HttpContainer>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("msExchProtocolCfgIMAPContainer"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <Imap4Container>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("msExchInformationStore"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <InformationStore>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("mTA"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <MicrosoftMTAConfiguration>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("msExchProtocolCfgPOPContainer"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <Pop3Container>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("protocolCfgSharedServer"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <ProtocolsContainer>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("msExchSmtpReceiveConnector"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <ReceiveConnector>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("msExchExchangeServer"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <Server>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("msExchProtocolCfgSMTPContainer"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <SmtpContainer>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("protocolCfgSMTPServer"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <SmtpVirtualServerConfiguration>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("msExchMDB"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <Database>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("msExchPrivateMDB"))
                {
                    adobject = tenantOrTopologyConfigurationSession.Read <MailboxDatabase>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains(ADOrganizationalUnit.MostDerivedClass))
                {
                    tenantOrTopologyConfigurationSession.UseConfigNC = false;
                    adobject = tenantOrTopologyConfigurationSession.Read <ADOrganizationalUnit>(this.DataObject.Id);
                    flag     = true;
                }
                else if (multiValuedProperty.Contains("domain"))
                {
                    tenantOrTopologyConfigurationSession.UseConfigNC = false;
                    adobject = tenantOrTopologyConfigurationSession.Read <ADDomain>(this.DataObject.Id);
                    flag     = true;
                }
                if (flag)
                {
                    if (adobject == null)
                    {
                        base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorObjectNotFound(this.Identity.ToString())), ErrorCategory.InvalidArgument, null);
                    }
                    if (!tenantOrTopologyConfigurationSession.TryVerifyIsWithinScopes(adobject, true, out ex))
                    {
                        base.WriteError(new TaskInvalidOperationException(Strings.ErrorCannotChangeObjectOutOfWriteScope(adobject.Identity.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ExchangeErrorCategory.Client, adobject.Identity);
                    }
                }
            }
        }
Ejemplo n.º 22
0
        public static bool IsUMLanguageAvailable(UMLanguage language)
        {
            MultiValuedProperty <UMLanguage> multiValuedProperty = Utils.ComputeUnionOfUmServerLanguages();

            return(multiValuedProperty != null && multiValuedProperty.Contains(language));
        }
Ejemplo n.º 23
0
        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();
        }
        internal static object SecurityPrincipalTypeDetailsGetter(IPropertyBag propertyBag)
        {
            Exception ex = null;

            try
            {
                ADObjectId adobjectId = (ADObjectId)propertyBag[ADObjectSchema.ObjectCategory];
                if (adobjectId != null)
                {
                    MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADObjectSchema.ObjectClass];
                    string text = adobjectId.Name.ToLower();
                    if (text == ADUser.ObjectCategoryNameInternal && multiValuedProperty.Count > 0 && multiValuedProperty.Contains(ADUser.MostDerivedClass))
                    {
                        return(SecurityPrincipalType.User);
                    }
                    if (text == ADGroup.MostDerivedClass)
                    {
                        return(SecurityPrincipalType.Group);
                    }
                    if (text == "foreign-security-principal")
                    {
                        return(SecurityPrincipalType.WellknownSecurityPrincipal);
                    }
                    if (text == ExtendedSecurityPrincipal.computer && multiValuedProperty.Count > 0 && multiValuedProperty.Contains(ADUser.MostDerivedClass))
                    {
                        return(SecurityPrincipalType.Computer);
                    }
                    ex = new ArgumentException(DirectoryStrings.ExArgumentException("ObjectCategory", text));
                }
                else
                {
                    ex = new ArgumentNullException(DirectoryStrings.ExArgumentNullException("ObjectCategory"));
                }
            }
            catch (InvalidOperationException ex2)
            {
                ex = ex2;
            }
            throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("SecurityPrincipalTypes", ex.Message), ExtendedSecurityPrincipalSchema.SecurityPrincipalTypes, propertyBag[ADObjectSchema.ObjectCategory]), ex);
        }
Ejemplo n.º 25
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         if (this.Mailbox == null)
         {
             ADObjectId adObjectId;
             if (!base.TryGetExecutingUserId(out adObjectId))
             {
                 throw new ExecutingUserPropertyNotFoundException("executingUserid");
             }
             this.Mailbox = new MailboxIdParameter(adObjectId);
         }
         this.targetUser            = RequestTaskHelper.ResolveADUser(base.RecipSession, base.GCSession, base.ServerSettings, this.Mailbox, base.OptionalIdentityData, base.DomainController, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADUser>), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), true);
         base.RecipSession          = (IRecipientSession)TaskHelper.UnderscopeSessionToOrganization(base.RecipSession, this.targetUser.OrganizationId, true);
         base.CurrentOrganizationId = this.targetUser.OrganizationId;
         base.RJProvider.IndexProvider.RecipientSession = base.RecipSession;
         if (this.targetUser.Database == null)
         {
             base.WriteError(new MailboxLacksDatabasePermanentException(this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.Mailbox);
         }
         if (this.AggregatedMailboxGuid != Guid.Empty)
         {
             MultiValuedProperty <Guid> multiValuedProperty = this.targetUser.AggregatedMailboxGuids ?? new MultiValuedProperty <Guid>();
             if (!multiValuedProperty.Contains(this.AggregatedMailboxGuid))
             {
                 base.WriteError(new AggregatedMailboxNotFoundPermanentException(this.AggregatedMailboxGuid, this.targetUser.ToString()), ErrorCategory.InvalidArgument, this.AggregatedMailboxGuid);
             }
         }
         this.DataObject.DomainControllerToUpdate = this.targetUser.OriginatingServer;
         bool wildcardedSearch = false;
         if (!string.IsNullOrEmpty(this.Name))
         {
             base.ValidateName();
             base.RequestName = this.Name;
         }
         else if (this.Olc)
         {
             base.RequestName = "OlcSync";
         }
         else
         {
             wildcardedSearch = true;
             base.RequestName = "Sync";
         }
         base.RescopeToOrgId(this.targetUser.OrganizationId);
         ADObjectId   mdbId         = null;
         ADObjectId   mdbServerSite = null;
         RequestFlags requestFlags  = this.LocateAndChooseMdb(null, this.targetUser.Database, null, this.Mailbox, this.Mailbox, out mdbId, out mdbServerSite);
         base.MdbId         = mdbId;
         base.MdbServerSite = mdbServerSite;
         base.Flags         = (RequestFlags.CrossOrg | requestFlags);
         base.RequestName   = this.CheckRequestNameAvailability(base.RequestName, this.targetUser.Id, true, MRSRequestType.Sync, this.Mailbox, wildcardedSearch);
         if (this.Imap == true)
         {
             this.syncProtocol = SyncProtocol.Imap;
         }
         else if (this.Eas == true)
         {
             this.syncProtocol = SyncProtocol.Eas;
         }
         else if (this.Pop == true)
         {
             this.syncProtocol = SyncProtocol.Pop;
         }
         else if (this.Olc == true)
         {
             this.syncProtocol = SyncProtocol.Olc;
         }
         else
         {
             base.WriteError(new SyncProtocolNotSpecifiedPermanentException(), ErrorCategory.InvalidArgument, this.syncProtocol);
         }
         if (base.IsFieldSet("IncrementalSyncInterval"))
         {
             RequestTaskHelper.ValidateIncrementalSyncInterval(this.IncrementalSyncInterval, new Task.TaskErrorLoggingDelegate(base.WriteError));
         }
         DateTime utcNow = DateTime.UtcNow;
         if (base.IsFieldSet("StartAfter"))
         {
             RequestTaskHelper.ValidateStartAfterTime(this.StartAfter.ToUniversalTime(), new Task.TaskErrorLoggingDelegate(base.WriteError), utcNow);
         }
         if (base.IsFieldSet("StartAfter") && base.IsFieldSet("CompleteAfter"))
         {
             RequestTaskHelper.ValidateStartAfterComesBeforeCompleteAfter(new DateTime?(this.StartAfter.ToUniversalTime()), new DateTime?(this.CompleteAfter.ToUniversalTime()), new Task.TaskErrorLoggingDelegate(base.WriteError));
         }
         base.InternalValidate();
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Ejemplo n.º 26
0
        internal static object IsSmtpConnectorGetter(IPropertyBag propertyBag)
        {
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADObjectSchema.ObjectClass];

            return(multiValuedProperty.Contains(SmtpSendConnectorConfig.MostDerivedClass));
        }