예제 #1
0
 private bool QueryAvailability(AvailabilityQuery availabilityQuery, List <ResolvedRecipient> availabilityList, out AvailabilityQueryResult result)
 {
     result = null;
     AirSyncCounters.NumberOfAvailabilityRequests.Increment();
     try
     {
         result = availabilityQuery.Execute();
     }
     catch (ClientDisconnectedException)
     {
         AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "AvailabilityQuery has thrown ClientDisconnectedException");
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ClientDisconnectedException");
         foreach (ResolvedRecipient resolvedRecipient in availabilityList)
         {
             resolvedRecipient.AvailabilityStatus = StatusCode.AvailabilityTransientFailure;
         }
         return(false);
     }
     finally
     {
         AirSyncDiagnostics.TraceDebug <StringBuilder>(ExTraceGlobals.RequestsTracer, this, "AvailabilityQuery log:{0}", availabilityQuery.RequestLogger.LogData);
     }
     if (result == null)
     {
         AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "AvailabilityQuery has returned null result");
         base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "EmptyAvailabilityResult");
         foreach (ResolvedRecipient resolvedRecipient2 in availabilityList)
         {
             resolvedRecipient2.AvailabilityStatus = StatusCode.AvailabilityFailure;
         }
         return(false);
     }
     return(true);
 }
예제 #2
0
        protected bool ValidateXmlNode(XmlNode xmlNode, string targetNamespace)
        {
            bool result;

            using (Command.CurrentCommand.Context.Tracker.Start(TimeId.ValidatorValidateXMLNode))
            {
                if (!Validator.schemasCreated)
                {
                    Validator.CreateSchemaSet();
                }
                xmlNode.OwnerDocument.Schemas = Validator.schemas[this.versionIdx];
                ICollection collection = xmlNode.OwnerDocument.Schemas.Schemas(targetNamespace);
                if (collection == null || collection.Count == 0)
                {
                    if (AirSyncDiagnostics.IsTraceEnabled(TraceType.ErrorTrace, ExTraceGlobals.ValidationTracer))
                    {
                        AirSyncDiagnostics.TraceError <string, string>(ExTraceGlobals.ValidationTracer, null, "Validaton Failure No Schema specified for {0} TargetNamespace={1}", xmlNode.OwnerDocument.LocalName, targetNamespace);
                    }
                    this.ValidationErrors.Add(new Validator.XmlValidationError("Unknown Namespace: '{0}'", new object[]
                    {
                        targetNamespace
                    }));
                    result = false;
                }
                else
                {
                    this.failed = false;
                    xmlNode.OwnerDocument.Validate(new ValidationEventHandler(this.AirSyncValidationEventHandler), xmlNode);
                    result = !this.failed;
                }
            }
            return(result);
        }
예제 #3
0
 public void TraceTree()
 {
     AirSyncDiagnostics.TraceError(ExTraceGlobals.AlgorithmTracer, this, "Inconsistency found in FolderTree.  Dumping contents of tree:");
     foreach (KeyValuePair <ISyncItemId, FolderTree.FolderInfo> keyValuePair in this.folderTree)
     {
         FolderTree.FolderInfo value         = keyValuePair.Value;
         StringBuilder         stringBuilder = new StringBuilder();
         for (int i = 0; i < value.Children.Count; i++)
         {
             stringBuilder.Append(value.Children[i]);
             if (i + 1 < value.Children.Count)
             {
                 stringBuilder.Append(", ");
             }
         }
         AirSyncDiagnostics.TraceError(ExTraceGlobals.AlgorithmTracer, this, "FolderSyncId: {0}, ParentSyncId: {1}, Hidden: {2}, HiddenDueToParent: {3}, Children: {4}", new object[]
         {
             keyValuePair.Key,
             value.ParentId,
             value.Hidden,
             value.HiddenDueToParent,
             stringBuilder
         });
     }
 }
예제 #4
0
 private void ProxyLoginGetStreamCompleteCallback(IAsyncResult iar)
 {
     AirSyncDiagnostics.TraceFunction <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginRequestCompleteCallback: {0}, {1}.", this.remoteUri, this.userName);
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.ProxyLoginGetStreamCompleteCallback() Request was timed out while waiting for lock!");
             return;
         }
     }
     try
     {
         this.UnregisterTimeoutWaitHandle();
         this.backEndRequestStream  = this.backEndWebRequest.EndGetRequestStream(iar);
         this.pendingAsyncOperation = ProxyHandler.PendingOperationState.ProxyLoginWritingCsc;
         IAsyncResult asyncResult = this.backEndRequestStream.BeginWrite(this.proxyInfo.CscBuffer, 0, this.proxyInfo.CscBuffer.Length, new AsyncCallback(this.ProxyLoginWriteCompleteCallback), null);
         if (!asyncResult.CompletedSynchronously)
         {
             this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
         }
     }
     catch (Exception ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginRequestCompleteCallback caught an exception\r\n{0}", arg);
         if (this.backEndWebRequest != null)
         {
             this.backEndWebRequest.Abort();
             this.backEndWebRequest = null;
         }
         this.HandleException(ex);
     }
     AirSyncDiagnostics.TraceFunction <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyLoginRequestCompleteCallback: completed {0}, {1}.", this.remoteUri, this.userName);
 }
예제 #5
0
        // Token: 0x060002FE RID: 766 RVA: 0x0000FC2C File Offset: 0x0000DE2C
        private void InitializeFromClientSecurityContext()
        {
            string proxyHeader = this.context.Request.ProxyHeader;

            if (this.clientSecurityContextWrapper != null)
            {
                AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromClientSecurityContext]. clientSecurityContextWrapper is not null. calling dispose.");
                this.clientSecurityContextWrapper.Dispose();
            }
            this.clientSecurityContextWrapper = (ClientSecurityContextWrapper)HttpRuntime.Cache.Get(proxyHeader);
            if (this.clientSecurityContextWrapper == null)
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromClientSecurityContext] ProxyHeader key '{0}' was missing from HttpRuntime cache.  Returning HttpStatusNeedIdentity.", proxyHeader);
                this.context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "MissingCscCacheEntry");
                AirSyncPermanentException ex = new AirSyncPermanentException((HttpStatusCode)441, StatusCode.None, null, false);
                throw ex;
            }
            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromClientSecurityContext] ProxyHeader key '{0}' was found in the HttpRuntime cache.  Reusing CSC for user.", proxyHeader);
            string[] array = proxyHeader.Split(",".ToCharArray(), 2);
            if (array.Length != 2)
            {
                this.context.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "BadProxyHeader");
                throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.InvalidCombinationOfIDs, null, false);
            }
            this.username = array[1];
            ((IAirSyncUser)this).InitializeADUser();
            ((IAirSyncUser)this).AcquireBudget();
        }
