Beispiel #1
0
        private static object DatabaseGetter(IPropertyBag propertyBag)
        {
            bool        flag;
            MservRecord record = MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Exo, out flag);

            if (record == null)
            {
                return(null);
            }
            string exoForestFqdn = record.ExoForestFqdn;

            if (!Fqdn.IsValidFqdn(exoForestFqdn))
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculatePropertyGeneric(MServRecipientSchema.Database.Name), MServRecipientSchema.Database, record));
            }
            Guid guid;

            try
            {
                guid = new Guid(record.ExoDatabaseId);
            }
            catch (Exception ex)
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty(MServRecipientSchema.Database.Name, ex.Message), MServRecipientSchema.Database, record), ex);
            }
            return(new ADObjectId(guid, exoForestFqdn));
        }
Beispiel #2
0
        private static object IsDeletedGetter(IPropertyBag propertyBag)
        {
            MservRecord mservRecord  = (MservRecord)propertyBag[MServRecipientSchema.MservPrimaryRecord];
            MservRecord mservRecord2 = (MservRecord)propertyBag[MServRecipientSchema.MservSecondaryRecord];
            MservRecord mservRecord3 = (MservRecord)propertyBag[MServRecipientSchema.MservSoftDeletedPrimaryRecord];

            return(mservRecord == null && mservRecord2 == null && mservRecord3 != null);
        }
Beispiel #3
0
        private static MservRecord GetRecord(IPropertyBag propertyBag, MservValueFormat format, out bool isPrimary)
        {
            MServPropertyDefinition mservPropertyDefinition;
            MservRecord             record = MServRecipientSchema.GetRecord(propertyBag, format, false, out mservPropertyDefinition);

            isPrimary = (mservPropertyDefinition == MServRecipientSchema.MservPrimaryRecord);
            return(record);
        }
Beispiel #4
0
        // Token: 0x06000F20 RID: 3872 RVA: 0x00048E14 File Offset: 0x00047014
        public MservRecord GetUpdatedRecordFlag(bool flagValue, byte mask)
        {
            byte        flags        = flagValue ? (this.Flags | mask) : (this.Flags & ~mask);
            MservRecord mservRecord  = new MservRecord(this.Key, this.ResourceId, this.Value, this.SourceKey, flags);
            MservRecord mservRecord2 = mservRecord;

            mservRecord2.UpdatedFlagsMask |= mask;
            return(mservRecord);
        }
Beispiel #5
0
        private static void UpdateRecordFlag(bool value, byte mask, IPropertyBag propertyBag, MServPropertyDefinition propertyDefinition)
        {
            MservRecord mservRecord = (MservRecord)propertyBag[propertyDefinition];

            if (mservRecord != null)
            {
                MservRecord updatedRecordFlag = mservRecord.GetUpdatedRecordFlag(value, mask);
                propertyBag[propertyDefinition] = updatedRecordFlag;
            }
        }
Beispiel #6
0
        private static string GetPuidKey(IPropertyBag propertyBag)
        {
            object obj = propertyBag[MServRecipientSchema.Puid];

            if (obj == null)
            {
                throw new ArgumentNullException("Puid");
            }
            return(MservRecord.KeyFromPuid((ulong)obj));
        }
Beispiel #7
0
        private static object SatchmoDGroupGetter(IPropertyBag propertyBag)
        {
            bool        flag;
            MservRecord record = MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Hotmail, out flag);

            if (record == null)
            {
                return(string.Empty);
            }
            return(record.HotmailDGroupId);
        }
Beispiel #8
0
        internal static void PrimaryMailboxSourceSetter(object value, IPropertyBag propertyBag)
        {
            bool        flag;
            MservRecord record = MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Exo, out flag);
            bool        flag2;
            MservRecord record2 = MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Hotmail, out flag2);

            if (record != null)
            {
                bool isEmpty = record.IsEmpty;
            }
            if (record2 != null)
            {
                bool isEmpty2 = record2.IsEmpty;
            }
            switch ((PrimaryMailboxSourceType)value)
            {
            case PrimaryMailboxSourceType.None:
                if ((flag && !record.IsEmpty) || (flag2 && !record2.IsEmpty))
                {
                    throw new DataValidationException(new PropertyValidationError(DirectoryStrings.MailboxPropertiesMustBeClearedFirst(flag ? record : record2), MServRecipientSchema.MservPrimaryRecord, flag ? record : record2));
                }
                return;

            case PrimaryMailboxSourceType.Hotmail:
                if (flag2)
                {
                    return;
                }
                if (flag)
                {
                    propertyBag[MServRecipientSchema.MservPrimaryRecord]   = record.GetUpdatedRecord(7);
                    propertyBag[MServRecipientSchema.MservSecondaryRecord] = record2.GetUpdatedRecord(0);
                    return;
                }
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotMakePrimary(record2, "Exo"), MServRecipientSchema.MservPrimaryRecord, record2));

            case PrimaryMailboxSourceType.Exo:
                if (flag)
                {
                    return;
                }
                if (flag2)
                {
                    propertyBag[MServRecipientSchema.MservPrimaryRecord]   = record2.GetUpdatedRecord(7);
                    propertyBag[MServRecipientSchema.MservSecondaryRecord] = record.GetUpdatedRecord(0);
                    return;
                }
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotMakePrimary(record, "Hotmail"), MServRecipientSchema.MservPrimaryRecord, record));

            default:
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.ExArgumentOutOfRangeException("PrimaryMailboxSource", value), MServRecipientSchema.PrimaryMailboxSource, value));
            }
        }
