internal override ADSessionSettings FromTenantCUName(string name) { if (name == null) { throw new ArgumentNullException("name"); } GlobalConfigSession globalConfigSession = new GlobalConfigSession(); FfoTenant tenantByName = globalConfigSession.GetTenantByName(name); if (tenantByName == null) { throw new CannotResolveTenantNameException(DirectoryStrings.CannotResolveTenantName(name)); } ExchangeConfigurationUnit exchangeConfigurationUnit = FfoConfigurationSession.GetExchangeConfigurationUnit(tenantByName); return(ADSessionSettings.SessionSettingsFactory.CreateADSessionSettings(ScopeSet.GetOrgWideDefaultScopeSet(OrganizationId.ForestWideOrgId), null, exchangeConfigurationUnit.OrganizationId, null, ConfigScopes.TenantLocal, PartitionId.LocalForest)); }
protected ADObjectId ExtractTenantId(ADObjectId tenantDescendantId) { if (tenantDescendantId == null) { return(null); } int num = DalHelper.FfoRootDN.Depth + 1; FfoTenant ffoTenant = null; if (string.IsNullOrEmpty(tenantDescendantId.DistinguishedName) && tenantDescendantId.ObjectGuid != Guid.Empty) { ffoTenant = this.ReadAndHandleException <FfoTenant>(new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.OrganizationalUnitRoot, new ADObjectId(tenantDescendantId.ObjectGuid))); if (ffoTenant != null) { string tenantDistinguishedName = DalHelper.GetTenantDistinguishedName(ffoTenant.Name); return(new ADObjectId(tenantDistinguishedName, tenantDescendantId.ObjectGuid)); } } if (tenantDescendantId.Depth <= num) { return(tenantDescendantId); } ADObjectId adobjectId = tenantDescendantId.AncestorDN(tenantDescendantId.Depth - num); string name = adobjectId.Name; Guid guid; if (Guid.TryParse(name, out guid)) { ffoTenant = this.ReadAndHandleException <FfoTenant>(new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.OrganizationalUnitRoot, new ADObjectId(guid))); } if (ffoTenant == null && tenantDescendantId.ObjectGuid == Guid.Empty) { GlobalConfigSession globalConfigSession = new GlobalConfigSession(); ffoTenant = globalConfigSession.GetTenantByName(name); } if (ffoTenant == null) { return(tenantDescendantId); } return(ffoTenant.OrganizationalUnitRoot); }