예제 #6
0
 private void BackEndWriteContent(IAsyncResult asynchronousResult)
 {
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndWriteContent() Request was timed out while waiting for lock!");
             return;
         }
     }
     try
     {
         AirSyncDiagnostics.TraceDebug <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndWriteContent called for serverName: {0}, user {1}", this.remoteUri, this.userName);
         this.UnregisterTimeoutWaitHandle();
         this.backEndRequestStream.EndWrite(asynchronousResult);
         this.pendingAsyncOperation = ProxyHandler.PendingOperationState.FrontEndReadContentFromClient;
         IAsyncResult asyncResult = this.clientRequestStream.BeginRead(this.asyncBuffer, 0, this.asyncBuffer.Length, new AsyncCallback(this.FrontEndReadContentFromClient), null);
         if (!asyncResult.CompletedSynchronously)
         {
             this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
         }
     }
     catch (Exception ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndWriteContent caught an exception\r\n{0}", arg);
         if (this.backEndWebRequest != null)
         {
             this.backEndWebRequest.Abort();
             this.backEndWebRequest = null;
         }
         this.HandleException(ex);
     }
 }
예제 #7
0
 private static void GetThumbnailPhotoCompleted(IAsyncResult result)
 {
     AirSyncPhotoRetriever.GetThumbnailPhotoFromMailboxDelegate getThumbnailPhotoFromMailboxDelegate = ((AsyncResult)result).AsyncDelegate as AirSyncPhotoRetriever.GetThumbnailPhotoFromMailboxDelegate;
     AirSyncPhotoRetriever.UserPhotoWithSize userPhotoWithSize = result.AsyncState as AirSyncPhotoRetriever.UserPhotoWithSize;
     try
     {
         byte[] userPhotoBytes = getThumbnailPhotoFromMailboxDelegate.EndInvoke(result);
         lock (AirSyncPhotoRetriever.lockObject)
         {
             List <AirSyncPhotoRetriever.UserPhotoWithSize> list;
             if (!AirSyncPhotoRetriever.userPhotosCache.ContainsKey(userPhotoWithSize.UserEmail))
             {
                 list = new List <AirSyncPhotoRetriever.UserPhotoWithSize>();
             }
             else
             {
                 list = AirSyncPhotoRetriever.userPhotosCache[userPhotoWithSize.UserEmail];
             }
             list.Add(new AirSyncPhotoRetriever.UserPhotoWithSize
             {
                 UserEmail      = userPhotoWithSize.UserEmail,
                 PhotoSize      = userPhotoWithSize.PhotoSize,
                 UserPhotoBytes = userPhotoBytes
             });
             AirSyncPhotoRetriever.userPhotosCache.Add(userPhotoWithSize.UserEmail, list);
         }
     }
     catch (AccessDeniedException arg)
     {
         AirSyncDiagnostics.TraceError <AccessDeniedException>(ExTraceGlobals.ProtocolTracer, "AirSyncPhotoRetriever::GetThumbnailPhotoCompleted- Access denied retrieving thumbnailPhoto via GetUserPhoto. TargetUser: {0}.  Exception: {1}", userPhotoWithSize.UserEmail, arg);
     }
 }
예제 #8
0
        internal static List <ChainValidityStatus> ValidateCertificates(List <string> trustedCertificateList, List <string> certificateChainList, List <string> certificateList, bool checkCRL, int hashCodeForTracing, MailboxLogger mailboxLogger, bool againstADConfiguration, string organizationId)
        {
            X509Store trustedStore          = CertificateManager.AddChainCertsToStore(trustedCertificateList, hashCodeForTracing);
            X509Store chainBuildStore       = CertificateManager.AddChainCertsToStore(certificateChainList, hashCodeForTracing);
            List <ChainValidityStatus> list = new List <ChainValidityStatus>(certificateList.Count);

            foreach (string text in certificateList)
            {
                ChainContext chainContext = null;
                try
                {
                    X509Certificate2    certificate = new X509Certificate2(Convert.FromBase64String(text));
                    ChainValidityStatus item        = X509CertificateCollection.ValidateCertificate(certificate, null, X509KeyUsageFlags.NonRepudiation | X509KeyUsageFlags.DigitalSignature, checkCRL, trustedStore, chainBuildStore, ref chainContext, againstADConfiguration, organizationId);
                    list.Add(item);
                }
                catch (CryptographicException ex)
                {
                    if (mailboxLogger != null)
                    {
                        mailboxLogger.SetData(MailboxLogDataName.ValidateCertCommand_ProcessCommand_Per_Cert_Exception, ex.ToString());
                    }
                    AirSyncDiagnostics.TraceError <string, CryptographicException>(ExTraceGlobals.RequestTracer, null, "Failed to validate certificate: '{0}', Error: '{1}'", text, ex);
                    list.Add((ChainValidityStatus)2148098052U);
                }
                finally
                {
                    if (chainContext != null)
                    {
                        chainContext.Dispose();
                    }
                }
            }
            return(list);
        }
예제 #9
0
        // Token: 0x06001569 RID: 5481 RVA: 0x0007E1B0 File Offset: 0x0007C3B0
        protected bool IsIrmOperation(out Guid templateId)
        {
            string templateID = this.TemplateID;

            if (templateID == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "IRM operation not requested by device");
                templateId = Guid.Empty;
                return(false);
            }
            AirSyncCounters.NumberOfSendIRMMails.Increment();
            if (!base.User.IrmEnabled || !base.Request.IsSecureConnection)
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, this, "IRM feature disabled for user {0}", base.User.DisplayName);
                throw new AirSyncPermanentException(StatusCode.IRM_FeatureDisabled, false)
                      {
                          ErrorStringForProtocolLogger = "smbIioFeatureDisabled"
                      };
            }
            if (!DrmClientUtils.TryParseGuid(templateID, out templateId))
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, this, "Invalid template Guid {0}", templateID);
                throw new AirSyncPermanentException(StatusCode.IRM_InvalidTemplateID, false)
                      {
                          ErrorStringForProtocolLogger = "smbIioInvalidTemplateID"
                      };
            }
            return(true);
        }
