示例#1
0
        private static bool TryGetOURootFromDN(string dn, out string tenantOU, out bool isOrgChange)
        {
            tenantOU    = string.Empty;
            isOrgChange = false;
            ADObjectId adobjectId = new ADObjectId(dn);
            int        num        = adobjectId.Depth - adobjectId.DomainId.Depth;

            if (num < EhfAdminAccountSynchronizer.OrganizationUnitDepth)
            {
                return(false);
            }
            ADObjectId adobjectId2;

            if (num == EhfAdminAccountSynchronizer.OrganizationUnitDepth)
            {
                adobjectId2 = adobjectId;
                isOrgChange = true;
            }
            else
            {
                adobjectId2 = adobjectId.AncestorDN(num - EhfAdminAccountSynchronizer.OrganizationUnitDepth);
            }
            if (!EhfAdminAccountSynchronizer.IsOrganizationUnitDN(adobjectId2))
            {
                return(false);
            }
            tenantOU = adobjectId2.DistinguishedName;
            return(true);
        }
        public OrganizationConfigurationTree(DirectoryObjectCollection data)
        {
            if (data == null || data.Count == 0)
            {
                throw new ArgumentNullException("data");
            }
            ADObjectId adobjectId = new ADObjectId(data.ElementAt(0).Properties["distinguishedname"][0].ToString());

            this.Root = new Node(adobjectId.AncestorDN(adobjectId.Depth).ToDNString());
            foreach (DirectoryObject adObject in data)
            {
                this.AddLeaf(this.Root, adObject);
            }
        }
        private MserveTargetConnection.TenantSyncControl GetTenantSyncControlAndUpdateCache(ADObjectId tenantCUId)
        {
            string unescapedName = tenantCUId.AncestorDN(1).Rdn.UnescapedName;

            MserveTargetConnection.TenantSyncControl tenantSyncControl = null;
            bool flag = false;

            if (!MserveTargetConnection.tenantSyncControlCache.TryGetValue(unescapedName, out tenantSyncControl, out flag) || flag)
            {
                tenantSyncControl = this.GetTenantSyncControlSettingFromAD(tenantCUId, unescapedName);
                MserveTargetConnection.tenantSyncControlCache.TryAdd(unescapedName, tenantSyncControl);
            }
            return(tenantSyncControl);
        }
示例#4
0
        protected override void InternalProcessRecord()
        {
            if (this.Identity == null)
            {
                throw new ArgumentNullException("Identity");
            }
            TaskLogger.LogEnter();
            LocalizedString?localizedString;
            IEnumerable <ExchangeConfigurationUnit> dataObjects = base.GetDataObjects <ExchangeConfigurationUnit>(this.Identity, base.DataSession, this.RootId, base.OptionalIdentityData, out localizedString);
            OrganizationId organizationId = null;

            using (IEnumerator <ExchangeConfigurationUnit> enumerator = dataObjects.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    ExchangeConfigurationUnit exchangeConfigurationUnit = enumerator.Current;
                    organizationId = exchangeConfigurationUnit.OrganizationId;
                    string originatingServer = exchangeConfigurationUnit.OriginatingServer;
                }
            }
            if (!base.HasErrors && organizationId == null)
            {
                base.WriteError(new ManagementObjectNotFoundException(localizedString ?? base.GetErrorMessageObjectNotFound(this.Identity.ToString(), typeof(ExchangeConfigurationUnit).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, null);
            }
            this.directoryInfo = new DirectoryBindingInfo();
            string name = organizationId.ConfigurationUnit.ToString();
            string distinguishedName = organizationId.OrganizationalUnit.DistinguishedName;
            DirectoryObjectCollection orgUnit;

            using (SearchResultCollection subtree = this.GetSubtree(distinguishedName))
            {
                orgUnit = new DirectoryObjectCollection(distinguishedName, subtree);
            }
            string     text       = organizationId.ConfigurationUnit.DistinguishedName;
            ADObjectId adobjectId = new ADObjectId(text);

            text = adobjectId.AncestorDN(1).ToDNString();
            DirectoryObjectCollection configUnit;

            using (SearchResultCollection subtree2 = this.GetSubtree(text))
            {
                configUnit = new DirectoryObjectCollection(text, subtree2);
            }
            this.WriteResult(new OrganizationData(name, orgUnit, configUnit, base.RootOrgContainerId.ToString(), ADSession.GetDomainNamingContextForLocalForest().ToString(), this.site.Name));
            TaskLogger.LogExit();
        }
示例#5
0
        internal static object ServerGetter(IPropertyBag propertyBag)
        {
            object result;

            try
            {
                ADObjectId adobjectId = (ADObjectId)propertyBag[ADObjectSchema.Id];
                if (adobjectId == null && (ObjectState)propertyBag[ADObjectSchema.ObjectState] != ObjectState.New)
                {
                    throw new InvalidOperationException(DirectoryStrings.IdIsNotSet);
                }
                result = ((adobjectId == null) ? null : adobjectId.AncestorDN(3));
            }
            catch (InvalidOperationException ex)
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("Server", ex.Message), ADVirtualDirectorySchema.Server, propertyBag[ADObjectSchema.Id]), ex);
            }
            return(result);
        }
