private void RemoveTagFromExternalAddressEntry(ADObjectIdWithString entry, string[] tags, SmtpAddress externalRecipientToRemove, MultiValuedProperty <ADObjectIdWithString> supervisionList)
        {
            if (tags.Length == 1)
            {
                supervisionList.Remove(entry);
                return;
            }
            StringBuilder stringBuilder = new StringBuilder(entry.StringValue.Length - this.Tag.Length - 1);

            foreach (string text in tags)
            {
                if (!text.Equals(this.Tag, StringComparison.OrdinalIgnoreCase))
                {
                    if (stringBuilder.Length != 0)
                    {
                        stringBuilder.Append(SupervisionListEntryConstraint.Delimiter);
                    }
                    stringBuilder.Append(text);
                }
            }
            stringBuilder.Append(SupervisionListEntryConstraint.Delimiter);
            stringBuilder.Append(externalRecipientToRemove.ToString());
            ADObjectIdWithString item = new ADObjectIdWithString(stringBuilder.ToString(), entry.ObjectIdValue);

            supervisionList.Remove(entry);
            supervisionList.Add(item);
        }
Example #2
0
        public void Delete(IConfigurable instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            if (this.configurationSession.ReadOnly)
            {
                throw new InvalidOperationException("read only");
            }
            if (this.serviceInstanceName == null)
            {
                throw new InvalidOperationException("Delete can be performed only for specific service instance.");
            }
            FullSyncObjectRequest fullSyncObjectRequest = instance as FullSyncObjectRequest;

            if (fullSyncObjectRequest == null)
            {
                throw new NotSupportedException(instance.GetType().FullName);
            }
            this.RefreshRidMasterInformation();
            MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.configurationSession.GetMsoMainStreamCookieContainer(this.serviceInstanceName);
            MultiValuedProperty <FullSyncObjectRequest> msoForwardSyncObjectFullSyncRequests = msoMainStreamCookieContainer.MsoForwardSyncObjectFullSyncRequests;

            if (msoForwardSyncObjectFullSyncRequests.Contains(fullSyncObjectRequest))
            {
                msoForwardSyncObjectFullSyncRequests.Remove(fullSyncObjectRequest);
                this.configurationSession.Save(msoMainStreamCookieContainer);
                return;
            }
            throw new ADNoSuchObjectException(DirectoryStrings.ExceptionADOperationFailedNoSuchObject(this.configurationSession.DomainController, fullSyncObjectRequest.ToString()));
        }
 private void RemoveEdgeFromConnectorSourceServers(IConfigurationSession scSession, Server server)
 {
     SmtpSendConnectorConfig[] array = scSession.Find <SmtpSendConnectorConfig>(null, QueryScope.SubTree, null, null, -1);
     foreach (SmtpSendConnectorConfig smtpSendConnectorConfig in array)
     {
         if (smtpSendConnectorConfig != null && smtpSendConnectorConfig.SourceTransportServers != null)
         {
             MultiValuedProperty <ADObjectId> sourceTransportServers = smtpSendConnectorConfig.SourceTransportServers;
             ADObjectId adobjectId = null;
             foreach (ADObjectId adobjectId2 in sourceTransportServers)
             {
                 if (adobjectId2.Name == server.Id.Name)
                 {
                     if (smtpSendConnectorConfig.SourceTransportServers.Count == 1)
                     {
                         scSession.Delete(smtpSendConnectorConfig);
                     }
                     else
                     {
                         adobjectId = adobjectId2;
                     }
                 }
             }
             if (adobjectId != null)
             {
                 sourceTransportServers.Remove(adobjectId);
                 smtpSendConnectorConfig.SourceTransportServers = sourceTransportServers;
                 scSession.Save(smtpSendConnectorConfig);
             }
         }
     }
 }
 // Token: 0x060009EB RID: 2539 RVA: 0x0002CBE4 File Offset: 0x0002ADE4
 internal static void SetSKUCapability(Capability?skuCapability, MultiValuedProperty <Capability> capabilities)
 {
     if (skuCapability != null && !CapabilityHelper.RootSKUCapabilities.Contains(skuCapability.Value))
     {
         throw new ArgumentOutOfRangeException("skuCapability", skuCapability.Value, DirectoryStrings.ExArgumentOutOfRangeException("skuCapability", skuCapability.Value));
     }
     if (skuCapability != null && capabilities.Contains(skuCapability.Value))
     {
         return;
     }
     if (capabilities.Count > 0)
     {
         foreach (Capability item in CapabilityHelper.RootSKUCapabilities)
         {
             capabilities.Remove(item);
             if (capabilities.Count == 0)
             {
                 break;
             }
         }
     }
     if (skuCapability != null)
     {
         capabilities.Add(skuCapability.Value);
     }
 }
        private static bool UpdateTextMessagingState(MultiValuedProperty <TextMessagingStateBase> states, List <DeliveryPoint> deliveryPoints)
        {
            if (states == null)
            {
                throw new ArgumentNullException("states");
            }
            if (deliveryPoints == null)
            {
                throw new ArgumentNullException("deliveryPoint");
            }
            List <TextMessagingStateBase> list = new List <TextMessagingStateBase>(states.Count);
            bool flag = states.Count >= deliveryPoints.Count;

            foreach (TextMessagingStateBase textMessagingStateBase in states)
            {
                TextMessagingDeliveryPointState deliveryPointState = textMessagingStateBase as TextMessagingDeliveryPointState;
                if (deliveryPointState != null && !deliveryPointState.Shared)
                {
                    if (!deliveryPoints.Exists(delegate(DeliveryPoint dp)
                    {
                        if (dp.Identity != deliveryPointState.Identity || dp.Type != deliveryPointState.Type || !((dp.M2pMessagingPriority > -1) ? (dp.M2pMessagingPriority == (int)deliveryPointState.MachineToPersonMessagingPriority) : (!deliveryPointState.MachineToPersonMessagingEnabled)))
                        {
                            return(false);
                        }
                        if (dp.P2pMessagingPriority <= -1)
                        {
                            return(!deliveryPointState.PersonToPersonMessagingEnabled);
                        }
                        return(dp.P2pMessagingPriority == (int)deliveryPointState.PersonToPersonMessagingPriority);
                    }))
                    {
                        flag = false;
                    }
                    list.Add(deliveryPointState);
                }
            }
            if (flag)
            {
                return(false);
            }
            try
            {
                foreach (TextMessagingStateBase item in list)
                {
                    states.Remove(item);
                }
                foreach (DeliveryPoint deliveryPoint in deliveryPoints)
                {
                    states.Add(new TextMessagingDeliveryPointState(false, deliveryPoint.Ready && -1 < deliveryPoint.P2pMessagingPriority, deliveryPoint.Ready && -1 < deliveryPoint.M2pMessagingPriority, deliveryPoint.Type, deliveryPoint.Identity, (byte)deliveryPoint.P2pMessagingPriority, (byte)deliveryPoint.M2pMessagingPriority));
                }
            }
            catch (InvalidOperationException ex)
            {
                throw new ADTransientException(new LocalizedString(ex.Message), ex);
            }
            return(true);
        }