예제 #10
0
        // Token: 0x06001566 RID: 5478 RVA: 0x0007DE58 File Offset: 0x0007C058
        protected CalendarItemBase GetCalendarItemBaseToReplyOrForward(CalendarItem item)
        {
            ExDateTime       occurrence = this.Occurrence;
            CalendarItemBase result     = null;

            if (occurrence == ExDateTime.MinValue)
            {
                result = item;
            }
            else
            {
                if (item.Recurrence == null)
                {
                    AirSyncDiagnostics.TraceError <string, ExDateTime>(ExTraceGlobals.RequestsTracer, this, "Failed to get occurrence of calendar item with subject: \"{0}\" with Start Time: {1}", item.Subject, occurrence);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoRecurrenceInCalendar");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.NoRecurrenceInCalendar, null, false);
                }
                try
                {
                    CalendarItemOccurrence calendarItemOccurrence = item.OpenOccurrenceByOriginalStartTime(occurrence, null);
                    if (!item.IsMeeting)
                    {
                        calendarItemOccurrence.MakeModifiedOccurrence();
                    }
                    result = calendarItemOccurrence;
                }
                catch (OccurrenceNotFoundException innerException)
                {
                    AirSyncDiagnostics.TraceError <string, ExDateTime>(ExTraceGlobals.RequestsTracer, this, "OccurrenceNotFoundException getting occurrence of calendar item with subject: \"{0}\" with Start Time: {1}", item.Subject, occurrence);
                    base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "NoInstanceInCalendar");
                    throw new AirSyncPermanentException(HttpStatusCode.InternalServerError, StatusCode.NoRecurrenceInCalendar, innerException, false);
                }
            }
            return(result);
        }
예제 #11
0
 private void AirSyncValidationEventHandler(object sender, ValidationEventArgs args)
 {
     this.failed = true;
     this.ValidationErrors.Add(new Validator.XmlValidationError(args));
     if (AirSyncDiagnostics.IsTraceEnabled(TraceType.ErrorTrace, ExTraceGlobals.ValidationTracer))
     {
         StringBuilder stringBuilder     = new StringBuilder();
         XmlSchemaValidationException ex = args.Exception as XmlSchemaValidationException;
         if (ex != null && ex.SourceObject != null)
         {
             XmlElement xmlElement = ex.SourceObject as XmlElement;
             if (xmlElement != null)
             {
                 stringBuilder.Append("Source=").Append(xmlElement.InnerXml);
             }
             if (args.Exception.LineNumber != 0)
             {
                 stringBuilder.Append("Line=").Append(args.Exception.LineNumber);
             }
             if (args.Exception.StackTrace != null)
             {
                 stringBuilder.Append("Stack=").Append(args.Exception.StackTrace);
             }
         }
         AirSyncDiagnostics.TraceError <XmlSeverityType, string, StringBuilder>(ExTraceGlobals.ValidationTracer, null, "Validaton Failure Severity={0} Message={1} {2}", args.Severity, args.Message, stringBuilder);
     }
 }
        // Token: 0x060000BD RID: 189 RVA: 0x00008770 File Offset: 0x00006970
        private void SendMaxDevicesExceededMailIfNeeded(int deviceCount, uint maxDevicesLimit)
        {
            if (Command.CurrentCommand == null)
            {
                return;
            }
            MailboxSession mailboxSession = Command.CurrentCommand.MailboxSession;

            using (SyncStateRootStorage orCreateSyncStateRootStorage = SyncStateRootStorage.GetOrCreateSyncStateRootStorage(mailboxSession, "AirSync", null))
            {
                if (orCreateSyncStateRootStorage == null)
                {
                    AirSyncDiagnostics.TraceError(this.tracer, null, "Error: Could not load SyncStateRootStorage!");
                }
                else
                {
                    using (AirSyncRootInfo airSyncRootInfo = AirSyncRootInfo.LoadFromMailbox(mailboxSession, orCreateSyncStateRootStorage))
                    {
                        if (airSyncRootInfo == null)
                        {
                            AirSyncDiagnostics.TraceError(this.tracer, null, "Error: Could not load AirSyncRootInfo!");
                        }
                        else if (airSyncRootInfo.LastMaxDevicesExceededMailSentTime == null || airSyncRootInfo.LastMaxDevicesExceededMailSentTime.Value.AddHours(24.0) < ExDateTime.UtcNow)
                        {
                            CultureInfo preferedCulture = mailboxSession.PreferedCulture;
                            SystemMessageHelper.PostMessage(mailboxSession, Strings.MaxDevicesExceededMailSubject.ToString(preferedCulture), Strings.MaxDevicesExceededMailBody(deviceCount, maxDevicesLimit).ToString(preferedCulture), null, Importance.High);
                            airSyncRootInfo.LastMaxDevicesExceededMailSentTime = new ExDateTime?(ExDateTime.UtcNow);
                            airSyncRootInfo.SaveToMailbox();
                        }
                    }
                }
            }
        }
예제 #13
0
 private void FrontEndReadContentFromClient(IAsyncResult asynchronousResult)
 {
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.FrontEndReadContentFromClient() Request was timed out while waiting for lock!");
             return;
         }
     }
     try
     {
         AirSyncDiagnostics.TraceDebug <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.FrontEndReadContentFromClient called for serverName: {0}, user {1}", this.remoteUri, this.userName);
         this.UnregisterTimeoutWaitHandle();
         if (this.proxyLoginAttempts == 0 && this.cachedRequestBody == null)
         {
             this.cachedRequestBody = new MemoryStream(this.frontEndHttpContext.Request.ContentLength);
         }
         int num = this.clientRequestStream.EndRead(asynchronousResult);
         if (num > 0)
         {
             if (this.proxyLoginAttempts == 0)
             {
                 this.cachedRequestBody.Write(this.asyncBuffer, 0, num);
             }
             lock (this)
             {
                 this.pendingAsyncOperation = ProxyHandler.PendingOperationState.BackEndWriteContent;
                 IAsyncResult asyncResult = this.backEndRequestStream.BeginWrite(this.asyncBuffer, 0, num, new AsyncCallback(this.BackEndWriteContent), null);
                 if (!asyncResult.CompletedSynchronously)
                 {
                     this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
                 }
                 goto IL_16D;
             }
         }
         this.backEndRequestStream.Flush();
         this.backEndRequestStream.Dispose();
         this.backEndRequestStream  = null;
         this.pendingAsyncOperation = ProxyHandler.PendingOperationState.BackEndGetResponse;
         IAsyncResult asyncResult2 = this.backEndWebRequest.BeginGetResponse(new AsyncCallback(this.BackEndGetResponse), null);
         if (!asyncResult2.CompletedSynchronously)
         {
             this.RegisterTimeoutWaitHandle(asyncResult2, (int)GlobalSettings.ProxyHandlerLongTimeout.TotalMilliseconds);
         }
         IL_16D :;
     }
     catch (Exception ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.FrontEndReadContentFromClient caught an exception\r\n{0}", arg);
         if (this.backEndWebRequest != null)
         {
             this.backEndWebRequest.Abort();
             this.backEndWebRequest = null;
         }
         this.HandleException(ex);
     }
 }