示例#6
0
        private void InitializeIdentity(EdgeSyncEhfConnector connector)
        {
            ADObjectId id = connector.Id;

            if (id.Depth > 2)
            {
                string name = id.AncestorDN(2).Name;
                this.identity = string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", new object[]
                {
                    name,
                    connector.Name
                });
            }
            else
            {
                this.identity = id.DistinguishedName;
            }
            EhfSynchronizationProvider.tracer.TraceDebug <string, string>((long)this.GetHashCode(), "Initialized provider identity to <{0}> based on the connector DN <{1}>", this.identity, id.DistinguishedName);
        }
示例#7
0
        internal static object InternalGetter(IPropertyBag propertyBag)
        {
            object result;

            try
            {
                ADObjectId adobjectId = (ADObjectId)propertyBag[ADObjectSchema.Id];
                if (adobjectId == null)
                {
                    throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("Internal", DirectoryStrings.CannotGetDnAtDepth(null, 0)), SystemMessageSchema.Internal, propertyBag[ADObjectSchema.Id]));
                }
                string escapedName = adobjectId.AncestorDN(1).Rdn.EscapedName;
                result = !escapedName.Equals("external", StringComparison.OrdinalIgnoreCase);
            }
            catch (InvalidOperationException ex)
            {
                throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CannotCalculateProperty("Internal", ex.Message), SystemMessageSchema.Internal, propertyBag[ADObjectSchema.Id]), ex);
            }
            return(result);
        }
示例#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);
        }
示例#9
0
        internal static object SiteGetter(IPropertyBag propertyBag)
        {
            ADObjectId adobjectId = (ADObjectId)propertyBag[RootDseSchema.NtDsDsa];

            return(adobjectId.AncestorDN(3));
        }
示例#10
0
 internal static bool IsForefrontObject(ADObjectId id)
 {
     return(DatacenterRegistry.IsForefrontForOffice() && id.Depth >= 3 && string.Equals(id.AncestorDN(id.Depth - 3).Name, "FFO", StringComparison.OrdinalIgnoreCase) && string.Equals(id.AncestorDN(id.Depth - 2).Name, "EXTEST", StringComparison.OrdinalIgnoreCase) && string.Equals(id.AncestorDN(id.Depth - 1).Name, "MICROSOFT", StringComparison.OrdinalIgnoreCase) && string.Equals(id.AncestorDN(id.Depth).Name, "COM", StringComparison.OrdinalIgnoreCase));
 }
示例#11
0
        internal static string GetServerNameFromVDirObjectId(ADObjectId vDirObjectId)
        {
            ADObjectId adobjectId = vDirObjectId.AncestorDN(3);

            return(adobjectId.Name);
        }