// Token: 0x06000E74 RID: 3700 RVA: 0x000452C4 File Offset: 0x000434C4 public static ADRawEntry FindADRawEntryByPuid(ulong puid, Guid mdbGuid, bool readOnly, IEnumerable <MbxPropertyDefinition> properties) { Guid exchangeGuidFromPuid = ConsumerIdentityHelper.GetExchangeGuidFromPuid(puid); ADObjectId adobjectIdFromPuid = ConsumerIdentityHelper.GetADObjectIdFromPuid(puid); List <ValidationError> errors = new List <ValidationError>(); return(MbxRecipientSession.ReadUserInformationRecord(adobjectIdFromPuid, mdbGuid, exchangeGuidFromPuid, readOnly, properties, errors)); }
private static bool TrySaveChanges(IRecipientSession session, ulong puid, ADPropertyDefinition prop, object addedValue, object removedValue, Action <string> logAction, Action <string> warningLogAction) { if (addedValue != null && removedValue != null) { throw new InvalidOperationException("You must set a value to addedValue or removedValue, not both."); } object obj = addedValue; bool result; try { ADUser aduser = new ADUser(); aduser.SetId(ConsumerIdentityHelper.GetADObjectIdFromPuid(puid)); if (prop.IsMultivalued) { if (addedValue != null) { ((MultiValuedPropertyBase)aduser[prop]).Add(addedValue); } else if (removedValue != null) { ((MultiValuedPropertyBase)aduser[prop]).Remove(removedValue); obj = removedValue; } } else { aduser[prop] = addedValue; } session.Save(aduser); result = true; } catch (Exception ex) { logAction(string.Format("Error writing value. PUID: {0} Property: {1} Value: {2} Error: {3}", new object[] { ConsumerIdentityHelper.GetExchangeGuidFromPuid(puid), prop.Name, obj ?? "<NULL>", ex.ToString() })); warningLogAction(string.Format("Error writing value. PUID: {0} Property: {1} Value: {2} Error: {3}", new object[] { ConsumerIdentityHelper.GetExchangeGuidFromPuid(puid), prop.Name, obj ?? "<NULL>", ex.Message })); result = false; } return(result); }
private static bool PopulateMservPuidRecordProperties(ADUser user, ulong puid, bool makePrimary, bool makeSecondary, PropertyBag propertiesToSet) { bool result = false; user.SetId(ConsumerIdentityHelper.GetADObjectIdFromPuid(puid)); if (propertiesToSet.IsModified(ADMailboxRecipientSchema.Database)) { user.Database = (ADObjectId)propertiesToSet[ADMailboxRecipientSchema.Database]; result = true; } if (makePrimary) { user[ADUserSchema.PrimaryMailboxSource] = PrimaryMailboxSourceType.Exo; result = true; } else if (makeSecondary) { user[ADUserSchema.PrimaryMailboxSource] = PrimaryMailboxSourceType.Hotmail; result = true; } return(result); }
private static bool PopulateConsumerMailboxProperties(ADRawEntry user, ulong puid, IEnumerable <ADPropertyDefinition> propertiesToSet, PropertyBag propertyValuesBag, bool setMbxPropertyDefinition = false) { bool result = false; if (!setMbxPropertyDefinition) { user.SetId(ConsumerIdentityHelper.GetADObjectIdFromPuid(puid)); } foreach (ADPropertyDefinition adpropertyDefinition in propertiesToSet) { if (propertyValuesBag.IsModified(adpropertyDefinition)) { if (adpropertyDefinition.IsMultivalued) { MultiValuedPropertyBase multiValuedPropertyBase = setMbxPropertyDefinition ? ((MultiValuedPropertyBase)user[adpropertyDefinition.MbxPropertyDefinition]) : ((MultiValuedPropertyBase)user[adpropertyDefinition]); MultiValuedPropertyBase multiValuedPropertyBase2 = (MultiValuedPropertyBase)propertyValuesBag[adpropertyDefinition]; foreach (object item in multiValuedPropertyBase2.Added) { multiValuedPropertyBase.Add(item); } foreach (object item2 in multiValuedPropertyBase2.Removed) { multiValuedPropertyBase.Remove(item2); } } else if (setMbxPropertyDefinition) { user[adpropertyDefinition.MbxPropertyDefinition] = propertyValuesBag[adpropertyDefinition]; } else { user[adpropertyDefinition] = propertyValuesBag[adpropertyDefinition]; } result = true; } } return(result); }
// Token: 0x06000EFF RID: 3839 RVA: 0x000484C4 File Offset: 0x000466C4 private ADRawEntry ADRawEntryFromMservRecords(ulong puid, IList <MservRecord> mservRecords, IEnumerable <MServPropertyDefinition> properties, string originatingServerName, List <ValidationError> errors) { ADObjectId adobjectIdFromPuid = ConsumerIdentityHelper.GetADObjectIdFromPuid(puid); ADPropertyBag adpropertyBag = new ADPropertyBag(this.isReadOnly, 16); adpropertyBag.SetField(ADObjectSchema.Id, adobjectIdFromPuid); adpropertyBag.SetField(MServRecipientSchema.Puid, puid); foreach (MservRecord mservRecord in mservRecords) { object value = mservRecord; ProviderPropertyDefinition providerPropertyDefinition; switch (mservRecord.ResourceId) { case 0: if (mservRecord.SourceKey == null) { providerPropertyDefinition = MServRecipientSchema.MservPrimaryRecord; } else { providerPropertyDefinition = MServRecipientSchema.MservEmailAddressesRecord; value = new MultiValuedProperty <MservRecord> { mservRecord }; } break; case 1: providerPropertyDefinition = MServRecipientSchema.MservSoftDeletedPrimaryRecord; break; case 2: case 3: case 5: case 6: goto IL_D0; case 4: providerPropertyDefinition = MServRecipientSchema.MservCalendarRecord; break; case 7: providerPropertyDefinition = MServRecipientSchema.MservSecondaryRecord; break; case 8: providerPropertyDefinition = MServRecipientSchema.MservSoftDeletedCalendarRecord; break; default: goto IL_D0; } PropertyValidationError propertyValidationError = providerPropertyDefinition.ValidateValue(value, true); if (propertyValidationError != null) { errors.Add(propertyValidationError); } adpropertyBag.SetField(providerPropertyDefinition, value); continue; IL_D0: throw new NotSupportedException("Unexpected record received:" + mservRecord.ToString()); } ADRawEntry adrawEntry = new ADRawEntry(adpropertyBag); adrawEntry.OriginatingServer = originatingServerName; adrawEntry.WhenReadUTC = new DateTime?(DateTime.UtcNow); adrawEntry.IsCached = false; adrawEntry.ValidateRead(errors, properties); adrawEntry.ResetChangeTracking(true); return(adrawEntry); }
private static object ObjectIdGetter(IPropertyBag propertyBag) { ulong puid = (ulong)propertyBag[MServRecipientSchema.Puid]; return(ConsumerIdentityHelper.GetADObjectIdFromPuid(puid)); }