Beispiel #1
0
        internal static void UpdateRecipientForSoftDelete(IRecipientSession session, ADUser recipient, bool includeInGarbageCollection, bool isInactive)
        {
            int num = 1;

            if (includeInGarbageCollection)
            {
                num |= 4;
            }
            if (isInactive)
            {
                num |= 8;
            }
            recipient.propertyBag.SetField(ADRecipientSchema.RecipientSoftDeletedStatus, num);
            recipient.propertyBag.SetField(ADRecipientSchema.WhenSoftDeleted, new DateTime?(DateTime.UtcNow));
            int num2 = (int)recipient.propertyBag[ADRecipientSchema.TransportSettingFlags];

            num2 |= 8;
            recipient.propertyBag.SetField(ADRecipientSchema.TransportSettingFlags, num2);
            if (!"Soft Deleted Objects".Equals(recipient.Id.Parent.Name))
            {
                ADObjectId childId = recipient.Id.Parent.GetChildId("OU", "Soft Deleted Objects");
                childId = childId.GetChildId(SoftDeletedTaskHelper.ReservedADNameStringRegex.Replace(recipient.Id.Name, string.Empty));
                string userPrincipalName = recipient.UserPrincipalName;
                session.SessionSettings.IncludeSoftDeletedObjects = true;
                if (session.Read(childId) != null)
                {
                    childId = childId.Parent.GetChildId(MailboxTaskHelper.AppendRandomNameSuffix(childId.Name));
                }
                session.SessionSettings.IncludeSoftDeletedObjects = false;
                recipient.SetId(childId);
                recipient.UserPrincipalName = userPrincipalName;
            }
        }
Beispiel #2
0
        internal static string GetUniqueNameForRecovery(IRecipientSession session, string name, ADObjectId id)
        {
            string      result      = name;
            ADRecipient adrecipient = session.Read(id.Parent.Parent.GetChildId(name));

            if (adrecipient != null)
            {
                result = MailboxTaskHelper.AppendRandomNameSuffix(name);
            }
            return(result);
        }