public void LogCertificate(EdgeSyncLoggingLevel level, EdgeSyncEvent logEvent, X509Certificate2 cert) { if (cert == null) { return; } if (!this.CanLogEvent(level)) { return; } this.LogEvent(level, logEvent, cert.Subject, "Certificate subject"); this.LogEvent(level, logEvent, cert.IssuerName.Name, "Certificate issuer name"); this.LogEvent(level, logEvent, cert.SerialNumber, "Certificate serial number"); this.LogEvent(level, logEvent, cert.Thumbprint, "Certificate thumbprint"); StringBuilder stringBuilder = new StringBuilder(256); foreach (string value in TlsCertificateInfo.GetFQDNs(cert)) { if (stringBuilder.Length != 0) { stringBuilder.Append(';'); } stringBuilder.Append(value); } this.LogEvent(level, logEvent, stringBuilder.ToString(), "Certificate alternate names"); }
internal EdgeSyncLogSession(EdgeSyncLog edgeSyncLog, LogRowFormatter row, EdgeSyncLoggingLevel loggingLevel) { this.edgeSyncLog = edgeSyncLog; this.row = row; this.loggingLevel = loggingLevel; this.row[2] = 0; }
public void LogAndTraceInfo(EdgeSyncLoggingLevel level, string messageFormat, params object[] args) { string diagString = EdgeSyncDiag.GetDiagString(messageFormat, args); this.LogSession.LogEvent(level, EdgeSyncEvent.TargetConnection, null, diagString); this.Tracer.TraceDebug <string>((long)this.GetHashCode(), "{0}", diagString); }
public void LogEvent(EdgeSyncLoggingLevel loggingLevel, EdgeSyncEvent eventId, string data, string context) { if (!this.CanLogEvent(loggingLevel)) { return; } this.row[6] = eventId; this.row[9] = context; this.row[8] = data; this.row[7] = loggingLevel; this.edgeSyncLog.Append(this.row); this.row[2] = (int)this.row[2] + 1; }
public void LogException(EdgeSyncLoggingLevel level, EdgeSyncEvent edgeEvent, Exception exception, string context) { if (!this.CanLogEvent(level)) { return; } StringBuilder stringBuilder = new StringBuilder(exception.Message.Length + exception.GetType().Name.Length + 3); stringBuilder.AppendFormat("{0} [{1}]", exception.Message, exception.GetType().Name); if (exception.InnerException != null) { stringBuilder.AppendFormat("; Inner Exception: {0} [{1}]", exception.InnerException.Message, exception.InnerException.GetType().Name); } this.LogEvent(level, edgeEvent, stringBuilder.ToString(), context); }
protected override void HandleCreateDomainResponse(DomainResponseInfoSet responseSet, List <EhfDomainItem> domainsTriedToCreate) { int num = 0; int permanentFailureCount = 0; List <EhfDomainItemVersion2> list = new List <EhfDomainItemVersion2>(); List <EhfDomainItemVersion2> list2 = new List <EhfDomainItemVersion2>(); for (int i = 0; i < responseSet.ResponseInfo.Length; i++) { DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i]; EhfDomainItemVersion2 ehfDomainItemVersion = domainsTriedToCreate[i] as EhfDomainItemVersion2; if (ehfDomainItemVersion == null) { throw new InvalidOperationException("Version 2 of EhfConnector should be using version 2 of EhfDomainItem"); } if (domainResponseInfo.Status == ResponseStatus.Success) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully created EHF domain: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Domain.Name, domainResponseInfo.DomainGuid.Value, ehfDomainItemVersion.Domain.CompanyId }); if (ehfDomainItemVersion.TryClearForceDomainSyncFlagFromPerimeterConfig(base.ADAdapter) == EhfADResultCode.Failure) { num++; } if (!this.UpdateDuplicateDetectedFlag(ehfDomainItemVersion)) { num++; } } else if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany || domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany) { Guid domainGuid = ehfDomainItemVersion.GetDomainGuid(); if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany && domainResponseInfo.DomainGuid.Value.Equals(domainGuid)) { if (ehfDomainItemVersion.TriedToUpdateDomain && !ehfDomainItemVersion.DomainCreatedWithGuid) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to create a domain that already exists. Treating this as error since update is already called: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Domain.Name, domainGuid, ehfDomainItemVersion.Domain.CompanyId }); base.HandleFailedDomain("Create Domain", ehfDomainItemVersion, domainResponseInfo, ref num, ref permanentFailureCount); } else { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to create a domain that already exists. Trying to update the domain. DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Domain.Name, domainGuid, ehfDomainItemVersion.Domain.CompanyId }); list.Add(ehfDomainItemVersion); } } else if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany && domainResponseInfo.SourceId == ProvisioningSource.Other && !ehfDomainItemVersion.DomainCreatedWithGuid) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "A domain collision is detected for domain: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-Company-ID=<{3}>. Trying to create the domain as OutboundOnly domain.", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Name, domainGuid, ehfDomainItemVersion.Domain.CompanyId }); list2.Add(ehfDomainItemVersion); } else if (!base.HandledAllDeletedDomains) { base.AddDomainToCreateLastList(ehfDomainItemVersion); EdgeSyncDiag diagSession = base.DiagSession; EdgeSyncLoggingLevel level = EdgeSyncLoggingLevel.Low; string messageFormat = "Attempted to create a domain with the name that already exists but a different GUID: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-GUID=<{3}>; EHF-Company-ID=<{4}>"; object[] array = new object[5]; array[0] = ehfDomainItemVersion.DistinguishedName; array[1] = ehfDomainItemVersion.Name; array[2] = domainGuid; object[] array2 = array; int num2 = 3; Guid? domainGuid2 = domainResponseInfo.DomainGuid; array2[num2] = ((domainGuid2 != null) ? domainGuid2.GetValueOrDefault() : "null"); array[4] = ehfDomainItemVersion.Domain.CompanyId; diagSession.LogAndTraceInfo(level, messageFormat, array); } else if (!ehfDomainItemVersion.DomainCreatedWithGuid && domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany) { base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "A domain collision is detected for domain: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-Company-ID=<{3}>. Trying to create the domain as OutboundOnly domain.", new object[] { ehfDomainItemVersion.DistinguishedName, ehfDomainItemVersion.Name, domainGuid, ehfDomainItemVersion.Domain.CompanyId }); list2.Add(ehfDomainItemVersion); } else { base.HandleFailedDomain("Create Domain", ehfDomainItemVersion, domainResponseInfo, ref num, ref permanentFailureCount); } } else if (domainResponseInfo.Fault.Id == FaultId.DomainGuidIsNotUnique && !ehfDomainItemVersion.TriedToUpdateDomain) { list.Add(ehfDomainItemVersion); } else { base.HandleFailedDomain("Create Domain", ehfDomainItemVersion, domainResponseInfo, ref num, ref permanentFailureCount); } if (!ehfDomainItemVersion.EventLogAndTryStoreSyncErrors(base.ADAdapter)) { num++; } } base.HandlePerEntryFailureCounts("Create Domain", domainsTriedToCreate.Count, num, permanentFailureCount, false); foreach (EhfDomainItemVersion2 domain in list) { this.AddDomainToUpdateBatch(domain); } foreach (EhfDomainItemVersion2 domain2 in list2) { this.AddDomainToCreateWithGuidBatch(domain2); } }
protected virtual void HandleCreateDomainResponse(DomainResponseInfoSet responseSet, List <EhfDomainItem> domainsTriedToCreate) { int num = 0; int permanentFailureCount = 0; for (int i = 0; i < responseSet.ResponseInfo.Length; i++) { DomainResponseInfo domainResponseInfo = responseSet.ResponseInfo[i]; EhfDomainItem ehfDomainItem = domainsTriedToCreate[i]; bool flag = false; if (domainResponseInfo.Status == ResponseStatus.Success) { flag = true; base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Successfully created EHF domain: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItem.DistinguishedName, ehfDomainItem.Domain.Name, domainResponseInfo.DomainGuid.Value, ehfDomainItem.Domain.CompanyId }); } else if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany || domainResponseInfo.Fault.Id == FaultId.DomainExistOutsideThisCompany) { Guid domainGuid = ehfDomainItem.GetDomainGuid(); if (domainResponseInfo.Fault.Id == FaultId.DomainExistUnderThisCompany && domainResponseInfo.DomainGuid.Value.Equals(domainGuid)) { flag = true; base.DiagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "Attempted to create a domain that already exists: DN=<{0}>; Name=<{1}>; GUID=<{2}>; EHF-Company-ID=<{3}>", new object[] { ehfDomainItem.DistinguishedName, ehfDomainItem.Domain.Name, domainGuid, ehfDomainItem.Domain.CompanyId }); } else if (!this.handledAllDeletedDomains) { base.AddItemToLazyList <EhfDomainItem>(ehfDomainItem, ref this.domainsToCreateLast); EdgeSyncDiag diagSession = base.DiagSession; EdgeSyncLoggingLevel level = EdgeSyncLoggingLevel.Low; string messageFormat = "Attempted to create a domain with the name that already exists but a different GUID: DN=<{0}>; Name=<{1}>; AD-GUID=<{2}>; EHF-GUID=<{3}>; EHF-Company-ID=<{4}>"; object[] array = new object[5]; array[0] = ehfDomainItem.DistinguishedName; array[1] = ehfDomainItem.Name; array[2] = domainGuid; object[] array2 = array; int num2 = 3; Guid? domainGuid2 = domainResponseInfo.DomainGuid; array2[num2] = ((domainGuid2 != null) ? domainGuid2.GetValueOrDefault() : "null"); array[4] = ehfDomainItem.Domain.CompanyId; diagSession.LogAndTraceInfo(level, messageFormat, array); } else { this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount); } } else { this.HandleFailedDomain("Create Domain", ehfDomainItem, domainResponseInfo, ref num, ref permanentFailureCount); } if (flag && ehfDomainItem.TryClearForceDomainSyncFlagFromPerimeterConfig(base.ADAdapter) == EhfADResultCode.Failure) { num++; } if (!ehfDomainItem.EventLogAndTryStoreSyncErrors(base.ADAdapter)) { num++; } } base.HandlePerEntryFailureCounts("Create Domain", domainsTriedToCreate.Count, num, permanentFailureCount, false); }
private bool CanLogEvent(EdgeSyncLoggingLevel loggingLevel) { return(this.edgeSyncLog.Enabled && this.loggingLevel >= loggingLevel); }
public EdgeSyncLogSession OpenSession(string sessionId, string remoteServerFqdn, int remotePort, string localServerFqdn, EdgeSyncLoggingLevel loggingLevel) { LogRowFormatter logRowFormatter = new LogRowFormatter(this.schema); logRowFormatter[1] = sessionId; logRowFormatter[4] = remoteServerFqdn; logRowFormatter[5] = remotePort; logRowFormatter[3] = localServerFqdn; return(new EdgeSyncLogSession(this, logRowFormatter, loggingLevel)); }