// Token: 0x060019AD RID: 6573 RVA: 0x0005AB7C File Offset: 0x00058D7C
        protected override OnlineMeetingType InternalExecute()
        {
            this.SetDefaultValuesForOptics();
            UserContext userContext = UserContextManager.GetUserContext(base.CallContext.HttpContext, base.CallContext.EffectiveCaller, true);

            if (string.Compare(userContext.SipUri, this.sipUri, StringComparison.OrdinalIgnoreCase) != 0)
            {
                base.CallContext.ProtocolLog.Set(CreateOnlineMeetingMetadata.ManagerSipUri, ExtensibleLogger.FormatPIIValue(this.sipUri));
            }
            if (userContext.ExchangePrincipal.MailboxInfo.OrganizationId != null && userContext.ExchangePrincipal.MailboxInfo.OrganizationId.OrganizationalUnit != null)
            {
                base.CallContext.ProtocolLog.Set(CreateOnlineMeetingMetadata.Organization, userContext.ExchangePrincipal.MailboxInfo.OrganizationId.OrganizationalUnit.Name);
            }
            UcwaUserConfiguration ucwaUserConfiguration = UcwaConfigurationUtilities.GetUcwaUserConfiguration(this.sipUri, base.CallContext);

            if (!ucwaUserConfiguration.IsUcwaSupported)
            {
                base.CallContext.ProtocolLog.Set(CreateOnlineMeetingMetadata.IsUcwaSupported, bool.FalseString);
                string errorString = string.Format("[InternalExecute] Attempted to create an online meeting for a non-UCWA supported user; autodiscover returned UcwaUrl: '{0}', DiagnosticInfo: '{1}'", ucwaUserConfiguration.UcwaUrl, ucwaUserConfiguration.DiagnosticInfo);
                this.LogAndTraceError(errorString);
                return(OnlineMeetingType.CreateFailedOnlineMeetingType("User is not UCWA enabled"));
            }
            if (!this.ShoudlMeetingBeCreated())
            {
                return(OnlineMeetingType.CreateFailedOnlineMeetingType("Item already has an online meeting associated to it."));
            }
            OAuthCredentials oauthCredential;

            try
            {
                oauthCredential = UcwaConfigurationUtilities.GetOAuthCredential(this.sipUri);
                oauthCredential.ClientRequestId = new Guid?(Guid.NewGuid());
                base.CallContext.ProtocolLog.Set(CreateOnlineMeetingMetadata.OAuthCorrelationId, oauthCredential.ClientRequestId.Value.ToString());
            }
            catch (OwaException ex)
            {
                this.LogAndTraceError("An error occurred while obtaining OAuth Credential: " + UcwaConfigurationUtilities.BuildFailureLogString(ex));
                return(OnlineMeetingType.CreateFailedOnlineMeetingType("An error occurred while obtaining OAuth credential"));
            }
            Task <OnlineMeetingResult> task = this.CreateLyncOnlineMeeting(ucwaUserConfiguration.UcwaUrl, oauthCredential, userContext.UserCulture);

            base.CallContext.ProtocolLog.Set(CreateOnlineMeetingMetadata.IsTaskCompleted, task.IsCompleted.ToString());
            if (task.IsFaulted)
            {
                task.Exception.Flatten().Handle(new Func <Exception, bool>(this.HandleCreateOnlineMeetingTaskException));
                return(OnlineMeetingType.CreateFailedOnlineMeetingType("An error occured while calling UCWA to create the meeting"));
            }
            if (task.Result == null)
            {
                this.LogAndTraceError("Result from call to UCWA is null");
                return(OnlineMeetingType.CreateFailedOnlineMeetingType("Unable to create the meeting"));
            }
            if (task.Result.OnlineMeeting.WebUrl == "")
            {
                return(OnlineMeetingType.CreateFailedOnlineMeetingType("Unable to create the meeting"));
            }
            this.UpdateOpticsLog(task.Result);
            OnlineMeetingType result = this.ProcessOnlineMeetingResult(userContext, task.Result);

            this.DiposeObjectsIfNeeded();
            return(result);
        }