예제 #14
0
 internal override Command.ExecutionState ExecuteCommand()
 {
     try
     {
         this.ParseXmlRequest();
         this.provider = this.CreateProvider(this.reqStoreName);
         if (this.provider == null)
         {
             AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "Unknown search provider specified!");
             base.XmlResponse = this.GetValidationErrorXml();
             return(Command.ExecutionState.Complete);
         }
         XmlDocument xmlResponse = this.BuildXmlResponse();
         this.provider.ParseOptions(this.reqOptionsNode);
         this.provider.ParseQueryNode(this.reqQueryNode);
         MailboxSearchProvider mailboxSearchProvider = this.provider as MailboxSearchProvider;
         if (mailboxSearchProvider != null)
         {
             base.ProtocolLogger.SetValue(ProtocolLoggerData.TotalFolders, mailboxSearchProvider.Folders);
             if (mailboxSearchProvider.DeepTraversal)
             {
                 base.ProtocolLogger.SetValue(ProtocolLoggerData.SearchDeep, 1);
             }
         }
         this.provider.Execute();
         this.provider.BuildResponse(this.respStoreNode);
         base.ProtocolLogger.IncrementValueBy("S", PerFolderProtocolLoggerData.ServerAdds, this.provider.NumberResponses);
         base.XmlResponse = xmlResponse;
     }
     catch (AirSyncPermanentException ex)
     {
         if (ex.HttpStatusCode != HttpStatusCode.OK)
         {
             throw;
         }
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.ProtocolTracer, this, "AirSyncPermanentException was thrown. Location Execute.\r\n{0}", arg);
         base.ProtocolLogger.IncrementValue(ProtocolLoggerData.NumErrors);
         base.ProtocolLogger.AppendValue(ProtocolLoggerData.Error, ex.ErrorStringForProtocolLogger);
         if (base.MailboxLogger != null)
         {
             base.MailboxLogger.SetData(MailboxLogDataName.SearchCommand_Execute_Exception, ex);
         }
         base.XmlResponse    = this.GetProviderErrorXml(ex.AirSyncStatusCodeInInt);
         base.PartialFailure = true;
     }
     finally
     {
         if (this.provider is IDisposable)
         {
             ((IDisposable)this.provider).Dispose();
         }
         this.provider = null;
     }
     return(Command.ExecutionState.Complete);
 }
예제 #15
0
        private void FillInAvailabilityData(List <ResolvedRecipient> availabilityList, AvailabilityQueryResult result)
        {
            if (result.FreeBusyResults == null || result.FreeBusyResults.Length != availabilityList.Count)
            {
                if (result.FreeBusyResults == null)
                {
                    AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "result.FreeBusyResults is null");
                }
                else
                {
                    AirSyncDiagnostics.TraceError <int, int>(ExTraceGlobals.RequestsTracer, this, "The number of results {0} doesn't match expected {1}", result.FreeBusyResults.Length, availabilityList.Count);
                }
                base.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "WrongLengthOfAvailabilityResult");
                foreach (ResolvedRecipient resolvedRecipient in availabilityList)
                {
                    resolvedRecipient.AvailabilityStatus = StatusCode.AvailabilityFailure;
                }
                return;
            }
            int num = -1;

            foreach (ResolvedRecipient resolvedRecipient2 in availabilityList)
            {
                num++;
                if (result.FreeBusyResults[num] == null)
                {
                    AirSyncDiagnostics.TraceError <int>(ExTraceGlobals.RequestsTracer, this, "result.FreeBusyResults[{0}] is null", num);
                    resolvedRecipient2.AvailabilityStatus = StatusCode.AvailabilityFailure;
                }
                else if (result.FreeBusyResults[num].ExceptionInfo != null)
                {
                    AirSyncDiagnostics.TraceError <int, LocalizedException>(ExTraceGlobals.RequestsTracer, this, "result.FreeBusyResults[{0}] returned {1}", num, result.FreeBusyResults[num].ExceptionInfo);
                    if (result.FreeBusyResults[num].ExceptionInfo is FreeBusyDLLimitReachedException)
                    {
                        resolvedRecipient2.AvailabilityStatus = StatusCode.AvailabilityDLLimitReached;
                    }
                    else if (result.FreeBusyResults[num].ExceptionInfo is TransientException || result.FreeBusyResults[num].ExceptionInfo.InnerException is TransientException)
                    {
                        resolvedRecipient2.AvailabilityStatus = StatusCode.AvailabilityTransientFailure;
                    }
                    else
                    {
                        resolvedRecipient2.AvailabilityStatus = StatusCode.AvailabilityFailure;
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(result.FreeBusyResults[num].MergedFreeBusy))
                    {
                        throw new InvalidOperationException("Empty free busy string received!");
                    }
                    resolvedRecipient2.AvailabilityStatus = StatusCode.Success;
                    resolvedRecipient2.MergedFreeBusy     = result.FreeBusyResults[num].MergedFreeBusy;
                }
            }
        }
