public static ADRawEntry GetSender(IRecipientSession session, ProxyAddress sendingAs, ADPropertyDefinition[] properties) { ADRawEntry sender = null; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { sender = session.FindByProxyAddress(sendingAs, properties); }); if (!adoperationResult.Succeeded) { if (adoperationResult.Exception is NonUniqueRecipientException) { string message = Strings.descMailTipsSenderNotUnique(sendingAs.ToString()); throw new SenderNotUniqueException(message); } throw adoperationResult.Exception; } else { if (sender == null) { string message2 = Strings.descMailTipsSenderNotFound(sendingAs.ToString()); throw new SenderNotFoundException(message2); } return(sender); } }
public string GetSenderEmailAddress() { if (this.senderAdEntry == null) { return(string.Empty); } SmtpAddress primarySmtpAddress = this.senderAdEntry.PrimarySmtpAddress; if (primarySmtpAddress.IsValidAddress) { return(primarySmtpAddress.ToString()); } ProxyAddressCollection emailAddresses = this.senderAdEntry.EmailAddresses; if (emailAddresses == null || 0 >= emailAddresses.Count) { return(string.Empty); } ProxyAddress proxyAddress = emailAddresses.Find(new Predicate <ProxyAddress>(this.IsSmtpAddress)); if (null != proxyAddress) { return(proxyAddress.ToString()); } return(emailAddresses[0].ToString()); }
public static void ToStringTest(string value) { var instance = new ProxyAddress(value); var strValue = instance.ToString(); // セットした値と取得した値が一致すること Assert.AreEqual(strValue, value); }
protected string PrimarySMTPAddressOfObject(CSEntry csentry) { foreach (Value ProxyAddress in csentry[PROXY_ADDRESSES].Values) { if (ProxyAddress.ToString().StartsWith("SMTP:")) { return(ProxyAddress.ToString()); } } return(null); }
public void Save([NotNull] XmlTextWriter output) { Assert.ArgumentNotNull(output, nameof(output)); var blowFish = new BlowFish(BlowFish.CipherKey); var encryptedPassword = blowFish.Encrypt_ECB(Password); output.WriteStartElement(@"binding"); output.WriteAttributeString(@"hostName", HostName); output.WriteAttributeString(@"useWindowsAuth", UseWindowsAuth ? @"true" : @"false"); output.WriteAttributeString(@"userName", UserName); output.WriteAttributeString(@"password", encryptedPassword); output.WriteAttributeString(@"dataService", DataServiceName); output.WriteAttributeString(@"webRootPath", WebRootPath); output.WriteAttributeString(@"description", Description); output.WriteAttributeString(@"isRemoteSitecore", IsRemoteSitecore ? @"true" : @"false"); output.WriteAttributeString(@"automaticallyUpdate", AutomaticallyUpdate ? @"true" : @"false"); output.WriteAttributeString(@"isHidden", IsHidden ? @"true" : @"false"); output.WriteAttributeString(@"hostNameComparisonMode", HostNameComparisonMode.ToString()); output.WriteAttributeString(@"receiveTimeout", ReceiveTimeout.ToString()); output.WriteAttributeString(@"sendTimeout", SendTimeout.ToString()); output.WriteAttributeString(@"openTimeout", OpenTimeout.ToString()); output.WriteAttributeString(@"closeTimeout", CloseTimeout.ToString()); output.WriteAttributeString(@"maxReceivedMessageSize", MaxReceivedMessageSize.ToString()); output.WriteAttributeString(@"maxBufferSize", MaxBufferSize.ToString()); output.WriteAttributeString(@"maxBufferPoolSize", MaxBufferPoolSize.ToString()); output.WriteAttributeString(@"maxStringContentLength", MaxStringContentLength.ToString()); output.WriteAttributeString(@"transferMode", TransferMode.ToString()); output.WriteAttributeString(@"messageEncoding", MessageEncoding.ToString()); output.WriteAttributeString(@"textEncoding", TextEncoding.WebName); output.WriteAttributeString(@"bypassProxyOnLocal", BypassProxyOnLocal ? @"true" : @"false"); output.WriteAttributeString(@"useDefaultWebProxy", UseDefaultWebProxy ? @"true" : @"false"); if (ProxyAddress != null) { output.WriteAttributeString(@"proxyAddress", ProxyAddress.ToString()); } else { output.WriteAttributeString(@"proxyAddress", string.Empty); } output.WriteEndElement(); }
// added bool hasBeenMigrated to use in suffix selection protected string FindMatchedDomainSuffix(CSEntry csentry, bool checkMailRouting, bool onlyMatchingFirstSuffix, bool hasBeenMigrated) { string result = null; GALMA MAConfig = null; // // CheckMailRouting is true if called for Contact, // false for user and group. // // So for contact (true == checkMailRouting), if the MA is // configured to use mail routing, then skip finding from // matching proxy, the caller will then map the source CS // target address to MV directly. // if (true == checkMailRouting) { MAConfig = FindMA(csentry); if (false == MAConfig.MailRouting) { result = null; } } // // Check every smtp address in proxy addresses if they end // with one of the mail domain suffixes that that forest // controls return it // foreach (Value ProxyAddress in csentry[PROXY_ADDRESSES].Values) { string ProxyAddressString = ProxyAddress.ToString(); // AFRIEDRICHSEN 06 Jan 2016 - added hasBeenMigrated to logic for smtp selection in function call if (ProxyAddressString.ToUpper().StartsWith(SMTP_PREFIX)) { if (ProxyAddressIsInSMTPMailDomain(csentry, ProxyAddressString, onlyMatchingFirstSuffix, hasBeenMigrated)) { result = "SMTP:" + ProxyAddressString.Split(':')[1].ToLower(); } } } return(result); }
public bool CompareAddresses(object messageValue, object ruleValue) { ProxyAddress proxyAddressFromSearchKey = RuleUtil.GetProxyAddressFromSearchKey(messageValue); ProxyAddress proxyAddressFromSearchKey2 = RuleUtil.GetProxyAddressFromSearchKey(ruleValue); if (proxyAddressFromSearchKey2 == null || proxyAddressFromSearchKey2 is InvalidProxyAddress || string.IsNullOrEmpty(proxyAddressFromSearchKey2.ValueString)) { string recipient = ServerStrings.Null; if (proxyAddressFromSearchKey2 != null) { recipient = proxyAddressFromSearchKey2.ToString(); } this.DisableAndMarkRuleInError(this.CurrentRule, RuleAction.Type.OP_INVALID, 0, DeferredError.RuleError.Parsing); this.RecordError(ServerStrings.FolderRuleErrorInvalidRecipient(recipient)); return(false); } this.TraceDebug <ProxyAddress, ProxyAddress>("Comparing recipients, message address {0}, rule address {1}", proxyAddressFromSearchKey, proxyAddressFromSearchKey2); RuleUtil.FaultInjection((FaultInjectionLid)4257530192U); return(RuleUtil.IsSameUser(this, this.RecipientCache, proxyAddressFromSearchKey, proxyAddressFromSearchKey2)); }
internal static bool IsMemberOf(IRuleEvaluationContext context, byte[] recipientEntryId, byte[] groupEntryId) { ProxyAddress legacyProxyAddress = RuleUtil.GetLegacyProxyAddress(context, recipientEntryId); if (legacyProxyAddress == null) { context.TraceDebug("IsMemberOf: unable to get legacy DN for recipient."); return(false); } ProxyAddress legacyProxyAddress2 = RuleUtil.GetLegacyProxyAddress(context, groupEntryId); if (legacyProxyAddress2 == null) { context.TraceDebug("IsMemberOf: unable to get address for group, this rule is in error."); throw new InvalidRuleException(ServerStrings.FolderRuleErrorInvalidGroup(BitConverter.ToString(groupEntryId))); } context.TraceDebug <string, string>("IsMemberOf: Recipient=\"{0}\" Group=\"{1}\"", legacyProxyAddress.AddressString, legacyProxyAddress2.AddressString); Result <ADRawEntry> result = context.RecipientCache.FindAndCacheRecipient(legacyProxyAddress); if (result.Data == null) { context.TraceDebug("Recipient doesn't exist in AD"); context.RecordError(ServerStrings.FolderRuleErrorGroupDoesNotResolve(legacyProxyAddress.ToString())); return(false); } bool result2; try { IsMemberOfResolver <string> isMemberOfResolver = context.IsMemberOfResolver; bool flag = isMemberOfResolver.IsMemberOf(context.RecipientCache.ADSession, result.Data.Id, legacyProxyAddress2.AddressString); context.TraceDebug <bool>("IsMemberOf: {0}", flag); result2 = flag; } catch (AddressBookTransientException exception) { context.RecordError(exception, ServerStrings.FolderRuleStageEvaluation); result2 = false; } return(result2); }
private void SetEnvelopeSender(TransportMailItem mailItem, ProxyAddress sender) { RoutingAddress routingAddress; if (!SubmissionItemUtils.TryGetRoutingAddress(mailItem.ADRecipientCache, sender.AddressString, sender.PrefixString, "SmtpSubmissionItem.SetEnvelopeSender", out routingAddress)) { this.context.TraceError <string>("SmtpSubmissionItem.SetEnvelopeSender: Could not get routing address for sender {0}.", sender.ToString()); throw new InvalidSenderException(sender); } this.context.TraceDebug <RoutingAddress>("SmtpSubmissionItem.SetEnvelopeSender: Setting envelope sender: {0}", routingAddress); mailItem.From = routingAddress; mailItem.MimeSender = routingAddress; }
private string[] GetProxyAddresses(string address) { if (string.IsNullOrEmpty(address)) { return(null); } int num = 0; string[] array = null; Exception ex = null; ADRawEntry adrawEntry = null; ProxyAddress proxyAddress = ProxyAddress.Parse(address); if (proxyAddress is InvalidProxyAddress) { ex = ((InvalidProxyAddress)proxyAddress).ParseException; LocalizedException exception = new LocalizedException(Strings.WarningProxyAddressIsInvalid(address, ex.Message)); base.WriteError(exception, ErrorCategory.InvalidArgument, null); return(null); } if (this.recipSession == null) { ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(SmtpAddress.Parse(address).Domain); this.recipSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.FullyConsistent, sessionSettings, 977, "GetProxyAddresses", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\LogSearch\\GetMessageTrackingLog.cs"); if (!this.recipSession.IsReadConnectionAvailable()) { this.recipSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.FullyConsistent, sessionSettings, 986, "GetProxyAddresses", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\LogSearch\\GetMessageTrackingLog.cs"); } } AcceptedDomain acceptedDomain = null; bool flag; do { flag = false; try { this.GetRecipientInformation(proxyAddress.ToString(), out adrawEntry, out acceptedDomain); } catch (DataValidationException ex2) { ex = ex2; } catch (TransientException ex3) { if (num < 3) { flag = true; num++; Thread.Sleep(1000); } else { ex = ex3; } } }while (flag); if (ex != null) { this.WriteWarning(Strings.WarningProxyListUnavailable(address, ex.GetType().Name + ": " + ex.Message)); return(null); } if (adrawEntry == null) { return(null); } ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses]; string address2 = (string)adrawEntry[ADRecipientSchema.LegacyExchangeDN]; array = new string[proxyAddressCollection.Count + 1]; int num2 = 0; SmtpProxyAddress smtpProxyAddress; if (acceptedDomain != null && SmtpProxyAddress.TryEncapsulate(ProxyAddressPrefix.LegacyDN.PrimaryPrefix, address2, acceptedDomain.DomainName.Domain, out smtpProxyAddress)) { array[0] = smtpProxyAddress.AddressString; } foreach (ProxyAddress proxyAddress2 in proxyAddressCollection) { num2++; SmtpProxyAddress smtpProxyAddress2 = null; if (proxyAddress2.Prefix == ProxyAddressPrefix.Smtp) { array[num2] = proxyAddress2.AddressString; } else if (acceptedDomain != null && SmtpProxyAddress.TryEncapsulate(proxyAddress2, acceptedDomain.DomainName.Domain, out smtpProxyAddress2)) { array[num2] = smtpProxyAddress2.AddressString; } } return(array); }
internal static OAuthCredentials GetOAuthCredential(string sipUri) { ProxyAddress proxyAddress = ProxyAddress.Parse(sipUri); string sipDomain = OnlineMeetingHelper.GetSipDomain(sipUri); if (string.IsNullOrEmpty(sipDomain)) { ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetOAuthCredential] Unable to determine domain from sip uri: {0}", sipUri); throw new OwaException(string.Format("Unable to determine domain from sip uri: {0}", sipUri)); } MiniRecipient miniRecipient = null; IRecipientSession recipientSession = null; try { recipientSession = UserContextUtilities.CreateScopedRecipientSession(true, ConsistencyMode.FullyConsistent, sipDomain, null); } catch (OwaADObjectNotFoundException innerException) { throw new OwaException(string.Format("Couldn't create a scoped recipient session for {0}", sipDomain), innerException); } try { miniRecipient = recipientSession.FindByProxyAddress <MiniRecipient>(proxyAddress); if (miniRecipient == null) { ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetOAuthCredential] IRecipientSession.FindByProxyAddress() unable to find to recipient with address: {0}", sipUri); throw new OwaException(string.Format("Couldn't find a match for {0}", proxyAddress.ToString())); } } catch (NonUniqueRecipientException innerException2) { ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetOAuthCredential] Couldn't find a unique match for: {0}", sipUri); throw new OwaException(string.Format("Couldn't find a unique match for {0}", proxyAddress.ToString()), innerException2); } return(OAuthCredentials.GetOAuthCredentialsForAppActAsToken(miniRecipient.OrganizationId, miniRecipient, sipDomain)); }
internal static bool IsSameUser(IRuleEvaluationContext context, IADRecipientCache recipientCache, ProxyAddress addressToResolve, ProxyAddress addressToCompare) { if (addressToResolve == null || addressToResolve is InvalidProxyAddress) { return(false); } if (addressToCompare == null || addressToCompare is InvalidProxyAddress) { return(false); } if (addressToResolve.Equals(addressToCompare)) { return(true); } ADRawEntry data = recipientCache.FindAndCacheRecipient(addressToResolve).Data; if (data == null) { context.TraceDebug <string>("Message recipient {0} did not resolve, IsSameUser returning false.", addressToResolve.ToString()); return(false); } string text = (string)data[ADRecipientSchema.LegacyExchangeDN]; if (text != null && addressToCompare.ValueString.Equals(text, StringComparison.OrdinalIgnoreCase)) { return(true); } ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)data[ADRecipientSchema.EmailAddresses]; if (proxyAddressCollection == null) { return(false); } foreach (ProxyAddress proxyAddress in proxyAddressCollection) { if (addressToCompare.ValueString.Equals(proxyAddress.ValueString, StringComparison.OrdinalIgnoreCase)) { return(true); } } return(false); }