private IConfigurable ReadImpl <T>(ObjectId id) where T : IConfigurable, new()
        {
            if (typeof(T) == typeof(ExchangeConfigurationUnit))
            {
                FfoTenant ffoTenant = base.ReadAndHandleException <FfoTenant>(base.AddTenantIdFilter(null));
                return(FfoConfigurationSession.GetExchangeConfigurationUnit(ffoTenant));
            }
            if (typeof(T) == typeof(ADOrganizationalUnit))
            {
                FfoTenant ffoTenant2 = base.ReadAndHandleException <FfoTenant>(base.AddTenantIdFilter(null));
                return(FfoConfigurationSession.GetADOrganizationalUnit(ffoTenant2));
            }
            if (typeof(T) == typeof(Organization))
            {
                FfoTenant ffoTenant3 = base.ReadAndHandleException <FfoTenant>(base.AddTenantIdFilter(null));
                return(FfoConfigurationSession.GetOrganization(ffoTenant3));
            }
            T        t        = base.ReadAndHandleException <T>(base.AddTenantIdFilter(new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, id)));
            ADObject adobject = t as ADObject;

            if (adobject != null)
            {
                FfoDirectorySession.FixDistinguishedName(adobject, base.TenantId.DistinguishedName, base.TenantId.ObjectGuid, ((ADObjectId)adobject.Identity).ObjectGuid, null);
            }
            return(t);
        }
 private static void SetTenantIds(FfoTenant ffoTenant, ADObject adTenantObject)
 {
     if (ffoTenant == null)
     {
         return;
     }
     adTenantObject.Name = ffoTenant.TenantName;
     FfoDirectorySession.FixDistinguishedName(adTenantObject, DalHelper.GetTenantDistinguishedName(ffoTenant.TenantName), ffoTenant.TenantId.ObjectGuid, ffoTenant.TenantId.ObjectGuid, null);
 }
        protected static Organization GetOrganization(FfoTenant ffoTenant)
        {
            if (ffoTenant == null)
            {
                return(null);
            }
            Organization organization = new Organization();

            FfoConfigurationSession.SetTenantIds(ffoTenant, organization);
            return(organization);
        }
        protected static ADOrganizationalUnit GetADOrganizationalUnit(FfoTenant ffoTenant)
        {
            if (ffoTenant == null)
            {
                return(null);
            }
            ADOrganizationalUnit adorganizationalUnit = new ADOrganizationalUnit();

            FfoConfigurationSession.SetTenantIds(ffoTenant, adorganizationalUnit);
            return(adorganizationalUnit);
        }
Exemplo n.º 5
0
        ExchangeConfigurationUnit ITenantConfigurationSession.GetExchangeConfigurationUnitByName(string organizationName)
        {
            ComparisonFilter filter    = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, organizationName);
            FfoTenant        ffoTenant = (FfoTenant)base.DataProvider.Find <FfoTenant>(filter, null, false, null).FirstOrDefault <IConfigurable>();

            if (ffoTenant == null)
            {
                return(null);
            }
            return(FfoConfigurationSession.GetExchangeConfigurationUnit(ffoTenant));
        }
        internal static ExchangeConfigurationUnit GetExchangeConfigurationUnit(FfoTenant ffoTenant)
        {
            if (ffoTenant == null)
            {
                return(null);
            }
            ExchangeConfigurationUnit exchangeConfigurationUnit = new ExchangeConfigurationUnit();

            FfoConfigurationSession.SetTenantIds(ffoTenant, exchangeConfigurationUnit);
            exchangeConfigurationUnit.ExternalDirectoryOrganizationId = ffoTenant.TenantId.ObjectGuid.ToString();
            exchangeConfigurationUnit.CompanyTags            = ffoTenant.CompanyTags;
            exchangeConfigurationUnit.DirSyncServiceInstance = ffoTenant.ServiceInstance;
            return(exchangeConfigurationUnit);
        }
Exemplo n.º 7
0
        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));
        }
Exemplo n.º 8
0
        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);
        }