예제 #16
0
        public static IEnumerable <RmsTemplate> GetRmsTemplates(OrganizationId organizationId)
        {
            bool flag = false;
            IEnumerable <RmsTemplate> result;

            try
            {
                if (!RmsClientManager.IRMConfig.IsInternalLicensingEnabledForTenant(organizationId))
                {
                    RmsTemplateReaderCache.negativeCacheTimeoutForFirstOrg = ExDateTime.MinValue;
                    throw new AirSyncPermanentException(StatusCode.IRM_FeatureDisabled, false)
                          {
                              ErrorStringForProtocolLogger = "rtrcGrtInternalLicensingDisabled"
                          };
                }
                if (organizationId == OrganizationId.ForestWideOrgId && RmsTemplateReaderCache.negativeCacheTimeoutForFirstOrg > ExDateTime.UtcNow)
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, null, "Found RMSTemplateReader for first org in negative cache");
                    throw new AirSyncPermanentException(StatusCode.IRM_TransientError, false)
                          {
                              ErrorStringForProtocolLogger = "rtrcGrtNegativeCacheHit"
                          };
                }
                result = RmsClientManager.AcquireRmsTemplates(organizationId, false);
            }
            catch (ExchangeConfigurationException ex)
            {
                AirSyncDiagnostics.TraceError <ExchangeConfigurationException>(ExTraceGlobals.RequestsTracer, null, "ExchangeConfigurationException encountered while acquiring RMS templates: {0}", ex);
                flag = true;
                throw new AirSyncPermanentException(StatusCode.IRM_TransientError, ex, false)
                      {
                          ErrorStringForProtocolLogger = "rtrcGrtExchangeConfigurationException"
                      };
            }
            catch (RightsManagementException ex2)
            {
                AirSyncDiagnostics.TraceError <RightsManagementException>(ExTraceGlobals.RequestsTracer, null, "RightsManagementException encountered while acquiring RMS templates: {0}", ex2);
                if (ex2.FailureCode != RightsManagementFailureCode.InternalLicensingDisabled)
                {
                    flag = true;
                }
                throw new AirSyncPermanentException(ex2.IsPermanent ? StatusCode.IRM_PermanentError : StatusCode.IRM_TransientError, ex2, false)
                      {
                          ErrorStringForProtocolLogger = "rtrcGrtRightsManagementException" + ex2.FailureCode.ToString()
                      };
            }
            finally
            {
                if (organizationId == OrganizationId.ForestWideOrgId && flag)
                {
                    RmsTemplateReaderCache.negativeCacheTimeoutForFirstOrg = ExDateTime.UtcNow.Add(GlobalSettings.NegativeRmsTemplateCacheExpirationInterval);
                }
            }
            return(result);
        }
예제 #17
0
        private static void HandleMissingSchemaDirectory(Exception ex)
        {
            bool watsonReportEnabled = true;

            if (ex == null || ex is ArgumentNullException || ex is SecurityException || ex is ArgumentException || ex is PathTooLongException)
            {
                watsonReportEnabled = false;
            }
            AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, null, "SchemaDirectory is not specified in the web.config or it is not accessible. Exception '{0}' ", (ex == null) ? string.Empty : ex.ToString());
            throw new AirSyncFatalException(EASServerStrings.SchemaDirectoryNotAccessible, "SchemaDirectoryNotAccessible", watsonReportEnabled, ex);
        }
예제 #18
0
        private static void HandleMissingSchemaVersionDirectory(Exception ex, string directoryPath)
        {
            bool watsonReportEnabled = true;

            if (ex == null || ex is ArgumentNullException || ex is SecurityException || ex is ArgumentException || ex is PathTooLongException)
            {
                watsonReportEnabled = false;
            }
            AirSyncDiagnostics.TraceError <string, string>(ExTraceGlobals.RequestsTracer, null, "SchemaDirectory with path '{0}' is missing or  not accessible. Exception '{1}' ", directoryPath, (ex == null) ? string.Empty : ex.ToString());
            throw new AirSyncFatalException(EASServerStrings.SchemaDirectoryVersionNotAccessible(directoryPath), "SchemaDirectoryVersionNotAccessible", watsonReportEnabled, ex);
        }
예제 #19
0
        private Uri GetEcpUrl(ExchangePrincipal mailbox)
        {
            Uri       uri = null;
            Exception ex  = null;

            try
            {
                if (mailbox.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && GlobalSettings.IsMultiTenancyEnabled)
                {
                    uri = FrontEndLocator.GetFrontEndEcpUrl(mailbox);
                    AirSyncDiagnostics.TraceDebug <ExchangePrincipal, Uri>(ExTraceGlobals.RequestsTracer, null, "ABQMail:ECP URL for user {0} - {1} (E15 Multitenancy)", mailbox, uri);
                }
                else
                {
                    ServiceTopology    serviceTopology = GlobalSettings.IsMultiTenancyEnabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 605) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 605);
                    ServerVersion      serverVersion   = new ServerVersion(mailbox.MailboxInfo.Location.ServerVersion);
                    int                majorversion    = serverVersion.Major;
                    IList <EcpService> list            = serviceTopology.FindAll <EcpService>(mailbox, ClientAccessType.External, (EcpService service) => new ServerVersion(service.ServerVersionNumber).Major == majorversion, "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ABQMailHelper.cs", "GetEcpUrl", 610);
                    foreach (EcpService ecpService in list)
                    {
                        if (ecpService != null && ecpService.Url != null)
                        {
                            uri = ecpService.Url;
                            AirSyncDiagnostics.TraceDebug <ExchangePrincipal, Uri>(ExTraceGlobals.RequestsTracer, null, "ABQMail:ECP URL for user {0} - {1} (not E15 Multitenancy)", mailbox, uri);
                            break;
                        }
                    }
                }
            }
            catch (ServerNotFoundException ex2)
            {
                ex = ex2;
            }
            catch (ADTransientException ex3)
            {
                ex = ex3;
            }
            catch (DataSourceOperationException ex4)
            {
                ex = ex4;
            }
            catch (DataValidationException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex != null)
                {
                    AirSyncDiagnostics.TraceError <ExchangePrincipal, Exception>(ExTraceGlobals.RequestsTracer, null, "ABQMail:Could not retrieve ECP URL for user {0} - {1}", mailbox, ex);
                }
            }
            return(uri);
        }
