public EwsAuditLog(EwsAuditClient ewsClient, FolderIdType auditFolderId, DateTime logRangeStart, DateTime logRangeEnd) { this.ewsClient = ewsClient; this.auditFolderId = auditFolderId; this.EstimatedLogStartTime = logRangeStart; this.EstimatedLogEndTime = logRangeEnd; }
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); }
private static FolderIdType GetAuditRootFolderId(EwsAuditClient ewsClient) { FolderIdType folderIdType; ewsClient.CheckAndCreateWellKnownFolder(DistinguishedFolderIdNameType.root, DistinguishedFolderIdNameType.recoverableitemsroot, out folderIdType); FolderIdType result; ewsClient.CheckAndCreateWellKnownFolder(DistinguishedFolderIdNameType.recoverableitemsroot, DistinguishedFolderIdNameType.adminauditlogs, out result); return(result); }
public EwsAuditLogCollection(EwsAuditClient ewsClient, FolderIdType auditRootFolderId) { this.ewsClient = ewsClient; this.auditRootFolderId = auditRootFolderId; }
private void GetClientAndRootFolderId(ExchangePrincipal principal, ref EwsAuditClient ewsClient, ref FolderIdType auditRootFolderId) { ewsClient = (ewsClient ?? new EwsAuditClient(new EwsConnectionManager(principal, OpenAsAdminOrSystemServiceBudgetTypeType.Unthrottled, this.Tracer), EwsAuditClient.DefaultSoapClientTimeout, this.Tracer)); auditRootFolderId = (auditRootFolderId ?? AdminAuditWriter.GetAuditRootFolderId(ewsClient)); }