예제 #1
0
 public static void SetDelegation(ADUser principalUser, ADRecipient delegateRecipient, IConfigDataProvider writableAdSession, Task.TaskVerboseLoggingDelegate verboseLogger, bool remove)
 {
     if (!principalUser.ExchangeVersion.IsOlderThan(ADMailboxRecipientSchema.DelegateListLink.VersionAdded))
     {
         LocalizedString message;
         if (remove)
         {
             if (principalUser.DelegateListLink.Contains(delegateRecipient.Id))
             {
                 principalUser.DelegateListLink.Remove(delegateRecipient.Id);
                 writableAdSession.Save(principalUser);
                 message = Strings.VerboseMailboxDelegateRemoved(delegateRecipient.ToString(), principalUser.ToString());
             }
             else
             {
                 message = Strings.VerboseMailboxDelegateNotExits(delegateRecipient.ToString(), principalUser.ToString());
             }
         }
         else if (!principalUser.DelegateListLink.Contains(delegateRecipient.Id))
         {
             principalUser.DelegateListLink.Add(delegateRecipient.Id);
             writableAdSession.Save(principalUser);
             message = Strings.VerboseMailboxDelegateAdded(delegateRecipient.ToString(), principalUser.ToString());
         }
         else
         {
             message = Strings.VerboseMailboxDelegateAlreadyExists(delegateRecipient.ToString(), principalUser.ToString());
         }
         verboseLogger(message);
     }
 }
예제 #2
0
        private ADObjectId ADObjectIdFromRecipientIdParameter(RecipientIdParameter recipientId, object param)
        {
            ADRecipient adrecipient = base.GetDataObject <ADRecipient>(recipientId, this.recipientSession, null, new LocalizedString?(Strings.ExceptionUserObjectNotFound(recipientId.ToString())), new LocalizedString?(Strings.ExceptionUserObjectAmbiguous)) as ADRecipient;

            if (param != null)
            {
                RecipientType[] array = param as RecipientType[];
                foreach (RecipientType recipientType in array)
                {
                    if (adrecipient.RecipientType == recipientType || RemoteMailbox.IsRemoteMailbox(adrecipient.RecipientTypeDetails))
                    {
                        return(adrecipient.Id);
                    }
                }
                base.WriteError(new MailboxSearchTaskException(Strings.ErrorInvalidRecipientType(adrecipient.ToString(), adrecipient.RecipientType.ToString())), ErrorCategory.InvalidArgument, null);
            }
            return(adrecipient.Id);
        }