예제 #20
0
 private static void HandleBadSchemaFile(Exception ex, string dirPath)
 {
     if (ex is XmlSchemaException)
     {
         XmlSchemaException ex2  = (XmlSchemaException)ex;
         string             text = (ex2.SourceUri != null) ? ex2.SourceUri : string.Empty;
         AirSyncDiagnostics.TraceError <string, string>(ExTraceGlobals.RequestsTracer, null, "Schema file with path '{0}' is corrupted. Exception '{1}'", text, ex2.ToString());
         throw new AirSyncFatalException(EASServerStrings.SchemaFileCorrupted(text), "SchemaFileCorrupted", false, ex2);
     }
     AirSyncDiagnostics.TraceError <string, string>(ExTraceGlobals.RequestsTracer, null, "Unable to compile the XSD SchemaSet under the folder '{0}'. Exception '{1}' ", dirPath, (ex == null) ? string.Empty : ex.ToString());
     throw new AirSyncFatalException(EASServerStrings.SchemaUnknownCompilationError(dirPath), "SchemaUnknownCompilationError", true, ex);
 }
예제 #21
0
        protected override ADMobileVirtualDirectory CreateOnCacheMiss(string vDirObjectId, ref bool shouldAdd)
        {
            if (string.IsNullOrEmpty(vDirObjectId))
            {
                throw new ArgumentNullException("vDirObjectId");
            }
            int        num = vDirObjectId.LastIndexOf('/');
            string     forestFqdn;
            ADObjectId adobjectId;

            if (num == -1)
            {
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.AlgorithmTracer, null, "VDir header from Cafe server: {0} contains only vDirObjectId. Read data using local forest.", vDirObjectId);
                forestFqdn = string.Empty;
                adobjectId = this.ParseObjectGuid(vDirObjectId);
            }
            else
            {
                forestFqdn = vDirObjectId.Substring(num + 1);
                adobjectId = this.ParseObjectGuid(vDirObjectId.Substring(0, num));
            }
            if (adobjectId == null)
            {
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.AlgorithmTracer, null, "ObjectGuid could not be parsed from vDir header: {0}", vDirObjectId.Substring(0, num));
                shouldAdd = false;
                return(null);
            }
            ADMobileVirtualDirectory admobileVirtualDirectory = null;

            try
            {
                string suitableDomainController = this.GetSuitableDomainController(forestFqdn);
                if (!string.IsNullOrEmpty(suitableDomainController))
                {
                    ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(suitableDomainController, true, ConsistencyMode.IgnoreInvalid, null, ADSessionSettings.FromRootOrgScopeSet(), 108, "CreateOnCacheMiss", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\ADObjIdToVDirMap.cs");
                    admobileVirtualDirectory = topologyConfigurationSession.Read <ADMobileVirtualDirectory>(adobjectId);
                    AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.AlgorithmTracer, null, "VDir object read from AD and cached: {0}", vDirObjectId);
                }
                else
                {
                    AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.AlgorithmTracer, null, "Failure looking up vDir object {0}", vDirObjectId);
                }
            }
            catch (ADTransientException ex)
            {
                AirSyncDiagnostics.TraceError <string, string>(ExTraceGlobals.AlgorithmTracer, null, "ADTransientException looking up vDir object {0}: {1}", vDirObjectId, ex.Message);
            }
            if (admobileVirtualDirectory == null)
            {
                shouldAdd = false;
            }
            return(admobileVirtualDirectory);
        }
예제 #22
0
 // Token: 0x060002FF RID: 767 RVA: 0x0000FD28 File Offset: 0x0000DF28
 private void InitializeFromRehydratedIdentity()
 {
     if (this.clientSecurityContextWrapper != null)
     {
         AirSyncDiagnostics.TraceInfo(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromRehydratedIdentity]. clientSecurityContextWrapper is not null. calling dispose.");
         this.clientSecurityContextWrapper.Dispose();
     }
     this.clientSecurityContextWrapper = ClientSecurityContextWrapper.FromIdentity(((IAirSyncUser)this).Identity);
     this.username = ((IAirSyncUser)this).Identity.Name;
     AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, null, "[AirSyncUser.InitializeFromRehydratedIdentity] Hyrdating CSC from user {0}", this.username);
     ((IAirSyncUser)this).InitializeADUser();
     ((IAirSyncUser)this).AcquireBudget();
 }
예제 #23
0
        private void HandleException(Exception ex)
        {
            AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestsTracer, this, "HandleException() is swallowing exception and returning HTTP 500 - {0}", ex);
            WebException ex2 = ex as WebException;

            if (ex2 != null)
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append(ex2.Status);
                if (ex2.Response != null)
                {
                    stringBuilder.Append(".");
                    stringBuilder.Append(((HttpWebResponse)ex2.Response).StatusCode);
                }
                this.protocolLogger.SetValue(ProtocolLoggerData.Error, stringBuilder.ToString());
            }
            else if (ex is SocketException || ex is IOException)
            {
                StringBuilder stringBuilder2 = new StringBuilder();
                stringBuilder2.Append("SocketIOException: ");
                stringBuilder2.Append(ex.Message);
                this.protocolLogger.SetValue(ProtocolLoggerData.Error, stringBuilder2.ToString());
            }
            else
            {
                if (!(ex is AirSyncPermanentException))
                {
                    throw ex;
                }
                StringBuilder stringBuilder3 = new StringBuilder();
                stringBuilder3.Append("AirSyncPermanentException: ");
                stringBuilder3.Append(ex.Message);
                this.protocolLogger.SetValue(ProtocolLoggerData.Error, stringBuilder3.ToString());
            }
            try
            {
                this.TryUnregisterTimeoutWaitHandle();
                this.frontEndHttpContext.Response.Clear();
                this.frontEndHttpContext.Response.StatusCode = 500;
                this.frontEndResult.InvokeCallback();
            }
            catch (HttpException ex3)
            {
                AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex3);
                AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "HttpException was thrown while setting the StatusCode.\r\n{0}", arg);
            }
            finally
            {
                this.ReleaseResources();
            }
        }
