private bool GetExternalDirectoryOrganizationIdToLog(ADObject instance, out Guid externalDirectoryOrganizationId) { externalDirectoryOrganizationId = Guid.Empty; if (instance != null && instance.OrganizationId != OrganizationId.ForestWideOrgId) { ADOperationResult externalDirectoryOrganizationId2 = SystemConfigurationTasksHelper.GetExternalDirectoryOrganizationId(this.dataSession, instance.OrganizationId, out externalDirectoryOrganizationId); TenantSettingSyncLogGenerator.Instance.AddEventLogOnADException(externalDirectoryOrganizationId2); return(externalDirectoryOrganizationId2.Succeeded && externalDirectoryOrganizationId != Guid.Empty); } return(false); }
private static void FixTenantId(IConfigurable instance) { IPropertyBag propertyBag = instance as IPropertyBag; OrganizationId organizationId = (OrganizationId)propertyBag[ADObjectSchema.OrganizationId]; if (organizationId == null) { return; } IConfigDataProvider tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(null, true, ConsistencyMode.IgnoreInvalid, null, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(organizationId), 192, "FixTenantId", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\MessageHygiene\\HygieneConfiguration\\FfoDualWriter.cs"); Guid objectGuid; ADOperationResult externalDirectoryOrganizationId = SystemConfigurationTasksHelper.GetExternalDirectoryOrganizationId(tenantOrTopologyConfigurationSession, organizationId, out objectGuid); if (!externalDirectoryOrganizationId.Succeeded) { throw new InvalidOperationException("Error resolving orgId to external org id", externalDirectoryOrganizationId.Exception); } string distinguishedName = FfoDualWriter.FfoRootDN.GetChildId(organizationId.OrganizationalUnit.Name).GetChildId(objectGuid.ToString()).DistinguishedName; propertyBag[ADObjectSchema.OrganizationalUnitRoot] = new ADObjectId(distinguishedName, objectGuid); }