Example #6
0
 private void UpdateAdSettings()
 {
     this.m_output.WriteProgressSimple(Strings.DagTaskUpdatingAdDagMembership(this.m_mailboxServerName, this.m_dagName));
     this.m_mailboxServer.DatabaseAvailabilityGroup = null;
     base.DataSession.Save(this.m_mailboxServer);
     this.m_output.WriteProgressSimple(Strings.DagTaskUpdatedAdDagMembership(this.m_mailboxServerName, this.m_dagName));
     DagTaskHelper.RevertDagServersDatabasesToStandalone(this.ConfigurationSession, this.m_output, this.m_mailboxServer);
     if (this.m_dag.StartedMailboxServers.Contains(this.m_mailboxServer.Fqdn) || this.m_dag.StoppedMailboxServers.Contains(this.m_mailboxServer.Fqdn))
     {
         DatabaseAvailabilityGroup databaseAvailabilityGroup = ((IConfigurationSession)base.DataSession).Read <DatabaseAvailabilityGroup>(this.m_dag.Id);
         bool flag = false;
         MultiValuedProperty <string> multiValuedProperty = databaseAvailabilityGroup.StartedMailboxServers;
         flag = (flag || multiValuedProperty.Remove(this.m_mailboxServer.Fqdn));
         databaseAvailabilityGroup.StartedMailboxServers = multiValuedProperty;
         multiValuedProperty = databaseAvailabilityGroup.StoppedMailboxServers;
         flag = (flag || multiValuedProperty.Remove(this.m_mailboxServer.Fqdn));
         databaseAvailabilityGroup.StoppedMailboxServers = multiValuedProperty;
         if (!flag)
         {
             this.m_output.AppendLogMessage("The server was not present in either the Started nor Stopped mailbox servers list in AD, so AD does not need an update.", new object[0]);
             return;
         }
         try
         {
             this.m_output.WriteProgressSimple(Strings.DagTaskUpdatingAdDagStartedStoppedMembership(this.m_mailboxServerName, this.m_dagName));
             base.DataSession.Save(databaseAvailabilityGroup);
             this.m_output.WriteProgressSimple(Strings.DagTaskUpdatedAdDagStartedStoppedMembership(this.m_mailboxServerName, this.m_dagName));
         }
         catch (ADExternalException ex)
         {
             this.DagTrace("Failed to update AD StartedMailboxServers/StoppedMailboxServers (error={0})", new object[]
             {
                 ex
             });
         }
         catch (ADTransientException ex2)
         {
             this.DagTrace("Failed to update AD StartedMailboxServers/StoppedMailboxServers (error={0})", new object[]
             {
                 ex2
             });
         }
     }
 }