예제 #24
0
 private void BackEndReadContent(IAsyncResult asynchronousResult)
 {
     lock (this)
     {
         if (this.requestWasTimedOut)
         {
             AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndReadContent() Request was timed out while waiting for lock!");
             string text = this.remoteUri.Host.ToString();
             AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_ProxyResultTimedOut, text, new string[]
             {
                 text
             });
             return;
         }
     }
     try
     {
         AirSyncDiagnostics.TraceDebug <Uri, string>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndReadContent called for serverName: {0}, user {1}", this.remoteUri, this.userName);
         this.UnregisterTimeoutWaitHandle();
         int num = this.backEndResponseStream.EndRead(asynchronousResult);
         if (num > 0)
         {
             this.frontEndHttpContext.Response.OutputStream.Write(this.asyncBuffer, 0, num);
             this.backEndResponseStream = this.httpWebResponse.GetResponseStream();
             this.pendingAsyncOperation = ProxyHandler.PendingOperationState.BackEndReadContent;
             IAsyncResult asyncResult = this.backEndResponseStream.BeginRead(this.asyncBuffer, 0, this.asyncBuffer.Length, new AsyncCallback(this.BackEndReadContent), null);
             if (!asyncResult.CompletedSynchronously)
             {
                 this.RegisterTimeoutWaitHandle(asyncResult, (int)GlobalSettings.ProxyHandlerShortTimeout.TotalMilliseconds);
             }
         }
         else
         {
             this.UnregisterTimeoutWaitHandle();
             this.frontEndResult.InvokeCallback();
             this.ReleaseResources();
         }
     }
     catch (Exception ex)
     {
         AirSyncUtility.ExceptionToStringHelper arg = new AirSyncUtility.ExceptionToStringHelper(ex);
         AirSyncDiagnostics.TraceError <AirSyncUtility.ExceptionToStringHelper>(ExTraceGlobals.RequestsTracer, this, "ProxyHandler.BackEndReadContent caught an exception\r\n{0}", arg);
         if (this.backEndWebRequest != null)
         {
             this.backEndWebRequest.Abort();
             this.backEndWebRequest = null;
         }
         this.HandleException(ex);
     }
 }
예제 #25
0
 internal void SendABQNotificationMail()
 {
     using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(this.context.User.ExchangePrincipal, this.context.Request.Culture, "Client=ActiveSync;Action=ABQMail"))
     {
         this.cultureInfo = mailboxSession.PreferedCulture;
         MicrosoftExchangeRecipient exchangeRecipient = this.organizationSettings.GetExchangeRecipient();
         StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);
         using (MessageItem messageItem = MessageItem.Create(mailboxSession, defaultFolderId))
         {
             this.ConstructUserNotificationMail(messageItem);
             messageItem.From = ((exchangeRecipient == null) ? new Participant(mailboxSession.MailboxOwner) : new Participant(exchangeRecipient));
             messageItem.Recipients.Add(new Participant(mailboxSession.MailboxOwner), RecipientItemType.To);
             messageItem[MessageItemSchema.IsDraft] = false;
             messageItem[MessageItemSchema.IsRead]  = false;
             messageItem.Save(SaveMode.NoConflictResolution);
             messageItem.Load(new PropertyDefinition[0]);
             this.globalInfo.ABQMailId    = messageItem.Id.ObjectId;
             this.globalInfo.ABQMailState = ABQMailState.MailPosted;
         }
         defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Drafts);
         if (this.globalInfo.DeviceAccessState == DeviceAccessState.Quarantined)
         {
             using (MessageItem messageItem2 = MessageItem.Create(mailboxSession, defaultFolderId))
             {
                 foreach (SmtpAddress smtpAddress in this.organizationSettings.AdminMailRecipients)
                 {
                     Participant participant;
                     if (smtpAddress.IsValidAddress && Participant.TryParse(smtpAddress.ToString(), out participant) && participant != null)
                     {
                         messageItem2.Recipients.Add(participant, RecipientItemType.To);
                     }
                 }
                 if (messageItem2.Recipients.Count > 0)
                 {
                     this.ConstructAdminNotificationMail(messageItem2);
                     messageItem2.From = ((exchangeRecipient == null) ? new Participant(mailboxSession.MailboxOwner) : new Participant(exchangeRecipient));
                     messageItem2.SendWithoutSavingMessage();
                 }
                 else
                 {
                     AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, null, "ABQMail:No valid AdminMailRecipients to send Admin mail to!");
                     if (VariantConfiguration.InvariantNoFlightingSnapshot.ActiveSync.ActiveSyncDiagnosticsLogABQPeriodicEvent.Enabled)
                     {
                         AirSyncDiagnostics.LogPeriodicEvent(AirSyncEventLogConstants.Tuple_NoAdminMailRecipientsError, "NoAdminMailRecipients", new string[0]);
                     }
                 }
             }
         }
     }
 }
예제 #26
0
        // Token: 0x06000370 RID: 880 RVA: 0x0001410C File Offset: 0x0001230C
        private AnrManager.LookupState GetNamesByAnrFromAD(string name, List <ResolvedRecipient> recipients)
        {
            IList <ABObject>            addressBookObjects          = null;
            OperationRetryManagerResult operationRetryManagerResult = AnrManager.retryManager.TryRun(delegate
            {
                addressBookObjects = this.GetAddressBookSession().FindByANR(name, 1000);
            });

            if (operationRetryManagerResult.Succeeded)
            {
                using (IEnumerator <ABObject> enumerator = addressBookObjects.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ABObject abobject = enumerator.Current;
                        if (abobject.CanEmail)
                        {
                            ResolvedRecipient resolvedRecipient = new ResolvedRecipient(new RecipientAddress
                            {
                                AddressOrigin  = AddressOrigin.Directory,
                                DisplayName    = abobject.DisplayName,
                                RoutingAddress = abobject.LegacyExchangeDN,
                                RoutingType    = "EX",
                                SmtpAddress    = abobject.EmailAddress
                            });
                            ABContact abcontact = abobject as ABContact;
                            if (abcontact != null)
                            {
                                resolvedRecipient.Picture = abcontact.Picture;
                            }
                            recipients.Add(resolvedRecipient);
                        }
                    }
                    goto IL_F7;
                }
            }
            AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.RequestTracer, 0, "AnrManager.GetNamesByAnrFromAD(): Exception thrown by FindByANR: {0}", operationRetryManagerResult.Exception);