Beispiel #9
0
 private static GetterDelegate MservFlagGetterDelegate(byte mask, ProviderPropertyDefinition propertyDefinition)
 {
     return(delegate(IPropertyBag propertyBag)
     {
         MservRecord mservRecord = (MservRecord)propertyBag[MServRecipientSchema.MservPrimaryRecord];
         if (mservRecord == null)
         {
             return propertyDefinition.DefaultValue;
         }
         bool value = 0 != (mask & mservRecord.Flags);
         return BoxedConstants.GetBool(value);
     });
 }
Beispiel #10
0
        internal static void SatchmoDGroupSetter(object value, IPropertyBag propertyBag)
        {
            MServPropertyDefinition propertyDefinition;
            MservRecord             record = MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Hotmail, true, out propertyDefinition);
            MservRecord             value2;

            if (record.HotmailClusterIp == null && value == null)
            {
                value2 = null;
            }
            else
            {
                value2 = record.GetUpdatedHotmailRecord(record.HotmailClusterIp, (string)value);
            }
            propertyBag[propertyDefinition] = value2;
        }
Beispiel #11
0
        private static object SatchmoClusterIpGetter(IPropertyBag propertyBag)
        {
            bool        flag;
            MservRecord record = MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Hotmail, out flag);

            if (record == null || record.HotmailClusterIp == null)
            {
                return(null);
            }
            IPAddress result;

            if (!IPAddress.TryParse(record.HotmailClusterIp, out result))
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculatePropertyGeneric(MServRecipientSchema.SatchmoClusterIp.Name), MServRecipientSchema.SatchmoClusterIp, record));
            }
            return(result);
        }
Beispiel #12
0
        internal static void DatabaseSetter(object value, IPropertyBag propertyBag)
        {
            MServPropertyDefinition propertyDefinition;
            MservRecord             record = MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Exo, true, out propertyDefinition);
            ADObjectId  adobjectId         = (ADObjectId)value;
            MservRecord value2;

            if (adobjectId == null)
            {
                value2 = null;
            }
            else
            {
                value2 = record.GetUpdatedExoRecord(adobjectId.PartitionFQDN, adobjectId.ObjectGuid.ToString());
            }
            propertyBag[propertyDefinition] = value2;
        }
Beispiel #13
0
        private static object RecipientDisplayTypeGetter(IPropertyBag propertyBag)
        {
            bool flag;

            MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Exo, out flag);
            if (flag)
            {
                return(Microsoft.Exchange.Data.Directory.Recipient.RecipientDisplayType.MailboxUser);
            }
            MservRecord record = MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Hotmail, out flag);

            if (flag && record.IsXmr)
            {
                return(Microsoft.Exchange.Data.Directory.Recipient.RecipientDisplayType.MailboxUser);
            }
            return(null);
        }
Beispiel #14
0
        private static MservRecord GetRecord(IPropertyBag propertyBag, MservValueFormat format, bool createIfMissing, out MServPropertyDefinition recordPropDef)
        {
            MservRecord mservRecord  = (MservRecord)propertyBag[MServRecipientSchema.MservPrimaryRecord];
            MservRecord mservRecord2 = (MservRecord)propertyBag[MServRecipientSchema.MservSecondaryRecord];

            if (mservRecord != null && mservRecord.ValueFormat == format)
            {
                recordPropDef = MServRecipientSchema.MservPrimaryRecord;
                return(mservRecord);
            }
            if (mservRecord2 != null && mservRecord2.ValueFormat == format)
            {
                recordPropDef = MServRecipientSchema.MservSecondaryRecord;
                return(mservRecord2);
            }
            if (!createIfMissing)
            {
                recordPropDef = null;
                return(null);
            }
            bool flag = mservRecord == null;

            if (mservRecord != null && mservRecord2 != null)
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CrossRecordMismatch(mservRecord, mservRecord2), MServRecipientSchema.MservPrimaryRecord, mservRecord));
            }
            string puidKey    = MServRecipientSchema.GetPuidKey(propertyBag);
            byte   resourceId = flag ? 0 : 7;

            recordPropDef = (flag ? MServRecipientSchema.MservPrimaryRecord : MServRecipientSchema.MservSecondaryRecord);
            byte flags = 0;

            if (!flag)
            {
                flags = mservRecord.Flags;
            }
            MservRecord mservRecord3 = new MservRecord(puidKey, resourceId, null, null, flags);

            propertyBag[recordPropDef] = mservRecord3;
            return(mservRecord3);
        }