Example #7
0
        private static string GetAndRemoveAction(MultiValuedProperty <string> actions, string prefix)
        {
            string action = OrganizationRelationshipHelper.GetAction(actions, prefix);

            if (action != null)
            {
                actions.Remove(action);
            }
            return(action);
        }
        private static void SetSettingsString(IPropertyBag propertyBag, string protocolName, int position, string value, int totalNumberOfFields)
        {
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADRecipientSchema.ProtocolSettings];

            string[] array = null;
            foreach (string text in multiValuedProperty)
            {
                if (text.StartsWith(protocolName, StringComparison.OrdinalIgnoreCase))
                {
                    multiValuedProperty.Remove(text);
                    array = text.Split(new char[]
                    {
                        '§'
                    });
                    break;
                }
            }
            for (int i = 0; i < multiValuedProperty.Count; i++)
            {
                if (multiValuedProperty[i].StartsWith(protocolName, StringComparison.OrdinalIgnoreCase))
                {
                    multiValuedProperty.RemoveAt(i);
                    i--;
                }
            }
            if (array == null)
            {
                array    = new string[totalNumberOfFields];
                array[0] = protocolName;
            }
            else if (array.Length < totalNumberOfFields)
            {
                Array.Resize <string>(ref array, totalNumberOfFields);
            }
            array[position] = value;
            StringBuilder stringBuilder = new StringBuilder();

            for (int j = 0; j < array.Length; j++)
            {
                if (j > 0)
                {
                    stringBuilder.Append('§');
                }
                if (!string.IsNullOrEmpty(array[j]))
                {
                    stringBuilder.Append(array[j]);
                }
            }
            multiValuedProperty.Add(stringBuilder.ToString());
        }
