Beispiel #1
0
        public bool FindLog(DateTime timestamp, bool createIfNotExists, out IAuditLog auditLog)
        {
            auditLog = null;
            DateTime     dateTime;
            DateTime     dateTime2;
            string       logFolderNameAndRange = AuditLogCollection.GetLogFolderNameAndRange(timestamp, out dateTime, out dateTime2);
            FolderIdType folderIdType          = null;

            if (!this.ewsClient.FindFolder(logFolderNameAndRange, this.auditRootFolderId, out folderIdType))
            {
                if (!createIfNotExists)
                {
                    if (this.IsTraceEnabled(TraceType.DebugTrace))
                    {
                        this.Tracer.TraceDebug <DateTime>((long)this.GetHashCode(), "No matching log subfolder found. Lookup time={0}", timestamp);
                    }
                    return(false);
                }
                bool flag = this.ewsClient.CreateFolder(logFolderNameAndRange, this.auditRootFolderId, out folderIdType);
                if (!flag)
                {
                    flag = this.ewsClient.FindFolder(logFolderNameAndRange, this.auditRootFolderId, out folderIdType);
                }
                if (!flag && this.IsTraceEnabled(TraceType.DebugTrace))
                {
                    this.Tracer.TraceDebug <DateTime, DateTime>((long)this.GetHashCode(), "Failed to create audit log folder for log range [{0}, {1})", dateTime, dateTime2);
                }
            }
            if (folderIdType != null)
            {
                auditLog = new EwsAuditLog(this.ewsClient, folderIdType, dateTime, dateTime2);
            }
            return(folderIdType != null);
        }
Beispiel #2
0
        private IAuditLog GetAuditLog(string organizationIdEncoded, AuditRecord auditRecord)
        {
            CacheEntry <IAuditLog> cacheEntry;
            IAuditLog         auditLog          = this.auditLogs.TryGetValue(organizationIdEncoded, DateTime.UtcNow, out cacheEntry) ? cacheEntry.Value : null;
            ExchangePrincipal exchangePrincipal = this.GetExchangePrincipal(organizationIdEncoded);
            EwsAuditClient    ewsClient         = null;
            FolderIdType      folderIdType      = null;

            if (AuditFeatureManager.IsPartitionedAdminLogEnabled(exchangePrincipal) && (auditLog == null || auditLog.EstimatedLogEndTime < auditRecord.CreationTime))
            {
                this.GetClientAndRootFolderId(exchangePrincipal, ref ewsClient, ref folderIdType);
                EwsAuditLogCollection ewsAuditLogCollection = new EwsAuditLogCollection(ewsClient, folderIdType);
                if (ewsAuditLogCollection.FindLog(auditRecord.CreationTime, true, out auditLog))
                {
                    this.auditLogs.Set(organizationIdEncoded, DateTime.UtcNow, new CacheEntry <IAuditLog>(auditLog));
                }
                else
                {
                    auditLog = null;
                }
            }
            if (auditLog == null)
            {
                this.GetClientAndRootFolderId(exchangePrincipal, ref ewsClient, ref folderIdType);
                auditLog = new EwsAuditLog(ewsClient, folderIdType, DateTime.MinValue, DateTime.MaxValue);
                this.auditLogs.Set(organizationIdEncoded, DateTime.UtcNow, new CacheEntry <IAuditLog>(auditLog));
            }
            return(auditLog);
        }
Beispiel #3
0
        public int WriteAuditRecord(IAuditLogRecord auditRecord)
        {
            this.ewsClient.RefreshUrl(false);
            int            result         = 0;
            CreateItemType createItemType = EwsAuditLog.GetCreateItemType(auditRecord, this.auditFolderId, out result);

            this.ewsClient.CreateItem(createItemType);
            return(result);
        }
Beispiel #4
0
 public EwsAuditLogQueryContext(EwsAuditLog auditLog)
 {
     this.auditLog           = auditLog;
     this.pendingAsyncResult = null;
 }