internal static void Execute(IMailboxContext userContext, string eventId, Action <MailboxSession, IRecipientSession, RequestDetailsLogger> action)
 {
     SimulatedWebRequestContext.Execute(userContext, eventId, delegate(RequestDetailsLogger logger)
     {
         ExchangePrincipal exchangePrincipal = userContext.ExchangePrincipal;
         if (exchangePrincipal == null)
         {
             return;
         }
         IRecipientSession arg = InstantMessageUtilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, exchangePrincipal, userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN);
         try
         {
             userContext.LockAndReconnectMailboxSession(3000);
             MailboxSession mailboxSession = userContext.MailboxSession;
             action(mailboxSession, arg, logger);
         }
         catch (OwaLockTimeoutException exception)
         {
             SimulatedWebRequestContext.ProcessException(logger, eventId, exception);
         }
         finally
         {
             if (userContext.MailboxSessionLockedByCurrentThread())
             {
                 userContext.UnlockAndDisconnectMailboxSession();
             }
         }
     });
 }
Exemple #2
0
        internal static ProxySettings[] GetProxySettings(string[] upns, IUserContext userContext)
        {
            List <ProxySettings> list             = new List <ProxySettings>();
            IRecipientSession    recipientSession = InstantMessageUtilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, userContext.ExchangePrincipal, userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN);

            Result <OWAMiniRecipient>[] array = recipientSession.FindOWAMiniRecipientByUserPrincipalName(upns);
            for (int i = 0; i < array.Length; i++)
            {
                OWAMiniRecipient data = array[i].Data;
                string           text = data.UserPrincipalName.ToString();
                if (string.IsNullOrEmpty(text))
                {
                    list.Add(new ProxySettings(text, null));
                }
                else
                {
                    list.Add(new ProxySettings(text, InstantMessageUtilities.GetProxyAddressesForRecipient(data)));
                }
            }
            return(list.ToArray());
        }
Exemple #3
0
        internal static string GetSipUri(string emailAddress, IUserContext userContext)
        {
            IRecipientSession recipientSession = InstantMessageUtilities.CreateADRecipientSession(Culture.GetUserCulture().LCID, true, ConsistencyMode.IgnoreInvalid, true, userContext.ExchangePrincipal, false, userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN);

            try
            {
                SmtpProxyAddress proxyAddress = new SmtpProxyAddress(emailAddress, true);
                ADRecipient      adrecipient  = recipientSession.FindByProxyAddress(proxyAddress);
                if (adrecipient != null)
                {
                    string sipUri = ADPersonToContactConverter.GetSipUri(adrecipient);
                    Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.InstantMessagingTracer.TraceDebug <string, string>(0L, "SIPUri for {0}: {1}", emailAddress, sipUri);
                    return(sipUri);
                }
            }
            catch (NonUniqueRecipientException ex)
            {
                Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.InstantMessagingTracer.TraceError <string>(0L, "Failed to get unique recipient: Error: {0}", ex.Message);
            }
            Microsoft.Exchange.Diagnostics.Components.Clients.ExTraceGlobals.InstantMessagingTracer.TraceError <string>(0L, "Failed to get SIP Address for: {0}", emailAddress);
            return(null);
        }
Exemple #4
0
 private static IRecipientSession CreateADRecipientSession(int lcid, bool readOnly, ConsistencyMode consistencyMode, bool useDirectorySearchRoot, ExchangePrincipal exchangePrincipal, ADObjectId directorySearchRoot)
 {
     return(InstantMessageUtilities.CreateADRecipientSession(lcid, readOnly, consistencyMode, useDirectorySearchRoot, exchangePrincipal, true, directorySearchRoot));
 }
Exemple #5
0
 private static IRecipientSession CreateADRecipientSession(bool readOnly, ConsistencyMode consistencyMode, ExchangePrincipal exchangePrincipal, ADObjectId directorySearchRoot)
 {
     return(InstantMessageUtilities.CreateADRecipientSession(CultureInfo.CurrentCulture.LCID, readOnly, consistencyMode, false, exchangePrincipal, true, directorySearchRoot));
 }
Exemple #6
0
 internal static IRecipientSession CreateADRecipientSession(ConsistencyMode consistencyMode, ExchangePrincipal exchangePrincipal, ADObjectId directorySearchRoot)
 {
     return(InstantMessageUtilities.CreateADRecipientSession(true, consistencyMode, exchangePrincipal, directorySearchRoot));
 }