Example #9
0
 protected override void InternalAddRemoveRoleEntry(MultiValuedProperty <RoleEntry> roleEntries)
 {
     if (!this.addedEntry.Equals(this.roleEntryOnDataObject))
     {
         if (null != this.roleEntryOnDataObject)
         {
             roleEntries.Remove(this.roleEntryOnDataObject);
         }
         if (!roleEntries.Contains(this.addedEntry))
         {
             roleEntries.Add(this.addedEntry);
         }
     }
 }
Example #10
0
        public void Save(IConfigurable instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            if (this.configurationSession.ReadOnly)
            {
                throw new InvalidOperationException("read only");
            }
            if (this.serviceInstanceName == null)
            {
                throw new InvalidOperationException("Save can be performed only for specific service instance.");
            }
            FullSyncObjectRequest request = instance as FullSyncObjectRequest;

            if (request == null)
            {
                throw new NotSupportedException(instance.GetType().FullName);
            }
            this.RefreshRidMasterInformation();
            MsoMainStreamCookieContainer msoMainStreamCookieContainer = this.configurationSession.GetMsoMainStreamCookieContainer(this.serviceInstanceName);
            MultiValuedProperty <FullSyncObjectRequest> msoForwardSyncObjectFullSyncRequests = msoMainStreamCookieContainer.MsoForwardSyncObjectFullSyncRequests;
            FullSyncObjectRequest fullSyncObjectRequest = msoForwardSyncObjectFullSyncRequests.Find((FullSyncObjectRequest r) => request.Identity.Equals(r.Identity) && request.ServiceInstanceId == r.ServiceInstanceId);

            if (fullSyncObjectRequest != null)
            {
                if (request.ObjectState == ObjectState.New)
                {
                    throw new ADObjectAlreadyExistsException(DirectoryStrings.ExceptionADOperationFailedAlreadyExist(this.configurationSession.DomainController, request.ToString()));
                }
                if (request.ObjectState == ObjectState.Changed)
                {
                    msoForwardSyncObjectFullSyncRequests.Remove(fullSyncObjectRequest);
                }
            }
            else
            {
                IEnumerable <FullSyncObjectRequest> source = from r in msoForwardSyncObjectFullSyncRequests
                                                             where request.ServiceInstanceId == r.ServiceInstanceId
                                                             select r;
                int maxObjectFullSyncRequestsPerServiceInstance = ProvisioningTasksConfigImpl.MaxObjectFullSyncRequestsPerServiceInstance;
                if (source.Count <FullSyncObjectRequest>() >= maxObjectFullSyncRequestsPerServiceInstance)
                {
                    throw new DataSourceOperationException(Strings.OperationExceedsPerServiceInstanceFullSyncObjectRequestLimit(maxObjectFullSyncRequestsPerServiceInstance, request.ServiceInstanceId));
                }
            }
            msoForwardSyncObjectFullSyncRequests.Add(request);
            this.configurationSession.Save(msoMainStreamCookieContainer);
        }
 // Token: 0x060009ED RID: 2541 RVA: 0x0002CD78 File Offset: 0x0002AF78
 internal static void SetAddOnSKUCapabilities(MultiValuedProperty <Capability> sourceCapabilities, MultiValuedProperty <Capability> targetCapabilities)
 {
     if (!sourceCapabilities.All((Capability c) => CapabilityHelper.IsAddOnSKUCapability(c)))
     {
         throw new ArgumentOutOfRangeException("sourceCapabilities", sourceCapabilities, DirectoryStrings.ExArgumentOutOfRangeException("sourceCapabilities", sourceCapabilities));
     }
     foreach (Capability item in from c in CapabilityHelper.AddOnSKUCapabilities
              where targetCapabilities.Contains(c)
              select c)
     {
         targetCapabilities.Remove(item);
     }
     foreach (Capability item2 in sourceCapabilities)
     {
         targetCapabilities.Add(item2);
     }
 }