Beispiel #15
0
        private static object PrimaryMailboxSourceGetter(IPropertyBag propertyBag)
        {
            bool flag;

            MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Exo, out flag);
            if (flag)
            {
                return(PrimaryMailboxSourceType.Exo);
            }
            MservRecord record = MServRecipientSchema.GetRecord(propertyBag, MservValueFormat.Hotmail, out flag);

            if (!flag)
            {
                return(PrimaryMailboxSourceType.None);
            }
            if (record.IsXmr)
            {
                return(PrimaryMailboxSourceType.Exo);
            }
            return(PrimaryMailboxSourceType.Hotmail);
        }
Beispiel #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;
                    }
                }
            }
        }
Beispiel #17
0
        // Token: 0x06000F00 RID: 3840 RVA: 0x00048644 File Offset: 0x00046844
        public void Save(ADRawEntry instanceToSave)
        {
            bool flag;
            List <MservChange> list = this.BuildChangeList(instanceToSave, out flag);

            if (flag)
            {
                this.SwapRecords(list[0], list[1]);
                return;
            }
            foreach (MservChange mservChange in list)
            {
                MservRecord newValue = mservChange.NewValue;
                MservRecord oldValue = mservChange.OldValue;
                if (newValue != null && oldValue == null)
                {
                    if (newValue.SourceKey == null)
                    {
                        this.mservClient.AddRecord(newValue.Key, newValue.ResourceId, newValue.Value, newValue.Flags);
                    }
                    else
                    {
                        this.mservClient.AddAlias(newValue.Key, newValue.SourceKey, newValue.ResourceId);
                    }
                }
                else if (newValue != null && oldValue != null)
                {
                    this.mservClient.UpdateExistingRecord(newValue.Key, newValue.ResourceId, newValue.Value, oldValue.Value, newValue.Flags, newValue.UpdatedFlagsMask, oldValue.Flags, newValue.UpdatedFlagsMask);
                }
                else if (oldValue.SourceKey == null)
                {
                    this.mservClient.DeleteRecord(oldValue.Key, oldValue.ResourceId, oldValue.Value, oldValue.Flags, byte.MaxValue);
                }
                else
                {
                    this.mservClient.DeleteAlias(oldValue.Key, oldValue.SourceKey, oldValue.ResourceId);
                }
            }
        }
Beispiel #18
0
        // Token: 0x06000EFC RID: 3836 RVA: 0x0004835C File Offset: 0x0004655C
        private ADRawEntry LookUpByKey(string key, IEnumerable <MServPropertyDefinition> properties)
        {
            List <MservRecord> list = new List <MservRecord>(4);
            string             text;
            MservRecord        mservRecord = this.Read(key, 0, out text);

            if (mservRecord != null)
            {
                list.Add(mservRecord);
                if (!string.IsNullOrEmpty(text))
                {
                    MservRecord item = new MservRecord(text, mservRecord.ResourceId, null, mservRecord.Key, mservRecord.Flags);
                    list.Add(item);
                }
            }
            if (mservRecord != null)
            {
                string      text2;
                MservRecord mservRecord2 = this.Read((mservRecord == null) ? key : mservRecord.Key, 7, out text2);
                if (mservRecord2 != null)
                {
                    list.Add(mservRecord2);
                }
            }
            if (list.Count == 0)
            {
                return(null);
            }
            ulong puid;

            if (!list[0].TryGetPuid(out puid))
            {
                return(null);
            }
            return(this.ADRawEntryFromMservRecords(puid, list, properties, this.mservEndpointConfig, new List <ValidationError>()));
        }
Beispiel #19
0
 // Token: 0x06000EF8 RID: 3832 RVA: 0x000482D0 File Offset: 0x000464D0
 public MservChange(MservRecord newValue, MservRecord oldValue)
 {
     this.NewValue = newValue;
     this.OldValue = oldValue;
 }
