public static bool TryGetExternalDirectoryObjectId(ExSearchResultEntry entry, EdgeSyncDiag diagSession, out Guid externalDirectoryObjectId) { externalDirectoryObjectId = Guid.Empty; DirectoryAttribute attribute = entry.GetAttribute("msExchExternalDirectoryObjectId"); if (attribute == null || attribute.Count == 0) { diagSession.LogAndTraceError("msExchExternalDirectoryObjectId attribute is not set on '{0}'", new object[] { entry.DistinguishedName }); return(false); } string text = (string)attribute[0]; if (!GuidHelper.TryParseGuid(text, out externalDirectoryObjectId)) { diagSession.LogAndTraceError("msExchExternalDirectoryObjectId attribute in '{0}' is set to an invalid Guid '{1}'", new object[] { entry.DistinguishedName, text }); return(false); } return(true); }
public string[] GetWlidsOfGroupMembers(int maxAdmins, EdgeSyncDiag diagSession) { List <string> list = new List <string>(this.groupMembers.Count); foreach (MailboxAdminSyncUser mailboxAdminSyncUser in this.groupMembers.Values) { if (!string.IsNullOrEmpty(mailboxAdminSyncUser.WindowsLiveId)) { if (!EhfWellKnownGroup.ValidateWindowsLiveId(mailboxAdminSyncUser)) { diagSession.LogAndTraceError("WLID <{0}> for user <{1}>:<{2}> is not valid. The admin will be ignored from group <{3}>.", new object[] { mailboxAdminSyncUser.WindowsLiveId, mailboxAdminSyncUser.DistinguishedName, mailboxAdminSyncUser.UserGuid, this.wellknownGroupName }); } else { list.Add(mailboxAdminSyncUser.WindowsLiveId); } if (list.Count == maxAdmins) { diagSession.LogAndTraceError("The group <{0}> has more than the maximum allowed number ({1}) of members. Only the first <{1}> will be taken.", new object[] { this.wellknownGroupName, maxAdmins }); break; } } } return(list.ToArray()); }
private static bool ValidateDomainName(ExSearchResultEntry entry, EdgeSyncDiag diagSession) { DirectoryAttribute attribute = entry.GetAttribute("msExchAcceptedDomainName"); string text = null; if (attribute != null) { text = (string)attribute[0]; } if (string.IsNullOrEmpty(text)) { diagSession.LogAndTraceError("Accepted domain object with DN <{0}> does not contain domain name; ignoring the object", new object[] { entry.DistinguishedName }); return(false); } if (text.StartsWith("*", StringComparison.Ordinal)) { diagSession.LogAndTraceError("Wildcard accepted domain <{0}> with DN <{1}> cannot be sync'd", new object[] { text, entry.DistinguishedName }); return(false); } if (text.Contains("_")) { diagSession.LogAndTraceError("Accepted domain <{0}> with DN <{1}> cannot be sync'd because it contains one or more underscore characters", new object[] { text, entry.DistinguishedName }); return(false); } if (!text.Contains(".")) { diagSession.LogAndTraceError("Accepted domain <{0}> with DN <{1}> cannot be sync'd because it is a top level domain", new object[] { text, entry.DistinguishedName }); return(false); } if (text.Length > 255) { diagSession.LogAndTraceError("Accepted domain name <{0}> with DN <{1}> is too long; ignoring the domain", new object[] { text, entry.DistinguishedName }); return(false); } return(true); }
private static bool TryGetMailFlowConnectorId(ExSearchResultEntry entry, string attribute, EdgeSyncDiag diagSession, out int connectorId) { connectorId = EhfDomainSynchronizerVersion2.InvalidConnectorId; DirectoryAttribute attribute2 = entry.GetAttribute(attribute); if (attribute2 == null) { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.High, "ConnectorId is null or empty for <{0}>:<{1}>", new object[] { attribute, entry.DistinguishedName }); return(false); } string text = (string)attribute2[0]; if (string.IsNullOrEmpty(text)) { return(false); } if (int.TryParse(text, out connectorId)) { return(true); } diagSession.LogAndTraceError("ConnectorId '{0}' is not in the expected format for <{1}>:<{2}>", new object[] { text, attribute, entry.DistinguishedName }); return(false); }
protected void HandleFailedDomain(string operationName, EhfDomainItem domain, DomainResponseInfo response, ref int transientFailureCount, ref int permanentFailureCount) { if (response.Status == ResponseStatus.TransientFailure) { transientFailureCount++; } else { permanentFailureCount++; } string responseTargetValuesString = EhfProvisioningService.GetResponseTargetValuesString(response); EdgeSyncDiag diagSession = base.DiagSession; string messageFormat = "Failed to {0}: FaultId={1}; FaultType={2}; FaultDetail={3}; Target={4}; TargetValues=({5}); DN=({6}); Name={7}; AD-GUID=({8}); EHF-GUID=({9}); EHF-Company-ID={10}"; object[] array = new object[11]; array[0] = operationName; array[1] = response.Fault.Id; array[2] = response.Status; array[3] = (response.Fault.Detail ?? "null"); array[4] = response.Target; array[5] = responseTargetValuesString; array[6] = domain.DistinguishedName; array[7] = domain.Name; array[8] = domain.GetDomainGuid(); object[] array2 = array; int num = 9; Guid? domainGuid = response.DomainGuid; array2[num] = ((domainGuid != null) ? domainGuid.GetValueOrDefault() : "null"); array[10] = domain.Domain.CompanyId; domain.AddSyncError(diagSession.LogAndTraceError(messageFormat, array)); }
private static bool IsPartnerManagedGroup(ExSearchResultEntry searchEntry, EdgeSyncDiag diagSession) { DirectoryAttribute directoryAttribute; if (!searchEntry.Attributes.TryGetValue("msExchCapabilityIdentifiers", out directoryAttribute) || directoryAttribute == null) { return(false); } foreach (object obj in directoryAttribute.GetValues(typeof(string))) { string text = obj as string; if (!string.IsNullOrEmpty(text)) { Capability capability; if (EnumValidator.TryParse <Capability>(text, EnumParseOptions.AllowNumericConstants | EnumParseOptions.IgnoreCase, out capability)) { if (capability == Capability.Partner_Managed) { return(true); } } else { diagSession.LogAndTraceError("Capability value '{0}' is not in the expected format on the object '{1}'", new object[] { text, searchEntry.DistinguishedName }); } } } return(false); }
private void HandleFailedCompany(string operationName, EhfCompanyItem company, CompanyResponseInfo response, ref int transientFailureCount, ref int permanentFailureCount) { if (response.Status == ResponseStatus.TransientFailure) { transientFailureCount++; } else { permanentFailureCount++; } string text = (company.Company != null) ? company.Company.Name : "not available"; string responseTargetValuesString = EhfProvisioningService.GetResponseTargetValuesString(response); EdgeSyncDiag diagSession = base.DiagSession; string messageFormat = "Failed to {0}: FaultId={1}; FaultType={2}; FaultDetail={3}; Target={4}; TargetValues=({5}); DN=({6}); AD-Name={7}; EHF-Name={8}; AD-GUID=({9}); EHF-GUID=({10}); EHF-ID={11}"; object[] array = new object[12]; array[0] = operationName; array[1] = response.Fault.Id; array[2] = response.Status; array[3] = (response.Fault.Detail ?? "null"); array[4] = response.Target; array[5] = responseTargetValuesString; array[6] = company.DistinguishedName; array[7] = text; array[8] = (response.CompanyName ?? "null"); array[9] = company.GetCompanyGuid(); object[] array2 = array; int num = 10; Guid? companyGuid = response.CompanyGuid; array2[num] = ((companyGuid != null) ? companyGuid.GetValueOrDefault() : "null"); array[11] = response.CompanyId; company.AddSyncError(diagSession.LogAndTraceError(messageFormat, array)); }
private static EhfCompanyIdentity GetEhfCompanyIdentity(string configUnitDN, EdgeSyncDiag diagSession, string missingIdAction, ExSearchResultEntry perimeterSettingsEntry) { int companyId; string text; if (!EhfCompanyItem.TryGetEhfCompanyId(perimeterSettingsEntry, diagSession, out companyId, out text)) { if (string.IsNullOrEmpty(text)) { diagSession.LogAndTraceInfo(EdgeSyncLoggingLevel.Low, "EHF company ID is not set for tenant organization with ConfigUnit root DN <{0}>; {1}", new object[] { configUnitDN, missingIdAction }); } else { diagSession.LogAndTraceError("Failure occurred while retrieving EHF company ID for tenant organization with ConfigUnit root DN <{0}>; {1}; failure details: {2}", new object[] { configUnitDN, missingIdAction, text }); } } Guid objectGuid = perimeterSettingsEntry.GetObjectGuid(); return(new EhfCompanyIdentity(companyId, objectGuid)); }
private static bool TryGetOrganizationUnit(ExSearchResultEntry entry, EdgeSyncDiag diagSession, out string exchOURoot) { exchOURoot = string.Empty; DirectoryAttribute directoryAttribute; if (entry.Attributes.TryGetValue("msExchOURoot", out directoryAttribute) && directoryAttribute != null) { exchOURoot = (string)directoryAttribute[0]; return(true); } diagSession.LogAndTraceError("Could not find ExchOURoot for {0}. Every object is expected to contain this attribute.", new object[] { entry.DistinguishedName }); return(false); }
public Guid[] GetLinkedPartnerGroupGuidsOfLinkedRoleGroups(int maxMembers, EdgeSyncDiag diagSession) { if (this.linkedRoleGroups == null) { return(null); } Guid[] array = new Guid[Math.Min(this.linkedRoleGroups.Count, maxMembers)]; int num = 0; foreach (PartnerGroupAdminSyncUser partnerGroupAdminSyncUser in this.linkedRoleGroups.Values) { array[num++] = partnerGroupAdminSyncUser.PartnerGroupGuid; if (num == maxMembers) { diagSession.LogAndTraceError("The group <{0}> has more than the maximum allowed number ({1}) of partner linked role groups. Only the first <{1}> will be taken.", new object[] { this.wellknownGroupName, maxMembers }); break; } } return(array); }
private static bool IsPartnerManagedLinkedRoleGroup(ExSearchResultEntry searchEntry, EdgeSyncDiag diagSession, out Guid groupGuid) { groupGuid = Guid.Empty; if (!EhfCompanyAdmins.IsPartnerManagedGroup(searchEntry, diagSession)) { return(false); } DirectoryAttribute directoryAttribute; if (!searchEntry.Attributes.TryGetValue("msExchPartnerGroupID", out directoryAttribute)) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute is not present in the partner managed group '{0}'", new object[] { searchEntry.DistinguishedName }); return(false); } if (directoryAttribute == null || directoryAttribute.Count == 0) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute is not set on the partner managed group '{0}'", new object[] { searchEntry.DistinguishedName }); return(false); } string text = directoryAttribute[0] as string; if (string.IsNullOrEmpty(text)) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute is empty for the partner managed group '{0}'", new object[] { searchEntry.DistinguishedName }); return(false); } LinkedPartnerGroupInformation linkedPartnerGroupInformation; try { linkedPartnerGroupInformation = LinkedPartnerGroupInformation.Parse(text); } catch (ArgumentException) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute value '{0}' is not in the expected format for '{1}'", new object[] { text, searchEntry.DistinguishedName }); return(false); } if (string.IsNullOrEmpty(linkedPartnerGroupInformation.LinkedPartnerGroupId)) { diagSession.LogAndTraceError("msExchPartnerGroupID attribute value '{0}' has an empty LinkdedPartnetGroupId: '{1}'", new object[] { text, searchEntry.DistinguishedName }); return(false); } if (GuidHelper.TryParseGuid(linkedPartnerGroupInformation.LinkedPartnerGroupId, out groupGuid)) { return(true); } diagSession.LogAndTraceError("msExchPartnerGroupID attribute value '{0}' is not a valid Guid: '{1}'", new object[] { text, searchEntry.DistinguishedName }); return(false); }