예제 #3
0
        // Token: 0x060050C9 RID: 20681 RVA: 0x0012BB94 File Offset: 0x00129D94
        internal static ADRecipient UnMarshalObject(object rusResult, ADObject originalRecipient)
        {
            if (rusResult == null || !(rusResult is object[]))
            {
                return(null);
            }
            SortedList sortedList = new SortedList(new CaseInsensitiveComparer(CultureInfo.InvariantCulture));

            foreach (object[] array2 in (object[])rusResult)
            {
                string[] array3 = new string[array2.Length - 1];
                Array.Copy(array2, 1, array3, 0, array2.Length - 1);
                sortedList.Add(array2[0], array3);
            }
            string[] array4 = new string[sortedList.Count];
            sortedList.Keys.CopyTo(array4, 0);
            ADRecipient adrecipient          = new ADRecipient();
            List <ADPropertyDefinition> list = new List <ADPropertyDefinition>((ADPropertyDefinition[])RUSMarshal.LdapAttributesToPropertyDefinitions(RUSMarshal.SchemaInstance, array4));
            List <object> list2 = new List <object>(list.Count);

            for (int j = 0; j < list.Count; j++)
            {
                list2.Add(RUSMarshal.UnMarshalAttribute(list[j], (object[])sortedList[list[j].LdapDisplayName]));
            }
            int k = list.Count - 1;

            while (k >= 0)
            {
                if (list[k] != ADRecipientSchema.WindowsEmailAddress)
                {
                    goto IL_171;
                }
                SmtpAddress smtpAddress = (SmtpAddress)list2[k];
                if (((SmtpAddress)list2[k]).Length <= 256)
                {
                    goto IL_171;
                }
                list.RemoveAt(k);
                list2.RemoveAt(k);
                ExTraceGlobals.RecipientUpdateServiceTracer.TraceDebug <string>((long)adrecipient.GetHashCode(), "RecipientUpdateService:: A Windows Email Address exceeding 256 characters for recipient \"{0}\" is generated and discarded", adrecipient.ToString());
IL_286:
                k--;
                continue;
IL_171:
                if (!list[k].IsMultivalued)
                {
                    goto IL_286;
                }
                int  num  = (list2[k] == null) ? 0 : ((MultiValuedPropertyBase)list2[k]).Count;
                int  num2 = (originalRecipient[list[k]] == null) ? 0 : ((MultiValuedPropertyBase)originalRecipient[list[k]]).Count;
                bool flag = num != num2;
                if (!flag && num != 0)
                {
                    object[] array5 = (object[])RUSMarshal.MarshalAttribute(list[k], list2[k]);
                    object[] array6 = (object[])RUSMarshal.MarshalAttribute(list[k], originalRecipient[list[k]]);
                    for (int l = 1; l < array6.Length; l++)
                    {
                        if (-1 == Array.IndexOf <object>(array5, array6[l]))
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                if (!flag)
                {
                    list.RemoveAt(k);
                    list2.RemoveAt(k);
                    ExTraceGlobals.RecipientUpdateServiceTracer.TraceDebug <string>((long)adrecipient.GetHashCode(), "RecipientUpdateService:: the value of 'msExchPoliciesIncluded' property of recipient \"{0}\" does NOT change at all.", adrecipient.ToString());
                    goto IL_286;
                }
                goto IL_286;
            }
            adrecipient.SetProperties(list.ToArray(), list2.ToArray());
            return(adrecipient);
        }
예제 #4
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);
        }