Beispiel #20
0
        // Token: 0x06000F02 RID: 3842 RVA: 0x0004881C File Offset: 0x00046A1C
        private List <MservChange> BuildChangeList(ADRawEntry instanceToSave, out bool isSwap)
        {
            List <MservChange> list = new List <MservChange>();

            isSwap = false;
            foreach (PropertyDefinition propertyDefinition in MservRecipientSession.MServRecipientSchema.AllProperties)
            {
                MServPropertyDefinition mservPropertyDefinition = (MServPropertyDefinition)propertyDefinition;
                if (!mservPropertyDefinition.IsCalculated && (instanceToSave.propertyBag.IsChanged(mservPropertyDefinition) || mservPropertyDefinition.IsMultivalued) && !mservPropertyDefinition.IsTaskPopulated)
                {
                    object obj = null;
                    instanceToSave.propertyBag.TryGetField(mservPropertyDefinition, ref obj);
                    if (!mservPropertyDefinition.IsMultivalued || (obj != null && ((MultiValuedPropertyBase)obj).Changed))
                    {
                        ExTraceGlobals.ADSaveTracer.TraceDebug <string>((long)this.GetHashCode(), "MservRecipientSession::Save - updating {0}", mservPropertyDefinition.Name);
                        if (!mservPropertyDefinition.IsMultivalued)
                        {
                            object obj2;
                            instanceToSave.propertyBag.TryGetOriginalValue(mservPropertyDefinition, out obj2);
                            MservRecord mservRecord  = (MservRecord)obj;
                            MservRecord mservRecord2 = (MservRecord)obj2;
                            if (mservRecord != null && mservRecord.IsEmpty)
                            {
                                mservRecord = null;
                            }
                            list.Add(new MservChange(mservRecord, mservRecord2));
                            if (mservRecord != null && mservRecord2 != null && mservRecord.ResourceId != mservRecord2.ResourceId)
                            {
                                isSwap = true;
                                if (mservRecord.Value != mservRecord2.Value)
                                {
                                    throw new MservOperationException(DirectoryStrings.SwapShouldNotChangeValues(mservRecord2.Value, mservRecord2.ResourceId, mservRecord.Value, mservRecord.ResourceId));
                                }
                            }
                        }
                        else
                        {
                            MultiValuedPropertyBase multiValuedPropertyBase = (MultiValuedPropertyBase)obj;
                            if (multiValuedPropertyBase.WasCleared)
                            {
                                throw new MservOperationException(DirectoryStrings.NoResetOrAssignedMvp);
                            }
                            foreach (object obj3 in multiValuedPropertyBase.Removed)
                            {
                                list.Add(new MservChange(null, (MservRecord)obj3));
                            }
                            foreach (object obj4 in multiValuedPropertyBase.Added)
                            {
                                list.Add(new MservChange((MservRecord)obj4, null));
                            }
                        }
                    }
                }
            }
            if (isSwap)
            {
                if (list.Count != 2)
                {
                    throw new MservOperationException(DirectoryStrings.BadSwapOperationCount(list.Count));
                }
                if (list[0].OldValue.ResourceId != list[1].NewValue.ResourceId || list[0].NewValue.ResourceId != list[1].OldValue.ResourceId)
                {
                    throw new MservOperationException(DirectoryStrings.BadSwapResourceIds(list[0].OldValue.ResourceId, list[0].NewValue.ResourceId, list[1].OldValue.ResourceId, list[1].NewValue.ResourceId));
                }
            }
            return(list);
        }
Beispiel #21
0
 // Token: 0x06000EFA RID: 3834 RVA: 0x00048340 File Offset: 0x00046540
 public ADRawEntry FindADRawEntryByPuid(ulong puid, IEnumerable <MServPropertyDefinition> properties)
 {
     return(this.LookUpByKey(MservRecord.KeyFromPuid(puid), properties));
 }
Beispiel #22
0
 // Token: 0x06000EFE RID: 3838 RVA: 0x0004849C File Offset: 0x0004669C
 private void SwapRecords(string key, MservRecord record1, MservRecord record2)
 {
     this.mservClient.SwapRecords(key, record1.ResourceId, record1.Value, record2.ResourceId, record2.Value);
 }
Beispiel #23
0
 // Token: 0x06000F26 RID: 3878 RVA: 0x00048FA0 File Offset: 0x000471A0
 public bool SameRecord(MservRecord record)
 {
     return(record != null && string.Equals(this.Key, record.Key, StringComparison.OrdinalIgnoreCase) && this.ResourceId == record.ResourceId);
 }