internal override ADSessionSettings FromAllTenantsOrRootOrgAutoDetect(ADObjectId id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (id.DomainId == null)
            {
                ExTraceGlobals.GetConnectionTracer.TraceDebug <string>(0L, "FromAllTenantsOrRootOrgAutoDetect(): Value '{0}' passed to id parameter doesn't have DomainId initialized, falling back to RootOrg scope set", id.ToString());
                return(ADSessionSettings.FromRootOrgScopeSet());
            }
            PartitionId partitionId = id.GetPartitionId();

            if (!ADAccountPartitionLocator.IsKnownPartition(partitionId))
            {
                ExTraceGlobals.GetConnectionTracer.TraceDebug <string>(0L, "FromAllTenantsOrRootOrgAutoDetect(): Value '{0}' passed to id parameter doesn't match any known partition, falling back to RootOrg scope set", id.ToString());
                return(ADSessionSettings.FromRootOrgScopeSet());
            }
            ExTraceGlobals.GetConnectionTracer.TraceDebug <string, string>(0L, "FromAllTenantsOrRootOrgAutoDetect(): Value '{0}' passed to id parameter matches partition {1}, returning settings bound to that partition", id.ToString(), partitionId.ToString());
            if (ADSession.IsTenantIdentity(id, partitionId.ForestFQDN))
            {
                return(ADSessionSettings.FromAllTenantsObjectId(id));
            }
            if (!TopologyProvider.IsAdamTopology())
            {
                return(ADSessionSettings.FromAccountPartitionRootOrgScopeSet(id.GetPartitionId()));
            }
            return(ADSessionSettings.FromRootOrgScopeSet());
        }
Пример #2
0
        // Token: 0x06000354 RID: 852 RVA: 0x00012094 File Offset: 0x00010294
        private static ADNotificationRequestCookie RegisterChangeNotification <T>(T dummyObject, ADObjectId baseDN, ADNotificationCallback callback, object context) where T : ADConfigurationObject, new()
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (baseDN == null || string.IsNullOrEmpty(baseDN.DistinguishedName))
            {
                throw new ArgumentNullException("baseDN");
            }
            string forestFQDN = baseDN.GetPartitionId().ForestFQDN;

            if (!baseDN.IsDescendantOf(ADSession.GetConfigurationNamingContext(forestFQDN)) && !ADSession.IsTenantIdentity(baseDN, forestFQDN))
            {
                throw new ArgumentException(DirectoryStrings.ExArgumentException("baseDN", baseDN), "baseDN");
            }
            ADNotificationRequest adnotificationRequest = new ADNotificationRequest(typeof(T), dummyObject.MostDerivedObjectClass, baseDN, callback, context);

            ADNotificationListener.RegisterChangeNotification(adnotificationRequest);
            return(new ADNotificationRequestCookie(new ADNotificationRequest[]
            {
                adnotificationRequest
            }));
        }
Пример #3
0
        internal static bool TryVerifyIsWithinScopes(ADRawEntry obj, ADScope readScope, IList <ADScopeCollection> writeScopes, ADScopeCollection exclusiveScopes, IList <ValidationRule> validationRules, bool emptyObjectSessionOnException, ConfigScopes sessionScopeHint, out ADScopeException exception)
        {
            if (readScope == null)
            {
                throw new ArgumentNullException("readScope");
            }
            if (writeScopes == null)
            {
                throw new ArgumentNullException("writeScopes");
            }
            exception = null;
            bool flag;

            if (!ADSession.IsWithinScope(obj, readScope, out flag))
            {
                if (!flag || sessionScopeHint != ConfigScopes.RootOrg || ADSession.IsTenantIdentity(obj.Id, obj.Id.GetPartitionId().ForestFQDN))
                {
                    if (obj is ADObject && emptyObjectSessionOnException)
                    {
                        ((ADObject)obj).m_Session = null;
                    }
                    exception = new ADScopeException(DirectoryStrings.ErrorNotInReadScope(obj.Id.ToString()));
                    return(false);
                }
                ExTraceGlobals.ScopeVerificationTracer.TraceDebug <ADObjectId>(0L, "ADSession::TryVerifyIsWithinScopes Allowing unfilterable object '{0}' in RootOrg-scoped session to bypass filter verification", obj.Id);
            }
            bool flag2 = false;

            if (exclusiveScopes != null)
            {
                foreach (ADScope scope in exclusiveScopes)
                {
                    if (ADSession.IsWithinScope(obj, scope))
                    {
                        flag2 = true;
                        break;
                    }
                }
            }
            foreach (ADScopeCollection adscopeCollection in writeScopes)
            {
                bool flag3 = false;
                foreach (ADScope adscope in adscopeCollection)
                {
                    bool flag4 = false;
                    bool flag5 = false;
                    bool flag6 = false;
                    if (adscope is RbacScope)
                    {
                        RbacScope rbacScope = (RbacScope)adscope;
                        flag4 = rbacScope.Exclusive;
                        flag5 = rbacScope.IsFromEndUserRole;
                        flag6 = (rbacScope.ScopeType == ScopeType.Self);
                    }
                    if (!flag2 && flag4)
                    {
                        ExTraceGlobals.ScopeVerificationTracer.TraceDebug(0L, "ADSession::TryVerifyIsWithinScopes Ignoring scope ScopeRoot '{0}', ScopeFilter '{1}', IsWithinExclusiveScope '{2}', IsExclusive '{3}'", new object[]
                        {
                            (adscope.Root == null) ? "<null>" : adscope.Root.ToDNString(),
                            (adscope.Filter == null) ? "<null>" : adscope.Filter.ToString(),
                            flag2,
                            flag4
                        });
                    }
                    else
                    {
                        ADScope adscope2 = adscope;
                        if (flag2 && !flag4)
                        {
                            if (!flag5)
                            {
                                ExTraceGlobals.ScopeVerificationTracer.TraceDebug(0L, "ADSession::TryVerifyIsWithinScopes Ignoring scope ScopeRoot '{0}', ScopeFilter '{1}', IsWithinExclusiveScope '{2}', IsExclusive '{3}'", new object[]
                                {
                                    (adscope2.Root == null) ? "<null>" : adscope2.Root.ToDNString(),
                                    (adscope2.Filter == null) ? "<null>" : adscope2.Filter.ToString(),
                                    flag2,
                                    flag4
                                });
                                continue;
                            }
                            if (!flag6)
                            {
                                if (((RbacScope)adscope2).SelfFilter == null)
                                {
                                    exception = new ADScopeException(DirectoryStrings.ExArgumentNullException("RbacScope.SelfFilter"));
                                    return(false);
                                }
                                adscope2 = new RbacScope(ScopeType.Self)
                                {
                                    Root   = ((RbacScope)adscope2).SelfRoot,
                                    Filter = ((RbacScope)adscope2).SelfFilter
                                };
                            }
                        }
                        if (ADSession.IsWithinScope(obj, adscope2))
                        {
                            flag3 = true;
                            break;
                        }
                    }
                }
                if (!flag3)
                {
                    if (obj is ADObject && emptyObjectSessionOnException)
                    {
                        ((ADObject)obj).m_Session = null;
                    }
                    exception = new ADScopeException(DirectoryStrings.ErrorNoWriteScope(obj.Id.ToString()));
                    return(false);
                }
            }
            if (validationRules != null)
            {
                RuleValidationException ex = null;
                foreach (ValidationRule validationRule in validationRules)
                {
                    if (!validationRule.TryValidate(obj, out ex))
                    {
                        exception = ex;
                        return(false);
                    }
                }
            }
            return(true);
        }