Example #12
0
        internal void ApplyChangesToDownlevelData(ExchangeRole parentRole)
        {
            if (parentRole == null)
            {
                throw new ArgumentNullException("parentRole");
            }
            if (!this.HasDownlevelData)
            {
                return;
            }
            MultiValuedProperty <RoleEntry> multiValuedProperty = (MultiValuedProperty <RoleEntry>) this[ExchangeRoleSchema.InternalDownlevelRoleEntries];

            object[] removed = this.RoleEntries.Removed;
            for (int i = 0; i < removed.Length; i++)
            {
                RoleEntry roleEntry            = (RoleEntry)removed[i];
                RoleEntry downlevelEntryToFind = roleEntry.MapToPreviousVersion();
                RoleEntry roleEntry2           = multiValuedProperty.Find((RoleEntry dre) => 0 == RoleEntry.CompareRoleEntriesByName(dre, downlevelEntryToFind));
                if (roleEntry2 != null)
                {
                    multiValuedProperty.Remove(roleEntry2);
                }
            }
            object[] added = this.RoleEntries.Added;
            for (int j = 0; j < added.Length; j++)
            {
                RoleEntry roleEntry3           = (RoleEntry)added[j];
                RoleEntry downlevelEntryToFind = roleEntry3.MapToPreviousVersion();
                MultiValuedProperty <RoleEntry> multiValuedProperty2 = (MultiValuedProperty <RoleEntry>)parentRole[ExchangeRoleSchema.InternalDownlevelRoleEntries];
                RoleEntry roleEntry4 = multiValuedProperty2.Find((RoleEntry dre) => 0 == RoleEntry.CompareRoleEntriesByName(dre, downlevelEntryToFind));
                if (!(roleEntry4 == null))
                {
                    List <string> list = new List <string>();
                    foreach (string newParameter in roleEntry3.Parameters)
                    {
                        string text = roleEntry3.MapParameterToPreviousVersion(newParameter);
                        if (roleEntry4.ContainsParameter(text))
                        {
                            list.Add(text);
                        }
                    }
                    RoleEntry item = downlevelEntryToFind.Clone(list);
                    multiValuedProperty.Add(item);
                }
            }
        }
Example #13
0
 internal static SetterDelegate SetOrganizationRelationshipState(string sharedResource, ProviderPropertyDefinition federationEnabledActions)
 {
     return(delegate(object isEnabledObject, IPropertyBag properties)
     {
         bool flag = (bool)isEnabledObject;
         MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)properties[federationEnabledActions];
         bool flag2 = multiValuedProperty.Contains(sharedResource);
         if (flag && !flag2)
         {
             multiValuedProperty.Add(sharedResource);
             return;
         }
         if (!flag && flag2)
         {
             multiValuedProperty.Remove(sharedResource);
         }
     });
 }
Example #14
0
        private void AddExternalRecipientSupervisionListEntry(SmtpAddress externalRecipientToAdd, ADObjectId configContainerId)
        {
            if (configContainerId == null)
            {
                base.WriteError(new ArgumentNullException("configContainerId"), (ErrorCategory)1000, null);
            }
            MultiValuedProperty <ADObjectIdWithString> supervisionListForExternalAddress = base.GetSupervisionListForExternalAddress();
            ADObjectIdWithString adobjectIdWithString = null;

            string[] array = null;
            PropertyValidationError propertyValidationError = base.FindExternalAddressEntry(externalRecipientToAdd, supervisionListForExternalAddress, out adobjectIdWithString, out array);

            if (propertyValidationError != null)
            {
                return;
            }
            if (adobjectIdWithString != null)
            {
                foreach (string text in array)
                {
                    if (text.Equals(this.Tag, StringComparison.OrdinalIgnoreCase))
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorSupervisionEntryAlreadyPresent(this.Entry.ToString(), this.Tag.ToLower())), (ErrorCategory)1003, null);
                    }
                }
                string stringValue        = this.Tag.ToLower() + "," + adobjectIdWithString.StringValue;
                ADObjectIdWithString item = new ADObjectIdWithString(stringValue, adobjectIdWithString.ObjectIdValue);
                supervisionListForExternalAddress.Remove(adobjectIdWithString);
                supervisionListForExternalAddress.Add(item);
            }
            else
            {
                string stringValue2        = this.Tag.ToLower() + "," + externalRecipientToAdd.ToString();
                ADObjectIdWithString item2 = new ADObjectIdWithString(stringValue2, configContainerId);
                supervisionListForExternalAddress.Add(item2);
            }
            if (base.IsVerboseOn)
            {
                base.WriteVerbose(Strings.SupervisionListEntryAdded(this.Entry.ToString(), Strings.ExternalAddress, this.Tag));
            }
        }