예제 #5
0
        internal static MultiValuedProperty <string> ConvertSourceMailboxesCollection(IEnumerable <RecipientIdParameter> recipientIds, bool inplaceHoldEnabled, Func <RecipientIdParameter, ADRecipient> recipientGetter, IRecipientSession recipientSession, Task.TaskErrorLoggingDelegate writeErrorDelegate, Action <LocalizedString> writeWarningDelegate, Func <LocalizedString, bool> shouldContinueDelegate)
        {
            MultiValuedProperty <string> results = null;

            if (recipientIds != null)
            {
                RecipientType[] source = new RecipientType[]
                {
                    RecipientType.UserMailbox,
                    RecipientType.Group,
                    RecipientType.MailUniversalDistributionGroup,
                    RecipientType.MailUniversalSecurityGroup,
                    RecipientType.MailNonUniversalGroup,
                    RecipientType.DynamicDistributionGroup
                };
                bool flag = false;
                foreach (RecipientIdParameter arg in recipientIds)
                {
                    if (results == null)
                    {
                        results = new MultiValuedProperty <string>();
                    }
                    ADRecipient       adrecipient     = recipientGetter(arg);
                    string            text            = null;
                    ADSessionSettings sessionSettings = adrecipient.OrganizationId.ToADSessionSettings();
                    if (Utils.IsPublicFolderMailbox(adrecipient))
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorInvalidRecipientTypeDetails(adrecipient.ToString())), ErrorCategory.InvalidArgument, null);
                    }
                    else if (Utils.IsValidMailboxType(adrecipient))
                    {
                        if (adrecipient.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012) && !RemoteMailbox.IsRemoteMailbox(adrecipient.RecipientTypeDetails) && ExchangePrincipal.FromADUser(sessionSettings, (ADUser)adrecipient, RemotingOptions.AllowCrossSite).MailboxInfo.Location.ServerVersion < Server.E15MinVersion)
                        {
                            writeErrorDelegate(new MailboxSearchTaskException(Strings.SourceMailboxMustBeE15OrLater(adrecipient.DisplayName)), ErrorCategory.InvalidArgument, null);
                        }
                        text = adrecipient.LegacyExchangeDN;
                    }
                    else if (source.Contains(adrecipient.RecipientType))
                    {
                        if (inplaceHoldEnabled)
                        {
                            if (!flag)
                            {
                                if (shouldContinueDelegate(Strings.ShouldContinueToExpandGroupsForHold))
                                {
                                    flag = true;
                                }
                                else
                                {
                                    writeErrorDelegate(new MailboxSearchTaskException(Strings.GroupsIsNotAllowedForHold(adrecipient.DisplayName)), ErrorCategory.InvalidArgument, null);
                                }
                            }
                            bool invalidTypeSkipped                   = false;
                            bool oldVersionMailboxSkipped             = false;
                            ADRecipientExpansion adrecipientExpansion = new ADRecipientExpansion(new PropertyDefinition[]
                            {
                                ADRecipientSchema.LegacyExchangeDN,
                                ADRecipientSchema.RecipientTypeDetailsValue,
                                ADObjectSchema.ExchangeVersion
                            }, adrecipient.OrganizationId);
                            adrecipientExpansion.Expand(adrecipient, delegate(ADRawEntry expandedRecipient, ExpansionType expansionType, ADRawEntry parent, ExpansionType parentType)
                            {
                                if (expansionType == ExpansionType.GroupMembership)
                                {
                                    return(ExpansionControl.Continue);
                                }
                                if (Utils.IsValidMailboxType(expandedRecipient))
                                {
                                    ExchangeObjectVersion exchangeObjectVersion = (ExchangeObjectVersion)expandedRecipient[ADObjectSchema.ExchangeVersion];
                                    string text2 = (string)expandedRecipient[ADRecipientSchema.LegacyExchangeDN];
                                    if (!oldVersionMailboxSkipped && exchangeObjectVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012) && !RemoteMailbox.IsRemoteMailbox((RecipientTypeDetails)expandedRecipient[ADRecipientSchema.RecipientTypeDetails]) && ExchangePrincipal.FromLegacyDN(sessionSettings, text2).MailboxInfo.Location.ServerVersion < Server.E15MinVersion)
                                    {
                                        oldVersionMailboxSkipped = true;
                                        writeWarningDelegate(Strings.OldVersionMailboxSkipped);
                                    }
                                    if (!results.Contains(text2))
                                    {
                                        results.Add(text2);
                                    }
                                }
                                else if (!invalidTypeSkipped)
                                {
                                    invalidTypeSkipped = true;
                                    writeWarningDelegate(Strings.SkippingInvalidTypeInGroupExpansion);
                                }
                                return(ExpansionControl.Skip);
                            }, delegate(ExpansionFailure failure, ADRawEntry expandedRecipient, ExpansionType expansionType, ADRawEntry parent, ExpansionType parentType)
                            {
                                TaskLogger.Trace("Skipping invalid AD entry {0} because of failure: {1}", new object[]
                                {
                                    expandedRecipient,
                                    failure
                                });
                                return(ExpansionControl.Skip);
                            });
                        }
                        else
                        {
                            text = adrecipient.LegacyExchangeDN;
                        }
                    }
                    else
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorInvalidRecipientType(adrecipient.ToString(), adrecipient.RecipientType.ToString())), ErrorCategory.InvalidArgument, null);
                    }
                    if (text != null && !results.Contains(text))
                    {
                        results.Add(text);
                    }
                    if (results.Count > Utils.MaxNumberOfMailboxesInSingleHold)
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorTooManyMailboxesInSingleHold(Utils.MaxNumberOfMailboxesInSingleHold)), ErrorCategory.InvalidArgument, null);
                    }
                }
                if (results != null)
                {
                    uint discoveryMaxMailboxes = SearchUtils.GetDiscoveryMaxMailboxes(recipientSession);
                    if ((long)results.Count > (long)((ulong)discoveryMaxMailboxes) && !shouldContinueDelegate(Strings.ShouldContinueMoreMailboxesThanMaxSearch(results.Count, discoveryMaxMailboxes)))
                    {
                        writeErrorDelegate(new MailboxSearchTaskException(Strings.ErrorTaskCancelledBecauseMoreMailboxesThanSearchSupported), ErrorCategory.InvalidArgument, null);
                    }
                }
            }
            return(results);
        }