IL_F7:
            switch (recipients.Count)
            {
            case 0:
                return(AnrManager.LookupState.FoundNone);

            case 1:
                return(AnrManager.LookupState.FoundExact);

            default:
                return(AnrManager.LookupState.FoundMany);
            }
        }
        private static IOrganizationSettingsData LoadOrganizationSettings(IConfigurationSession scopedSession, IAirSyncContext context)
        {
            ADObjectId organizationId = scopedSession.GetOrgContainerId();
            ActiveSyncOrganizationSettings organizationSettings = null;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                organizationSettings = scopedSession.Read <ActiveSyncOrganizationSettings>(organizationId.GetDescendantId(new ADObjectId("CN=Mobile Mailbox Settings")));
            });

            if (!adoperationResult.Succeeded)
            {
                AirSyncDiagnostics.TraceDebug <ADObjectId, string>(ExTraceGlobals.RequestsTracer, null, "Exception occurred during AD Operation during LoadOrganizationSettings {0}. Exception Message- {1}", organizationId, adoperationResult.Exception.Message);
            }
            ValidationError[] array = organizationSettings.Validate();
            bool flag = false;

            if (array != null)
            {
                foreach (ValidationError validationError in array)
                {
                    if (string.Equals(validationError.PropertyName, "ConfigurationXMLRaw", StringComparison.OrdinalIgnoreCase))
                    {
                        flag = true;
                    }
                }
            }
            if (flag)
            {
                organizationSettings.DeviceFiltering = null;
            }
            ADRawEntry adrawEntry = scopedSession.ReadADRawEntry(organizationId, new PropertyDefinition[]
            {
                OrganizationSchema.IntuneManagedStatus
            });

            organizationSettings.IsIntuneManaged = (adrawEntry != null && (bool)adrawEntry[OrganizationSchema.IntuneManagedStatus]);
            AirSyncDiagnostics.TraceInfo <bool>(ExTraceGlobals.RequestsTracer, null, "LoadOrganizationSettings from AD.IntuneManagedStatus {0}.", organizationSettings.IsIntuneManaged);
            if (context != null)
            {
                context.ProtocolLogger.SetValue(ProtocolLoggerData.DomainController, scopedSession.LastUsedDc);
            }
            if (organizationSettings != null)
            {
                AirSyncDiagnostics.TraceInfo <int>(ExTraceGlobals.RequestsTracer, null, "LoadOrganizationSettings from AD. Found {0} OrganizationSettings.", 1);
                return(ADNotificationManager.AddOrganizationSettingsToCache(organizationSettings, scopedSession));
            }
            AirSyncDiagnostics.TraceError <ADObjectId>(ExTraceGlobals.RequestsTracer, null, "Cannot find ActiveSyncOrganizationSettings object in AD for organization {0}", organizationId);
            return(null);
        }
예제 #28
0
        internal static StatusCode GetThumbnailPhotoFromMailbox(IAirSyncContext context, string targetPrimarySmtpAddress, out byte[] thumbnailPhoto)
        {
            thumbnailPhoto = null;
            ClientContext clientContext = ClientContext.Create(context.User.ClientSecurityContextWrapper.ClientSecurityContext, context.User.ExchangePrincipal.MailboxInfo.OrganizationId, null, null, CultureInfo.InvariantCulture, Guid.NewGuid().ToString());

            clientContext.RequestSchemaVersion = ExchangeVersionType.Exchange2012;
            if (!SmtpAddress.IsValidSmtpAddress(targetPrimarySmtpAddress))
            {
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.ProtocolTracer, null, "Target SMTP address is not valid: {0}", targetPrimarySmtpAddress);
                return(StatusCode.NoPicture);
            }
            GetUserPhotoQuery getUserPhotoQuery = new GetUserPhotoQuery(clientContext, new PhotoRequest
            {
                Requestor = new PhotoPrincipal
                {
                    EmailAddresses = new string[]
                    {
                        context.User.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()
                    },
                    OrganizationId = context.User.ExchangePrincipal.MailboxInfo.OrganizationId
                },
                Size = UserPhotoSize.HR648x648,
                TargetSmtpAddress = targetPrimarySmtpAddress,
                Trace             = ExTraceGlobals.ProtocolTracer.IsTraceEnabled(TraceType.DebugTrace),
                HostOwnedTargetMailboxSessionGetter = new Func <ExchangePrincipal, IMailboxSession>(AirSyncPhotoRetriever.GetCachedMailboxSessionForPhotoRequest)
            }, null, false, AirSyncPhotoRetriever.PhotosConfiguration, ExTraceGlobals.ProtocolTracer);
            StatusCode result;

            try
            {
                thumbnailPhoto = getUserPhotoQuery.Execute();
                if (thumbnailPhoto == null || thumbnailPhoto.Length == 0)
                {
                    AirSyncDiagnostics.TraceError(ExTraceGlobals.ProtocolTracer, "Unable to retrieve thumbnailPhoto via GetUserPhoto for {0}", targetPrimarySmtpAddress);
                    result = StatusCode.NoPicture;
                }
                else
                {
                    result = StatusCode.Success;
                }
            }
            catch (AccessDeniedException arg)
            {
                AirSyncDiagnostics.TraceError <AccessDeniedException>(ExTraceGlobals.ProtocolTracer, "Access denied retrieving thumbnailPhoto via GetUserPhoto for {0}.  Exception: {1}", targetPrimarySmtpAddress, arg);
                result = StatusCode.NoPicture;
            }
            return(result);
        }
 protected AirSyncPermanentException(SerializationInfo info, StreamingContext context)
 {
     this.httpStatusCode          = HttpStatusCode.InternalServerError;
     this.logStackTraceToEventLog = true;
     base..ctor(info, context);
     AirSyncDiagnostics.TraceError(ExTraceGlobals.RequestsTracer, this, "AirSyncPermanentException is being deserialized");
     this.httpStatusCode    = (HttpStatusCode)info.GetValue("httpStatusCode", typeof(HttpStatusCode));
     this.airSyncStatusCode = (StatusCode)info.GetValue("airSyncStatusCode", typeof(StatusCode));
     foreach (SerializationEntry serializationEntry in info)
     {
         if (serializationEntry.Name == "xmlResponse")
         {
             this.xmlResponse = (XmlDocument)serializationEntry.Value;
         }
     }
 }
예제 #30
0
 // Token: 0x0600027A RID: 634 RVA: 0x0000E33C File Offset: 0x0000C53C
 void IAirSyncResponse.IssueWbXmlResponse()
 {
     if (this.responseWritten)
     {
         AirSyncDiagnostics.TraceError(ExTraceGlobals.ProtocolTracer, this, "[AirSyncResponse.IssueWbXmlResponse] Document has already been written to the HttpResponse stream.");
         return;
     }
     if (this.xmlDocument != null)
     {
         this.httpResponse.ClearContent();
         this.httpResponse.ContentType = "application/vnd.ms-sync.wbxml";
         WbxmlWriter wbxmlWriter = new WbxmlWriter(this.httpResponse.OutputStream);
         wbxmlWriter.WriteXmlDocument(this.xmlDocument);
         this.responseWritten = true;
     }
 }