Example #15
0
 internal static void MergeBindings(MultiValuedProperty <BindingMetadata> bindings, MultiValuedProperty <BindingMetadata> addedBindings, MultiValuedProperty <BindingMetadata> removedBindings, bool forceClear)
 {
     ArgumentValidator.ThrowIfNull("bindings", bindings);
     ArgumentValidator.ThrowIfNull("addedBindings", addedBindings);
     ArgumentValidator.ThrowIfNull("removedBindings", removedBindings);
     if (forceClear && bindings.Any <BindingMetadata>())
     {
         bindings.Clear();
         return;
     }
     using (MultiValuedProperty <BindingMetadata> .Enumerator enumerator = removedBindings.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             BindingMetadata item            = enumerator.Current;
             BindingMetadata bindingMetadata = bindings.FirstOrDefault((BindingMetadata p) => p.ImmutableIdentity == item.ImmutableIdentity);
             if (bindingMetadata != null)
             {
                 bindings.Remove(bindingMetadata);
             }
         }
     }
     using (MultiValuedProperty <BindingMetadata> .Enumerator enumerator2 = addedBindings.GetEnumerator())
     {
         while (enumerator2.MoveNext())
         {
             BindingMetadata item             = enumerator2.Current;
             BindingMetadata bindingMetadata2 = bindings.FirstOrDefault((BindingMetadata p) => p.ImmutableIdentity == item.ImmutableIdentity);
             if (bindingMetadata2 == null)
             {
                 bindings.Add(item);
             }
             else if (!string.Equals(bindingMetadata2.DisplayName, item.DisplayName, StringComparison.InvariantCulture) || !string.Equals(bindingMetadata2.Name, item.Name, StringComparison.InvariantCultureIgnoreCase))
             {
                 int index = bindings.IndexOf(bindingMetadata2);
                 bindings[index] = item;
             }
         }
     }
 }
