protected static RecipientItemType GetRecipientType(RuleEvaluationContextBase context) { RecipientItemType result = RecipientItemType.Unknown; string text = context.PropertyBag[StoreObjectSchema.ItemClass] as string; if (!string.IsNullOrEmpty(text) && ObjectClass.IsReport(text)) { result = RecipientItemType.To; } else { RecipientCollection recipients = context.Message.Recipients; for (int i = 0; i < recipients.Count; i++) { if (recipients[i].Participant.RoutingType != null && recipients[i].Participant.EmailAddress != null) { ProxyAddress addressToResolve = ProxyAddress.Parse(recipients[i].Participant.RoutingType, recipients[i].Participant.EmailAddress); if (RuleUtil.IsSameUser(context, context.RecipientCache, addressToResolve, context.Recipient)) { result = recipients[i].RecipientItemType; break; } } } } return(result); }
// Token: 0x06001A79 RID: 6777 RVA: 0x0006EA5C File Offset: 0x0006CC5C public virtual bool Remove(ProxyAddress proxyAddress) { bool result2; lock (this.dictionaryLock) { Result <TEntry> result; if (this.dictionary.TryGetValue(proxyAddress, out result)) { this.dictionary.Remove(proxyAddress); if (result.Data == null) { result2 = true; } else { if (ADRecipientCache <TEntry> .IsExAddress(proxyAddress)) { this.dictionary.Remove(ADRecipientCache <TEntry> .GetPrimarySmtpAddress(result.Data)); } else if (ADRecipientCache <TEntry> .IsSmtpAddress(proxyAddress)) { this.dictionary.Remove(ProxyAddress.Parse(ProxyAddressPrefix.LegacyDN.PrimaryPrefix, ADRecipientCache <TEntry> .GetLegacyExchangeDN(result.Data))); } result2 = true; } } else { result2 = false; } } return(result2); }
// Token: 0x06001A91 RID: 6801 RVA: 0x0006F524 File Offset: 0x0006D724 private void AddCacheEntry(ProxyAddress proxyAddress, Result <TEntry> result, bool isLockRequired, bool populateCalculatedProperties) { TEntry data = result.Data; if (populateCalculatedProperties && data != null) { this.PopulateCalculatedProperties(data); } this.SetEntry(proxyAddress, result, isLockRequired); if (data == null) { return; } ProxyAddress primarySmtpAddress = ADRecipientCache <TEntry> .GetPrimarySmtpAddress(data); if (ADRecipientCache <TEntry> .IsSmtpAddress(proxyAddress)) { ProxyAddress proxyAddress2 = ProxyAddress.Parse(ProxyAddressPrefix.LegacyDN.PrimaryPrefix, ADRecipientCache <TEntry> .GetLegacyExchangeDN(data)); this.SetEntry(proxyAddress2, result, isLockRequired); if (null != primarySmtpAddress && primarySmtpAddress != proxyAddress) { this.SetEntry(primarySmtpAddress, result, isLockRequired); return; } } else if (primarySmtpAddress != null) { this.SetEntry(primarySmtpAddress, result, isLockRequired); } }
private static ProxyAddress GetLegacyProxyAddress(IRuleEvaluationContext context, byte[] entryId) { if (entryId.Length == 0) { context.TraceDebug("GetLegacyProxyAddress: entry ID is zero-length"); return(null); } ParticipantEntryId participantEntryId = ParticipantEntryId.TryFromEntryId(entryId); context.TraceDebug <string>("GetLegacyProxyAddress: entry ID is {0}", participantEntryId.GetType().Name); Participant.Builder builder = new Participant.Builder(); builder.SetPropertiesFrom(participantEntryId); Participant participant = builder.ToParticipant(); string routingType = participant.RoutingType; string emailAddress = participant.EmailAddress; if (routingType != "EX" || string.IsNullOrEmpty(emailAddress)) { context.TraceDebug <string, string>("GetLegacyProxyAddress: returning null, address is {0}:{1}", routingType ?? "(null)", emailAddress ?? "(null)"); return(null); } ProxyAddress proxyAddress = ProxyAddress.Parse(routingType, emailAddress); if (proxyAddress is InvalidProxyAddress) { context.TraceDebug <string>("GetLegacyProxyAddress: legacyDN {0} is not valid", emailAddress); return(null); } context.TraceDebug <string>("GetLegacyProxyAddress: returning EX:{0}", emailAddress); return(proxyAddress); }
public void UpdateEmailAddresses(Mailbox mailbox) { ProxyAddressCollection emailAddresses = mailbox.EmailAddresses; for (int i = emailAddresses.Count - 1; i >= 0; i--) { if (emailAddresses[i] is SmtpProxyAddress && !((SmtpProxyAddress)emailAddresses[i]).IsPrimaryAddress) { emailAddresses.RemoveAt(i); } } if (this.EmailAddresses != null) { foreach (string text in this.EmailAddresses) { ProxyAddress proxyAddress = ProxyAddress.Parse(text); if (proxyAddress is InvalidProxyAddress) { InvalidProxyAddress invalidProxyAddress = proxyAddress as InvalidProxyAddress; throw new FaultException(invalidProxyAddress.ParseException.Message); } if (emailAddresses.Contains(proxyAddress)) { throw new FaultException(string.Format(OwaOptionStrings.DuplicateProxyAddressError, text)); } emailAddresses.Add(proxyAddress); } } base[MailEnabledRecipientSchema.EmailAddresses] = emailAddresses; }
protected override void PrepareUserObject(ADUser user) { TaskLogger.LogEnter(); if (base.WindowsLiveID == null && base.SoftDeletedObject == null && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.WindowsLiveID.Enabled&& !RecipientTaskHelper.SMTPAddressCheckWithAcceptedDomain(this.ConfigurationSession, user.OrganizationId, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache)) { base.WriteError(new RecipientTaskException(Strings.ErrorWindowsLiveIdRequired(user.Name)), ExchangeErrorCategory.Client, null); } if (base.WindowsLiveID != null && base.WindowsLiveID.SmtpAddress != SmtpAddress.Empty) { if (this.ExternalEmailAddress == null) { user.ExternalEmailAddress = ProxyAddress.Parse(base.WindowsLiveID.SmtpAddress.ToString()); } user.UserPrincipalName = base.WindowsLiveID.SmtpAddress.ToString(); base.IsSetRandomPassword = (base.SoftDeletedObject == null || base.IsSetRandomPassword); } if (string.IsNullOrEmpty(user.UserPrincipalName)) { user.UserPrincipalName = RecipientTaskHelper.GenerateUniqueUserPrincipalName(base.TenantGlobalCatalogSession, user.Name, this.ConfigurationSession.GetDefaultAcceptedDomain().DomainName.Domain, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); } if (base.SoftDeletedObject == null) { if (base.Fields.IsModified(MailUserSchema.RemotePowerShellEnabled)) { user.RemotePowerShellEnabled = this.RemotePowerShellEnabled; } else { user.RemotePowerShellEnabled = true; } MailUserTaskHelper.ValidateExternalEmailAddress(user, this.ConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache); } if (base.Fields.IsChanged(ADRecipientSchema.MailboxProvisioningConstraint)) { user.MailboxProvisioningConstraint = this.MailboxProvisioningConstraint; } if (base.Fields.IsChanged(ADRecipientSchema.MailboxProvisioningPreferences)) { user.MailboxProvisioningPreferences = this.MailboxProvisioningPreferences; } if (user.MailboxProvisioningConstraint != null) { MailboxTaskHelper.ValidateMailboxProvisioningConstraintEntries(new MailboxProvisioningConstraint[] { user.MailboxProvisioningConstraint }, base.DomainController, delegate(string message) { base.WriteVerbose(new LocalizedString(message)); }, new Task.ErrorLoggerDelegate(base.WriteError)); } if (user.MailboxProvisioningPreferences != null) { MailboxTaskHelper.ValidateMailboxProvisioningConstraintEntries(user.MailboxProvisioningPreferences, base.DomainController, delegate(string message) { base.WriteVerbose(new LocalizedString(message)); }, new Task.ErrorLoggerDelegate(base.WriteError)); } base.PrepareUserObject(user); TaskLogger.LogExit(); }
internal static bool TryGetRoutingAddressFromAD(IADRecipientCache recipientCache, string address, string type, out RoutingAddress result) { ProxyAddress proxyAddress = ProxyAddress.Parse(type, address); if (proxyAddress is InvalidProxyAddress) { TraceHelper.StoreDriverTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "Proxy address is invalid"); return(false); } Result <ADRawEntry> result2 = recipientCache.FindAndCacheRecipient(proxyAddress); if (result2.Data != null) { string primarySmtpAddress = SubmissionItemUtils.GetPrimarySmtpAddress(result2.Data); if (string.IsNullOrEmpty(primarySmtpAddress)) { TraceHelper.StoreDriverTracer.TracePass <string, string>(TraceHelper.MessageProbeActivityId, 0L, "Primary SMTP address for \"{0}:{1}\" is invalid or missing", address, type); return(false); } TraceHelper.StoreDriverTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "Use primary smtp address {0}", primarySmtpAddress); result = new RoutingAddress(primarySmtpAddress); return(true); } else { if (result2.Error != null && result2.Error != ProviderError.NotFound) { TraceHelper.StoreDriverTracer.TracePass <ProviderError>(TraceHelper.MessageProbeActivityId, 0L, "Failed to look up due to error :{0}", result2.Error); return(false); } TraceHelper.StoreDriverTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "The address doesn't exist in AD"); return(false); } }
internal static ProxyAddress GetProxyAddressFromSearchKey(object searchKey) { byte[] array = searchKey as byte[]; if (array == null || array.Length == 0 || array[0] == 0) { return(null); } int num = array.Length; if (array[num - 1] == 0) { num--; } string @string = RuleUtil.asciiEncoding.GetString(array, 0, num); ProxyAddress proxyAddress = ProxyAddress.Parse(@string); if (proxyAddress is InvalidProxyAddress && string.Equals(proxyAddress.PrefixString, ProxyAddressPrefix.Smtp.PrimaryPrefix, StringComparison.OrdinalIgnoreCase)) { string text = StringUtil.Unwrap(proxyAddress.ValueString); if (!object.ReferenceEquals(text, proxyAddress.ValueString)) { proxyAddress = ProxyAddress.Parse(proxyAddress.PrefixString, text); } } return(proxyAddress); }
private ProxyAddress[] GetProxyAddressArray(EmailAddress[] emailAddressArray, int startIndex, int size, out List <int> indexList) { List <ProxyAddress> list = new List <ProxyAddress>(size); indexList = new List <int>(size); for (int i = 0; i < size; i++) { EmailAddress emailAddress = emailAddressArray[startIndex + i]; if (emailAddress == null) { ExTraceGlobals.RequestRoutingTracer.TraceError <object, int>((long)this.GetHashCode(), "{0}: Null email address detected at position {1}.", TraceContext.Get(), i); } else { ProxyAddress proxyAddress = ProxyAddress.Parse(emailAddress.RoutingType, emailAddress.Address); if (proxyAddress is InvalidProxyAddress) { ExTraceGlobals.RequestRoutingTracer.TraceError <object, EmailAddress>((long)this.GetHashCode(), "{0}: The specified address {1} is not a valid proxy address.", TraceContext.Get(), emailAddress); } else { list.Add(proxyAddress); indexList.Add(i); } } } return(list.ToArray()); }
public static TrackedUser Create(string smtpAddress, IRecipientSession galSession) { ProxyAddress proxyAddress = ProxyAddress.Parse(smtpAddress); ADRecipient adrecipient = null; try { adrecipient = galSession.FindByProxyAddress(proxyAddress); } catch (NonUniqueRecipientException arg) { TraceWrapper.SearchLibraryTracer.TraceError <ProxyAddress, NonUniqueRecipientException>(0, "Create from SmtpAddress: Caught NonUniqueRecipientException when attempting to look up user for address {0}, exception: {1}", proxyAddress, arg); return(null); } if (adrecipient != null) { try { return(new TrackedUser(adrecipient)); } catch (TrackedUserCreationException arg2) { TraceWrapper.SearchLibraryTracer.TraceError <string, TrackedUserCreationException>(0, "Create from SmtpAddress: TrackedUserCreationException initializing from ADRecipient: {0}, {1}", smtpAddress, arg2); return(null); } } return(new TrackedUser(smtpAddress)); }
// Token: 0x06002E74 RID: 11892 RVA: 0x00109570 File Offset: 0x00107770 public ProxyAddress ToProxyAddress() { string addressString = this.RoutingAddress ?? string.Empty; string prefixString = this.RoutingType ?? string.Empty; return(ProxyAddress.Parse(prefixString, addressString)); }
public ProxyAddress GenerateRemoteRoutingAddress(string alias, Task.ErrorLoggerDelegate errorWriter) { if (string.IsNullOrEmpty(this.targetDeliveryDomain)) { errorWriter(new ErrorCannotFindTargetDeliveryDomainException(), ExchangeErrorCategory.Client, null); } return(ProxyAddress.Parse(alias + "@" + this.targetDeliveryDomain)); }
public static void Convert(DataRow dataRow) { foreach (object obj in dataRow.Table.Columns) { DataColumn dataColumn = (DataColumn)obj; Type type = dataColumn.ExtendedProperties["ExpectedType"] as Type; string text = dataRow[dataColumn] as string; if (type != null && dataRow[dataColumn].GetType() != type && text != null) { if (type == typeof(Unlimited <int>)) { dataRow[dataColumn] = Unlimited <int> .Parse(text); } else if (type == typeof(Unlimited <EnhancedTimeSpan>)) { dataRow[dataColumn] = Unlimited <EnhancedTimeSpan> .Parse(text); } else if (type == typeof(EmailAddressPolicyPriority)) { dataRow[dataColumn] = EmailAddressPolicyPriority.Parse(text); } else if (type == typeof(SmtpDomainWithSubdomains)) { dataRow[dataColumn] = SmtpDomainWithSubdomains.Parse(text); } else if (type == typeof(SmtpAddress)) { dataRow[dataColumn] = SmtpAddress.Parse(text); } else if (type == typeof(ProxyAddress)) { dataRow[dataColumn] = ProxyAddress.Parse(text); } else if (type == typeof(MailboxId)) { dataRow[dataColumn] = MailboxId.Parse(text); } else if (type == typeof(UMLanguage)) { dataRow[dataColumn] = UMLanguage.Parse(text); } else { if (!(type == typeof(ExchangeObjectVersion))) { throw new ArgumentException(string.Format("Type {0} is not supported convert from string yet", type)); } Regex regex = new Regex("^(?<Major>\\d+)\\.(?<Minor>\\d+) \\((?<buildMajor>\\d+)\\.(?<buildMinor>\\d+)\\.(?<buildVersion>\\d+)\\.(?<buildRevison>\\d+)\\)$"); Match match = regex.Match(text); if (!match.Success) { throw new ArgumentException(string.Format("{0} is not a valid ExchangeObjectVersion", text)); } dataRow[dataColumn] = new ExchangeObjectVersion(byte.Parse(match.Result("${Major}")), byte.Parse(match.Result("${Minor}")), byte.Parse(match.Result("${buildMajor}")), byte.Parse(match.Result("${buildMinor}")), ushort.Parse(match.Result("${buildVersion}")), ushort.Parse(match.Result("${buildRevison}"))); } } } }
public IEnumerable <ADRecipient> ResolveSmtpAddress(IEnumerable <string> addresses) { if (addresses != null && addresses.Any <string>()) { return(from recipient in this.ResolveProxyAddresses(from address in addresses select ProxyAddress.Parse(address)) where recipient != null select recipient); } return(null); }
// Token: 0x0600003D RID: 61 RVA: 0x00002744 File Offset: 0x00000944 public ADRecipient GetADRecipientByProxyAddress(string userEmail) { AnchorUtil.ThrowOnNullOrEmptyArgument(userEmail, "userEmail"); ProxyAddress proxy = ProxyAddress.Parse(userEmail); ADRecipient recipient = null; this.DoAdCallAndTranslateExceptions(delegate { recipient = this.RecipientSession.FindByProxyAddress <ADRecipient>(proxy); }, false); return(recipient); }
private static bool IsUserProxyAddress(ADUser user, string email) { ProxyAddress proxyAddress = ProxyAddress.Parse(email); foreach (ProxyAddress other in user.EmailAddresses) { if (proxyAddress.Equals(other)) { return(true); } } return(false); }
internal IEnumerable <string> Resolve(IEnumerable <string> addresses, IRecipientSession session) { if (addresses == null) { return(null); } int num = 0; List <ProxyAddress> list = new List <ProxyAddress>(); foreach (string text in addresses) { num++; if (!this.lookupCache.ContainsKey(text)) { list.Add(ProxyAddress.Parse(text)); this.lookupCache[text] = null; } } this.AddressesLookedUp = list.Count; if (list.Count > 0) { ProxyAddress[] array = list.ToArray(); Result <ADRawEntry>[] array2 = session.FindByProxyAddresses(array, BulkRecipientLookupCache.displayNameProperty); for (int i = 0; i < array.Length; i++) { ADRawEntry data = array2[i].Data; string addressString = array[i].AddressString; string value = null; if (data != null) { value = (data[ADRecipientSchema.DisplayName] as string); } if (string.IsNullOrEmpty(value)) { ProxyAddress proxyAddress; if (SmtpProxyAddress.TryDeencapsulate(array[i].AddressString, out proxyAddress) && !string.IsNullOrEmpty(proxyAddress.AddressString)) { value = proxyAddress.AddressString; } else { value = array[i].AddressString; } } this.lookupCache[addressString] = value; } } return(from address in addresses select this.lookupCache[address]); }
internal static ProxyAddress GetOriginalSender(MessageItem message) { string text = message.TryGetProperty(ItemSchema.SentRepresentingEmailAddress) as string; string text2 = message.TryGetProperty(ItemSchema.SentRepresentingType) as string; if (string.IsNullOrEmpty(text)) { return(null); } if (text2 == null) { text2 = string.Empty; } return(ProxyAddress.Parse(text2, text)); }
protected override UploadPhotoResponse InternalExecute() { DisposeGuard disposeGuard = default(DisposeGuard); Action action = null; ExchangePrincipal exchangePrincipal; MailboxSession mailboxSession; if (this.IsRequestForCurrentUser()) { exchangePrincipal = base.CallContext.AccessingPrincipal; mailboxSession = base.CallContext.SessionCache.GetMailboxSessionBySmtpAddress(this.uploadPhotoRequest.EmailAddress); } else { ProxyAddress proxyAddress = ProxyAddress.Parse(this.uploadPhotoRequest.EmailAddress); ADUser groupAdUser = this.adRecipientSession.FindByProxyAddress(proxyAddress) as ADUser; if (groupAdUser == null) { throw FaultExceptionUtilities.CreateFault(new OwaInvalidRequestException(), FaultParty.Sender); } if (groupAdUser.RecipientTypeDetails != RecipientTypeDetails.GroupMailbox || !this.IsOwnedModernGroup(groupAdUser)) { OwaInvalidOperationException exception = new OwaInvalidOperationException(string.Format("User does not have sufficient privileges on {0}", this.uploadPhotoRequest.EmailAddress)); throw FaultExceptionUtilities.CreateFault(exception, FaultParty.Sender); } if (groupAdUser.IsCached) { this.adRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(groupAdUser.OriginatingServer, false, ConsistencyMode.IgnoreInvalid, this.adRecipientSession.SessionSettings, 102, "InternalExecute", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\ServiceCommands\\UploadPhoto.cs"); } exchangePrincipal = ExchangePrincipal.FromADUser(groupAdUser, null); mailboxSession = MailboxSession.OpenAsAdmin(exchangePrincipal, base.CallContext.ClientCulture, "Client=OWA;Action=GroupPhotoUpload"); action = delegate() { DirectorySessionFactory.Default.GetTenantOrRootRecipientReadOnlySession(this.adRecipientSession, groupAdUser.OriginatingServer, 125, "InternalExecute", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\ServiceCommands\\UploadPhoto.cs").FindByProxyAddress(proxyAddress); }; disposeGuard.Add <MailboxSession>(mailboxSession); } using (disposeGuard) { PhotoRequest request = this.CreateRequest(exchangePrincipal); new PhotoUploadPipeline(UploadPhoto.PhotosConfiguration, mailboxSession, this.adRecipientSession, ExTraceGlobals.UserPhotosTracer).Upload(request, Stream.Null); if (action != null) { action(); } } return(new UploadPhotoResponse()); }
// Token: 0x060000A3 RID: 163 RVA: 0x00004148 File Offset: 0x00002348 public static ProxyAddress LegacyExchangeDNToProxyAddress(string legacyExchangeDN, string providerName) { if (legacyExchangeDN.StartsWith("/o=" + providerName, StringComparison.OrdinalIgnoreCase)) { int num = legacyExchangeDN.IndexOf("/cn="); string text = legacyExchangeDN.Substring(num + 4); if (!string.IsNullOrEmpty(text)) { return(ProxyAddress.Parse(text)); } } throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "legacyExchangeDN '{0}' is not generated by the '{1}' provider or is invalid.", new object[] { legacyExchangeDN, providerName })); }
protected virtual List <string> GetEscalatedUsersList(IMailboxSession session, out string yammerEscalateAddress) { ProxyAddress proxyAddress = ProxyAddress.Parse(session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()); if (proxyAddress is InvalidProxyAddress) { GroupEscalation.Tracer.TraceError <string>((long)this.GetHashCode(), "GroupEscalation.GetEscalatedUsersList: Escalation failed. Could not parse smtp address: {0}", session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()); yammerEscalateAddress = string.Empty; return(new List <string>()); } GroupMailboxLocator groupMailboxLocator = GroupMailboxLocator.Instantiate(session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), proxyAddress); yammerEscalateAddress = groupMailboxLocator.GetYammerGroupAddress(); EscalationGetter escalationGetter = new EscalationGetter(groupMailboxLocator, session); return(escalationGetter.Execute()); }
protected virtual IGenericADUser GetOrganizationFederatedMailbox() { IGenericADUser result = null; try { ProxyAddress proxyAddress = ProxyAddress.Parse(this.directoryAccessor.GetOrganizationFederatedMailboxIdentity(this.storeSession.GetADConfigurationSession(true, ConsistencyMode.IgnoreInvalid)).ToString()); result = this.directoryAccessor.FindByProxyAddress(this.storeSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), proxyAddress); } catch (ObjectNotFoundException) { StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_FederatedMailboxMisconfigured, string.Empty, new object[0]); ExTraceGlobals.XtcTracer.TraceError(0L, "Federated mailbox misconfigured for organization, remote mailbox access will be disabled."); throw; } return(result); }
public static OAuthCredentials Create(InternalClientContext clientContext, RequestLogger requestLogger) { ArgumentValidator.ThrowIfNull("clientContext", clientContext); OrganizationId organizationId = clientContext.OrganizationId; ADUser aduser = clientContext.ADUser; string text = FaultInjection.TraceTest <string>((FaultInjection.LIDs) 2743479613U); if (!string.IsNullOrEmpty(text)) { SmtpAddress smtpAddress = SmtpAddress.Parse(text); IRecipientSession recipientSession = DirectorySessionFactory.Default.CreateTenantRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromTenantAcceptedDomain(smtpAddress.Domain), 68, "Create", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\RequestDispatch\\OAuthCredentialsFactory.cs"); aduser = (recipientSession.FindByProxyAddress(ProxyAddress.Parse(text)) as ADUser); organizationId = aduser.OrganizationId; } OAuthCredentials oauthCredentialsForAppActAsToken = OAuthCredentials.GetOAuthCredentialsForAppActAsToken(organizationId, aduser, null); OAuthCredentialsFactory.SetCredentialsProperties(oauthCredentialsForAppActAsToken, clientContext, requestLogger); return(oauthCredentialsForAppActAsToken); }
protected override IConfigurable PrepareDataObject() { TaskLogger.LogEnter(); ADUser aduser = (ADUser)base.PrepareDataObject(); if (aduser.IsChanged(MailUserSchema.WindowsLiveID)) { SmtpAddress value = (SmtpAddress)aduser.GetOriginalObject()[MailUserSchema.WindowsLiveID]; if (value != SmtpAddress.Empty && !aduser.EmailAddresses.Contains(ProxyAddress.Parse("smtp", value.ToString()))) { aduser.EmailAddresses.Add(ProxyAddress.Parse("smtp", value.ToString())); } } if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled) { if (aduser.IsChanged(ADRecipientSchema.ExternalEmailAddress)) { MailUserTaskHelper.ValidateExternalEmailAddress(aduser, this.ConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache); } if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.WindowsLiveID.Enabled) { if (aduser.WindowsLiveID != SmtpAddress.Empty && !aduser.WindowsLiveID.Equals(aduser.UserPrincipalName)) { aduser.UserPrincipalName = aduser.WindowsLiveID.ToString(); } } else if (!aduser.IsModified(ADUserSchema.UserPrincipalName)) { aduser.UserPrincipalName = aduser.PrimarySmtpAddress.ToString(); } if (this.DataObject.IsSoftDeleted && this.DataObject.IsModified(MailUserSchema.ExchangeGuid)) { SoftDeletedTaskHelper.UpdateExchangeGuidForMailEnabledUser(this.DataObject); } if ((aduser.IsChanged(ADUserSchema.LitigationHoldEnabled) && aduser.LitigationHoldEnabled) || (aduser.IsChanged(ADRecipientSchema.InPlaceHoldsRaw) && aduser.IsInLitigationHoldOrInplaceHold) || (aduser.IsChanged(ADUserSchema.ElcMailboxFlags) && aduser.LitigationHoldEnabled)) { RecoverableItemsQuotaHelper.IncreaseRecoverableItemsQuotaIfNeeded(aduser); } } TaskLogger.LogExit(); return(aduser); }
private bool ResolveMdbParameters(MbxTransportMailItem mbxItem, ulong sessionId) { bool flag = false; ProxyAddress proxyAddress = ProxyAddress.Parse("SMTP:" + mbxItem.Recipients[0].ToString()); Result <TransportMiniRecipient> result; if (mbxItem.ADRecipientCache.TryGetValue(proxyAddress, out result) && result.Data != null) { if (result.Data.Database != null) { mbxItem.DatabaseGuid = result.Data.Database.ObjectGuid; mbxItem.DatabaseName = result.Data.Database.Name; flag = true; } else if (result.Data.RecipientTypeDetails == RecipientTypeDetails.PublicFolder) { ADObjectId adobjectId = null; if (mbxItem.Recipients[0].ExtendedProperties.TryGetValue <ADObjectId>("Microsoft.Exchange.Transport.DirectoryData.Database", out adobjectId) && adobjectId != null) { mbxItem.DatabaseGuid = adobjectId.ObjectGuid; mbxItem.DatabaseName = adobjectId.Name; flag = true; } } } if (flag) { Guid databaseGuid = mbxItem.DatabaseGuid; if (mbxItem.DatabaseGuid == Guid.Empty) { flag = false; StoreDriverDeliveryDiagnostics.Diag.TraceWarning <long>(0L, "MDB parameters were found but were null or empty for item {0}.", mbxItem.RecordId); } } if (!flag) { mbxItem.AckMailItem(AckStatus.Fail, AckReason.MissingMdbProperties, null, null, StoreDriverDelivery.GenerateSessionSourceContext(sessionId, mbxItem.SessionStartTime)); StoreDriverDeliveryDiagnostics.Diag.TraceWarning <long>(0L, "Failed to get MDB parameters for item {0}.", mbxItem.RecordId); } return(flag); }
protected override ICollection <string> RetrieveKeys(MappedPrincipal data) { HashSet <string> hashSet = new HashSet <string>(this.GetEqualityComparer()); if (!string.IsNullOrEmpty(data.LegacyDN)) { hashSet.Add(data.LegacyDN); } if (data.ProxyAddresses != null) { foreach (string proxyAddressString in data.ProxyAddresses) { ProxyAddress proxyAddress = ProxyAddress.Parse(proxyAddressString); if (proxyAddress != null && proxyAddress.Prefix == ProxyAddressPrefix.X500 && !hashSet.Contains(proxyAddress.AddressString)) { hashSet.Add(proxyAddress.AddressString); } } } return(hashSet); }
public ExchangePrincipal FromProxyAddress(IRecipientSession session, string proxyAddress, RemotingOptions remotingOptions) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(proxyAddress, "proxyAddress"); EnumValidator.ThrowIfInvalid <RemotingOptions>(remotingOptions, "remotingOptions"); if (proxyAddress.Length == 0) { throw new ObjectNotFoundException(ServerStrings.ADUserNotFound); } this.CheckNoCrossPremiseAccess(remotingOptions); ProxyAddress proxyAddress2 = ProxyAddress.Parse(proxyAddress); IGenericADUser genericADUser = this.directoryAccessor.FindByProxyAddress(session, proxyAddress2); if (genericADUser == null) { throw new ObjectNotFoundException(ServerStrings.ADUserNotFound); } ADObjectId mdb; bool asArchive = this.UpdateArchiveStatus(genericADUser.MailboxGuid, genericADUser, out mdb); return(this.InternalFromADUser(genericADUser, mdb, null, remotingOptions, asArchive, false, null)); }
private ProxyAddress GetSendingAsProxyAddress(MailTipsState mailTipsState) { ProxyAddress proxyAddress; if (mailTipsState.SenderInfo == null) { if (string.IsNullOrEmpty(mailTipsState.LogonUserLegDn)) { proxyAddress = ProxyAddress.Parse(ProxyAddressPrefix.Smtp.PrimaryPrefix, mailTipsState.LogonUserPrimarySmtpAddress ?? string.Empty); } else { proxyAddress = ProxyAddress.Parse(ProxyAddressPrefix.LegacyDN.PrimaryPrefix, mailTipsState.LogonUserLegDn); } } else { proxyAddress = mailTipsState.SenderInfo.ToProxyAddress(); } mailTipsState.SendingAs = proxyAddress; return(proxyAddress); }
private IEnumerable <UserObject> ExtractAttendees(IAttendeeCollection attendeeCollection, Participant organizerParticipant, bool dlParticipantsOnly) { Dictionary <ADObjectId, UserObject> dictionary = new Dictionary <ADObjectId, UserObject>(attendeeCollection.Count); HashSet <ADObjectId> hashSet = new HashSet <ADObjectId>(); Dictionary <ProxyAddress, UserObject> dictionary2 = new Dictionary <ProxyAddress, UserObject>(); int expandedDLCount = 0; foreach (Attendee attendee in attendeeCollection) { if (CalendarValidator.IsValidParticipant(attendee.Participant)) { ProxyAddress attendeeProxyAddress = ProxyAddress.Parse(attendee.Participant.RoutingType, attendee.Participant.EmailAddress); ADRecipient attendeeRecipient = null; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { attendeeRecipient = this.recipientSession.FindByProxyAddress(attendeeProxyAddress); }); if (!adoperationResult.Succeeded || attendeeRecipient == null) { this.ExtractUnaccessibleAttendee(organizerParticipant, dictionary2, attendee, attendeeProxyAddress); } else if (hashSet.Contains(attendeeRecipient.Id)) { AttendeeExtractor.RevisitAttendee(dictionary, attendee, attendeeRecipient); } else if (attendeeRecipient is ADGroup) { AttendeeExtractor.DLExpansionHandler dlexpansionHandler = new AttendeeExtractor.DLExpansionHandler(organizerParticipant, dictionary, hashSet, expandedDLCount, attendee, attendeeRecipient, this.recipientSession, this.expansionManager); expandedDLCount = dlexpansionHandler.ExpandDL(); } else if (!dlParticipantsOnly) { hashSet.Add(attendeeRecipient.Id); AttendeeExtractor.DLExpansionHandler.AddOrganizerFilteredAttendee <ADObjectId>(dictionary, attendeeRecipient.Id, new UserObject(attendee, attendeeRecipient, this.recipientSession), organizerParticipant, this.recipientSession); } } } return(dictionary.Values.Concat(dictionary2.Values)); }
// Token: 0x06000FC5 RID: 4037 RVA: 0x000627F4 File Offset: 0x000609F4 public static OwaMiniRecipientIdentity CreateFromProxyAddress(string emailString) { if (emailString == null) { throw new ArgumentNullException("emailString"); } ProxyAddress proxyAddress = null; try { proxyAddress = ProxyAddress.Parse(emailString); } catch (ArgumentNullException) { proxyAddress = null; } if (proxyAddress == null || proxyAddress.GetType() != typeof(SmtpProxyAddress)) { throw new OwaExplicitLogonException(string.Format("{0} is not a valid SMTP address", emailString), string.Format(LocalizedStrings.GetNonEncoded(-13616305), emailString)); } return(new OwaMiniRecipientIdentity(proxyAddress)); }