Пример #2
0
        public static UcwaUserConfiguration GetUcwaUserConfiguration(string sipUri, CallContext callContext)
        {
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsTaskCompleted, bool.FalseString);
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsUcwaSupported, bool.FalseString);
            UcwaUserConfiguration ucwaUserConfiguration = new UcwaUserConfiguration();

            ucwaUserConfiguration.SipUri = sipUri;
            if (string.IsNullOrEmpty(sipUri))
            {
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsTaskCompleted, bool.TrueString);
                throw new OwaInvalidRequestException("No sipUri specified");
            }
            UserContext userContext = UserContextManager.GetUserContext(callContext.HttpContext, callContext.EffectiveCaller, true);

            if (string.Compare(userContext.SipUri, sipUri, StringComparison.OrdinalIgnoreCase) != 0)
            {
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.ManagerSipUri, ExtensibleLogger.FormatPIIValue(sipUri));
            }
            if (userContext.ExchangePrincipal.MailboxInfo.OrganizationId != null && userContext.ExchangePrincipal.MailboxInfo.OrganizationId.OrganizationalUnit != null)
            {
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.Organization, userContext.ExchangePrincipal.MailboxInfo.OrganizationId.OrganizationalUnit.Name);
            }
            OAuthCredentials oauthCredential;

            try
            {
                oauthCredential = UcwaConfigurationUtilities.GetOAuthCredential(sipUri);
                oauthCredential.ClientRequestId = new Guid?(Guid.NewGuid());
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.OAuthCorrelationId, oauthCredential.ClientRequestId.Value.ToString());
            }
            catch (OwaException ex)
            {
                string text = UcwaConfigurationUtilities.BuildFailureLogString(ex);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.Exceptions, text);
                ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetUcwaUserConfiguration] An error occurred while obtaining OAuth credential; Exception: {0}", text);
                ucwaUserConfiguration.DiagnosticInfo = text;
                return(ucwaUserConfiguration);
            }
            AutodiscoverResult ucwaDiscoveryUrl = AutodiscoverWorker.GetUcwaDiscoveryUrl(sipUri, oauthCredential);

            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.AuthenticatedLyncAutodiscoverServer, ucwaDiscoveryUrl.AuthenticatedLyncAutodiscoverServer);
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsAuthdServerFromCache, ucwaDiscoveryUrl.IsAuthdServerFromCache ? bool.TrueString : bool.FalseString);
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsUcwaUrlFromCache, ucwaDiscoveryUrl.IsUcwaUrlFromCache ? bool.TrueString : bool.FalseString);
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.UnauthenticatedRedirectHops, string.Join(";", ucwaDiscoveryUrl.UnauthenticatedRedirects));
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.AuthenticatedRedirectHops, string.Join(";", ucwaDiscoveryUrl.AuthenticatedRedirects));
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.WorkerExceptions, ucwaDiscoveryUrl.BuildFailureString());
            if (!ucwaDiscoveryUrl.IsOnlineMeetingEnabled)
            {
                ExTraceGlobals.OnlineMeetingTracer.TraceInformation(0, 0L, "[UcwaConfigurationUtilities.GetUcwaUserConfiguration] Online meetings are not enabled in this topology");
                ucwaUserConfiguration.DiagnosticInfo = "Online meetings not enabled on the server";
                return(ucwaUserConfiguration);
            }
            if (ucwaDiscoveryUrl.HasError)
            {
                Exception     exception     = ucwaDiscoveryUrl.Error.Exception;
                StringBuilder stringBuilder = new StringBuilder(ucwaDiscoveryUrl.Error.FailureStep.ToString() + "_");
                stringBuilder.Append(UcwaConfigurationUtilities.BuildFailureLogString(exception));
                stringBuilder.Append(ucwaDiscoveryUrl.Error.ResponseFailureReason ?? string.Empty);
                string text2 = stringBuilder.ToString();
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.Exceptions, text2);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.RequestHeaders, ucwaDiscoveryUrl.Error.RequestHeaders);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.ResponseHeaders, ucwaDiscoveryUrl.Error.ResponseHeaders);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.ResponseBody, ucwaDiscoveryUrl.Error.ResponseBody);
                if (ucwaDiscoveryUrl.IsAuthdServerFromCache)
                {
                    AutodiscoverCache.InvalidateDomain(OnlineMeetingHelper.GetSipDomain(sipUri));
                    callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.CacheOperation, AutodiscoverCacheOperation.InvalidateDomain.ToString());
                }
                ExTraceGlobals.OnlineMeetingTracer.TraceError <string>(0L, "[UcwaConfigurationUtilities.GetUcwaUserConfiguration] An error occured while fetching UCWA configuration; Exception: {0}", text2);
                ucwaUserConfiguration.DiagnosticInfo = text2;
                return(ucwaUserConfiguration);
            }
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.ResponseBody, ucwaDiscoveryUrl.ResponseBody);
            ucwaUserConfiguration.IsUcwaSupported = ucwaDiscoveryUrl.IsUcwaSupported;
            ucwaUserConfiguration.UcwaUrl         = ucwaDiscoveryUrl.UcwaDiscoveryUrl;
            callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsTaskCompleted, bool.TrueString);
            if (ucwaUserConfiguration.IsUcwaSupported)
            {
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.IsUcwaSupported, bool.TrueString);
                callContext.ProtocolLog.Set(GetUcwaUserConfigurationMetaData.UcwaUrl, ucwaUserConfiguration.UcwaUrl);
            }
            return(ucwaUserConfiguration);
        }