Example #16
0
        internal static void EmailAddressesSetter(object value, IPropertyBag propertyBag)
        {
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)value;

            if (proxyAddressCollection == null || proxyAddressCollection.WasCleared)
            {
                throw new MservOperationException(DirectoryStrings.NoResetOrAssignedMvp);
            }
            string puidKey = MServRecipientSchema.GetPuidKey(propertyBag);
            MultiValuedProperty <MservRecord> multiValuedProperty = (MultiValuedProperty <MservRecord>)propertyBag[MServRecipientSchema.MservEmailAddressesRecord];

            foreach (ProxyAddress proxyAddress in proxyAddressCollection.Added)
            {
                bool        flag        = true;
                MservRecord mservRecord = new MservRecord(proxyAddress.AddressString, 0, null, puidKey, 0);
                foreach (MservRecord record in multiValuedProperty.Added)
                {
                    if (mservRecord.SameRecord(record))
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    multiValuedProperty.Add(mservRecord);
                }
            }
            foreach (ProxyAddress proxyAddress2 in proxyAddressCollection.Removed)
            {
                foreach (MservRecord mservRecord2 in multiValuedProperty.ToArray())
                {
                    if (proxyAddress2.AddressString.Equals(mservRecord2.Key, StringComparison.OrdinalIgnoreCase))
                    {
                        multiValuedProperty.Remove(mservRecord2);
                        break;
                    }
                }
            }
        }
        private static void EwsSetTupleBool(IPropertyBag propertyBag, string wellKnownApplicationName, bool?allow)
        {
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[CASMailboxSchema.EwsWellKnownApplicationAccessPolicies];

            foreach (string text in multiValuedProperty)
            {
                string[] array = text.Split(new char[]
                {
                    ':'
                });
                if (string.Compare(array[1], wellKnownApplicationName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    multiValuedProperty.Remove(text);
                    break;
                }
            }
            if (allow != null)
            {
                string arg = (allow == true) ? "Allow" : "Block";
                multiValuedProperty.Add(string.Format("{0}:{1}", arg, wellKnownApplicationName));
            }
        }
        // Token: 0x060060EF RID: 24815 RVA: 0x00149200 File Offset: 0x00147400
        internal static void ObjectCountQuotaSetter(string key, Unlimited <int> countQuota, IPropertyBag propertyBag)
        {
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[RecipientEnforcementProvisioningPolicySchema.ObjectCountQuota];

            foreach (string text in multiValuedProperty)
            {
                string[] array = text.Split(new char[]
                {
                    ':'
                });
                if (array.Length == 2 && string.Equals(key, array[0], StringComparison.OrdinalIgnoreCase))
                {
                    multiValuedProperty.Remove(text);
                    break;
                }
            }
            if (countQuota != Unlimited <int> .UnlimitedValue)
            {
                string item = string.Format("{0}:{1}", key, countQuota);
                multiValuedProperty.Add(item);
            }
            propertyBag[RecipientEnforcementProvisioningPolicySchema.ObjectCountQuota] = multiValuedProperty;
        }
Example #19
0
        private void AddADRecipientSupervisionListEntry(bool isGroup, ADRecipient adRecipientToAdd)
        {
            MultiValuedProperty <ADObjectIdWithString> supervisionListForADRecipient = base.GetSupervisionListForADRecipient(isGroup);
            ADObjectIdWithString adobjectIdWithString = null;

            string[] array = null;
            PropertyValidationError propertyValidationError = base.FindADRecipientEntry(adRecipientToAdd, supervisionListForADRecipient, out adobjectIdWithString, out array);

            if (propertyValidationError != null)
            {
                return;
            }
            if (adobjectIdWithString != null)
            {
                foreach (string text in array)
                {
                    if (text.Equals(this.Tag, StringComparison.OrdinalIgnoreCase))
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorSupervisionEntryAlreadyPresent(this.Entry.ToString(), this.Tag.ToLower())), (ErrorCategory)1003, null);
                    }
                }
                string stringValue        = this.Tag.ToLower() + "," + adobjectIdWithString.StringValue;
                ADObjectIdWithString item = new ADObjectIdWithString(stringValue, adobjectIdWithString.ObjectIdValue);
                supervisionListForADRecipient.Remove(adobjectIdWithString);
                supervisionListForADRecipient.Add(item);
            }
            else
            {
                string stringValue2        = this.Tag.ToLower();
                ADObjectIdWithString item2 = new ADObjectIdWithString(stringValue2, adRecipientToAdd.Id);
                supervisionListForADRecipient.Add(item2);
            }
            if (base.IsVerboseOn)
            {
                base.WriteVerbose(Strings.SupervisionListEntryAdded(this.Entry.ToString(), isGroup ? Strings.DistributionGroup : Strings.IndividualRecipient, this.Tag));
            }
        }
 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();
 }
Example #21
0
 protected override void InternalAddRemoveRoleEntry(MultiValuedProperty <RoleEntry> roleEntries)
 {
     roleEntries.Remove(this.removedEntry);
 }