Beispiel #1
0
        public ADRawEntry[] GetPropertyBags(int rowCount)
        {
            if (rowCount < 0)
            {
                throw new ArgumentOutOfRangeException("rowCount");
            }
            if (rowCount == 0)
            {
                return(Array <ADRawEntry> .Empty);
            }
            if (this.rowsToPrefetch < rowCount)
            {
                this.vlvRequestControl.AfterCount = rowCount;
                try
                {
                    this.results = this.GetNextResultCollection();
                }
                finally
                {
                    this.vlvRequestControl.AfterCount = this.rowsToPrefetch;
                }
            }
            if (this.results == null)
            {
                return(Array <ADRawEntry> .Empty);
            }
            int num = Math.Min(rowCount, this.results.Length);

            ADRawEntry[] array = new ADRawEntry[num];
            Array.Copy(this.results, array, num);
            return(array);
        }
        protected void CacheUpdateFromSavedObject(IConfigurable instance, ObjectState objectStateBeforeSave)
        {
            ADRawEntry adrawEntry = instance as ADRawEntry;
            bool       flag       = Configuration.IsCacheEnabledForInsertOnSave(adrawEntry);

            ExTraceGlobals.SessionTracer.TraceDebug((long)this.GetHashCode(), "UpdateOrRemoveFromCache. Identity={0}, ObjectStateBeforeSave={1}, DistinguishedName={2}, WhenCreatedUtc={3}, InsertInCache={4}", new object[]
            {
                instance.Identity,
                objectStateBeforeSave,
                (adrawEntry != null) ? adrawEntry.GetDistinguishedNameOrName() : "<NULL>",
                (adrawEntry != null) ? adrawEntry[ADObjectSchema.WhenCreatedUTC] : "<NULL>",
                flag
            });
            if (!flag)
            {
                if (objectStateBeforeSave != ObjectState.New)
                {
                    this.CacheDelete(instance);
                }
                return;
            }
            IEnumerable <PropertyDefinition> objectProperties = null;

            if (!(adrawEntry is ADObject))
            {
                objectProperties = new List <PropertyDefinition>(0);
            }
            this.CacheInsert <ADRawEntry>(adrawEntry, null, objectProperties);
        }
 private TResult[] GetUniqueResults(TResult[] results)
 {
     TResult[] result;
     if (this.pagesReturned == 0)
     {
         if (this.retrievedAllData == null || !this.retrievedAllData.Value)
         {
             this.idHashSet = new HashSet <Guid>(this.pageSize);
             foreach (TResult tresult in results)
             {
                 ADRawEntry adrawEntry = (ADRawEntry)((object)tresult);
                 this.idHashSet.Add(adrawEntry.Id.ObjectGuid);
             }
         }
         result = results;
     }
     else
     {
         List <TResult> list = new List <TResult>(results.Length);
         foreach (TResult tresult2 in results)
         {
             ADRawEntry adrawEntry2 = (ADRawEntry)((object)tresult2);
             if (this.idHashSet.TryAdd(adrawEntry2.Id.ObjectGuid))
             {
                 list.Add(tresult2);
             }
             else
             {
                 ExTraceGlobals.ADReadTracer.TraceError <int, string>((long)this.GetHashCode(), "Warning: Removing non-unique object from result set on {0}th page: {1}", this.pagesReturned + 1, adrawEntry2.Id.DistinguishedName);
             }
         }
         result = list.ToArray();
     }
     return(result);
 }
        // Token: 0x060000DD RID: 221 RVA: 0x00004974 File Offset: 0x00002B74
        protected ADRawEntry CreateAndInitializeADRawEntry(PropertyBag propertyBag)
        {
            ADRawEntry adrawEntry = new ADRawEntry((ADPropertyBag)propertyBag);

            adrawEntry.ResetChangeTracking(true);
            return(adrawEntry);
        }
Beispiel #5
0
        public static void VerifyIsWithinScopes(ADRawEntry obj, ADScope readScope, IList <ADScopeCollection> writeScopes, ADScopeCollection invalidScopes, bool emptyObjectSessionOnException)
        {
            ADScopeException ex;

            if (!ADSession.TryVerifyIsWithinScopes(obj, readScope, writeScopes, invalidScopes, emptyObjectSessionOnException, out ex))
            {
                throw ex;
            }
        }
Beispiel #6
0
        internal static ADObjectId ResolveADObjectIdWithoutCache(ADObjectId obj)
        {
            IDirectorySession sessionForPartition = ADObjectIdResolutionHelper.GetSessionForPartition(obj.PartitionFQDN);
            ADRawEntry        adrawEntry          = sessionForPartition.ReadADRawEntry(obj, ADObjectIdResolutionHelper.propertiesToRetrieve);

            if (adrawEntry != null)
            {
                return(adrawEntry.Id);
            }
            return(obj);
        }
        public static ADRawEntry FindUserBySid(SecurityIdentifier sId, IList <PropertyDefinition> properties, ref IRecipientSession recipientSession)
        {
            ADRawEntry adrawEntry = null;

            foreach (PartitionId partitionId in ADAccountPartitionLocator.GetAllAccountPartitionIds())
            {
                ITenantRecipientSession tenantRecipientSession = DirectorySessionFactory.Default.CreateTenantRecipientSession(true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromAllTenantsPartitionId(partitionId), 286, "FindUserBySid", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\PartitionDataAggregator.cs");
                adrawEntry = tenantRecipientSession.FindUserBySid(sId, properties);
                if (adrawEntry != null)
                {
                    recipientSession = tenantRecipientSession;
                    break;
                }
            }
            return(adrawEntry);
        }
        private void CacheDeleteInternal(IConfigurable instance)
        {
            string    error     = null;
            Stopwatch stopwatch = Stopwatch.StartNew();

            CachePerformanceTracker.StartLogging();
            bool   isNewProxyObject = false;
            int    retryCount       = 0;
            string callerInfo       = null;
            Guid   activityId       = Guid.Empty;

            try
            {
                TSession tsession = this.GetCacheSession();
                tsession.Delete(instance);
                CacheDirectorySession cacheDirectorySession = this.GetCacheSession() as CacheDirectorySession;
                if (cacheDirectorySession != null)
                {
                    isNewProxyObject = cacheDirectorySession.IsNewProxyObject;
                    retryCount       = cacheDirectorySession.RetryCount;
                }
                TSession session = this.GetSession();
                if (session.ActivityScope != null)
                {
                    TSession session2 = this.GetSession();
                    if (session2.ActivityScope.Status == ActivityContextStatus.ActivityStarted)
                    {
                        TSession session3 = this.GetSession();
                        activityId = session3.ActivityScope.ActivityId;
                    }
                }
                TSession session4 = this.GetSession();
                callerInfo = session4.CallerInfo;
            }
            catch (Exception ex)
            {
                error = ex.ToString();
                throw;
            }
            finally
            {
                stopwatch.Stop();
                string     cachePerformanceTracker = CachePerformanceTracker.StopLogging();
                ADRawEntry adrawEntry = instance as ADRawEntry;
                CacheProtocolLog.BeginAppend("Remove", (adrawEntry != null) ? adrawEntry.GetDistinguishedNameOrName() : "<NULL>", DateTime.MinValue, stopwatch.ElapsedMilliseconds, -1L, stopwatch.ElapsedMilliseconds, -1L, -1L, isNewProxyObject, retryCount, instance.GetType().Name, cachePerformanceTracker, activityId, callerInfo, error);
            }
        }
 // Token: 0x06001176 RID: 4470 RVA: 0x00054170 File Offset: 0x00052370
 public static bool ExecutingUserHasRetentionPolicy(ADRawEntry executingUser, OrganizationId orgId)
 {
     if (executingUser[ADUserSchema.RetentionPolicy] != null)
     {
         return(true);
     }
     if (executingUser[ADObjectSchema.OrganizationId] != null && !OrganizationId.ForestWideOrgId.Equals(executingUser[ADObjectSchema.OrganizationId]))
     {
         IConfigurationSession   scopedSession          = SharedConfiguration.CreateScopedToSharedConfigADSession(orgId);
         IList <RetentionPolicy> defaultRetentionPolicy = SharedConfiguration.GetDefaultRetentionPolicy(scopedSession, executingUser, null, 1);
         if (defaultRetentionPolicy != null && defaultRetentionPolicy.Count > 0)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #10
0
 // Token: 0x060006F3 RID: 1779 RVA: 0x00025530 File Offset: 0x00023730
 protected override TResult[] GetNextPage()
 {
     TResult[] nextPage = base.GetNextPage();
     TResult[] array    = nextPage;
     if (nextPage.Length > 0)
     {
         if (this.searchForward)
         {
             int num = 0;
             for (int i = 0; i < nextPage.Length; i++)
             {
                 ADRawEntry adrawEntry = (ADRawEntry)((object)nextPage[i]);
                 if (adrawEntry.Id.ObjectGuid == this.guidOfLastItem)
                 {
                     num = i;
                     break;
                 }
             }
             int num2 = this.includeBookmarkObject ? num : (num + 1);
             if (num2 > 0)
             {
                 array = new TResult[nextPage.Length - num2];
                 for (int j = num2; j < nextPage.Length; j++)
                 {
                     array[j - num2] = nextPage[j];
                 }
             }
             if (array.Length > 0)
             {
                 ADRawEntry adrawEntry2 = (ADRawEntry)((object)array[array.Length - 1]);
                 this.guidOfLastItem = adrawEntry2.Id.ObjectGuid;
             }
         }
         else if (!this.includeBookmarkObject)
         {
             array = new TResult[nextPage.Length - 1];
             for (int k = 0; k < array.Length; k++)
             {
                 array[k] = nextPage[k];
             }
         }
     }
     this.includeBookmarkObject = false;
     return(array);
 }
Beispiel #11
0
        private static OrganizationId FromPartition <T>(T lookupKey, Guid externalDirectoryOrganizationId, string tenantContainerCN, PartitionId partitionId, Func <ITenantConfigurationSession, OrganizationId> GetOrgFromAD, Func <Exception> CreateNotFoundException)
        {
            ADSessionSettings           sessionSettings            = ADSessionSettings.FromAllTenantsPartitionId(partitionId);
            ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 561, "FromPartition", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\OrganizationId.cs");

            if (!string.IsNullOrEmpty(tenantContainerCN))
            {
                OrganizationId organizationId = OrganizationId.FromTenantContainerCN(tenantContainerCN, tenantConfigurationSession);
                organizationId.externalDirectoryOrganizationId = new Guid?(externalDirectoryOrganizationId);
                return(organizationId);
            }
            OrganizationId organizationId2 = GetOrgFromAD(tenantConfigurationSession);

            if (organizationId2 != null)
            {
                ExTraceGlobals.GLSTracer.TraceDebug <OrganizationId, T>(0L, "[OrganizationIdConvertor.FromExternalDirectoryOrganizationId]: Found OrganizationId {0} for {1}", organizationId2, lookupKey);
                Guid value = Guid.Empty;
                if (externalDirectoryOrganizationId == Guid.Empty)
                {
                    ADRawEntry adrawEntry = tenantConfigurationSession.ReadADRawEntry(organizationId2.ConfigurationUnit, new PropertyDefinition[]
                    {
                        ExchangeConfigurationUnitSchema.ExternalDirectoryOrganizationId
                    });
                    if (adrawEntry != null)
                    {
                        Guid.TryParse(adrawEntry[ExchangeConfigurationUnitSchema.ExternalDirectoryOrganizationId].ToString(), out value);
                    }
                }
                else
                {
                    value = externalDirectoryOrganizationId;
                }
                organizationId2.externalDirectoryOrganizationId = new Guid?(value);
                return(organizationId2);
            }
            throw CreateNotFoundException();
        }
        ADScope IDirectorySession.GetReadScope(ADObjectId rootId, ADRawEntry scopeDeterminingObject)
        {
            TSession session = this.GetSession();

            return(session.GetReadScope(rootId, scopeDeterminingObject));
        }
Beispiel #13
0
        // Token: 0x060003B6 RID: 950 RVA: 0x0001573C File Offset: 0x0001393C
        internal static ADObject CreateAndInitializeConfigObject <TConfigObject>(ADPropertyBag propertyBag, ADRawEntry dummyObject, IDirectorySession directorySession) where TConfigObject : IConfigurable, new()
        {
            ArgumentValidator.ThrowIfNull("propertyBag", propertyBag);
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADObjectSchema.ObjectClass];
            ADObject adobject;

            if (dummyObject is MiniTopologyServer)
            {
                adobject = new MiniTopologyServer();
            }
            else if (dummyObject is MiniVirtualDirectory)
            {
                adobject = new MiniVirtualDirectory();
            }
            else if (dummyObject is MiniEmailTransport)
            {
                adobject = new MiniEmailTransport();
            }
            else if (dummyObject is MiniReceiveConnector)
            {
                adobject = new MiniReceiveConnector();
            }
            else if (multiValuedProperty.Contains(ADWebServicesVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADWebServicesVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADE12UMVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADE12UMVirtualDirectory();
            }
            else if (multiValuedProperty.Contains("msExchMobileVirtualDirectory"))
            {
                adobject = new ADMobileVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADOwaVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADOwaVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADRpcHttpVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADRpcHttpVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADMapiVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADMapiVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADAvailabilityForeignConnectorVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADAvailabilityForeignConnectorVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADOabVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADOabVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADEcpVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADEcpVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(Pop3AdConfiguration.MostDerivedClass))
            {
                adobject = new Pop3AdConfiguration();
            }
            else if (multiValuedProperty.Contains(Imap4AdConfiguration.MostDerivedClass))
            {
                adobject = new Imap4AdConfiguration();
            }
            else if (multiValuedProperty.Contains("mailGateway"))
            {
                if (multiValuedProperty.Contains(SmtpSendConnectorConfig.MostDerivedClass))
                {
                    adobject = new SmtpSendConnectorConfig();
                }
                else if (multiValuedProperty.Contains(DeliveryAgentConnector.MostDerivedClass))
                {
                    adobject = new DeliveryAgentConnector();
                }
                else if (propertyBag.Contains(ForeignConnectorSchema.DropDirectory))
                {
                    adobject = new ForeignConnector();
                }
                else
                {
                    adobject = new LegacyGatewayConnector();
                }
            }
            else if (multiValuedProperty.Contains("msExchEdgeSyncEhfConnector"))
            {
                adobject = new EdgeSyncEhfConnector();
            }
            else
            {
                if (!multiValuedProperty.Contains("msExchEdgeSyncMservConnector"))
                {
                    return(ADObjectFactory.CreateAndInitializeObject <TConfigObject>(propertyBag, directorySession));
                }
                adobject = new EdgeSyncMservConnector();
            }
            adobject.m_Session   = directorySession;
            adobject.propertyBag = propertyBag;
            adobject.Initialize();
            adobject.ResetChangeTracking(true);
            if (directorySession != null)
            {
                adobject.SetIsReadOnly(directorySession.ReadOnly);
            }
            return(adobject);
        }
        // Token: 0x06001174 RID: 4468 RVA: 0x000540EC File Offset: 0x000522EC
        public static IList <RetentionPolicy> GetDefaultRetentionPolicy(IConfigurationSession scopedSession, ADRawEntry user, SortBy sortBy, int resultSize)
        {
            bool isArbitrationMailbox = false;

            if (user[OrgPersonPresentationObjectSchema.RecipientTypeDetails] != null && (RecipientTypeDetails)user[OrgPersonPresentationObjectSchema.RecipientTypeDetails] == RecipientTypeDetails.ArbitrationMailbox)
            {
                isArbitrationMailbox = true;
            }
            return(SharedConfiguration.GetDefaultRetentionPolicy(scopedSession, isArbitrationMailbox, sortBy, resultSize));
        }
Beispiel #15
0
 // Token: 0x06000B4A RID: 2890 RVA: 0x00033E84 File Offset: 0x00032084
 internal bool Equals(ADRawEntry left, ADRawEntry right, IEnumerable <PropertyDefinition> properties)
 {
     if (left == null)
     {
         return(null == right);
     }
     if (right == null)
     {
         return(null == left);
     }
     foreach (PropertyDefinition propertyDefinition in properties)
     {
         ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)propertyDefinition;
         if (adpropertyDefinition.LdapDisplayName != null && !adpropertyDefinition.IsCalculated && !adpropertyDefinition.LdapDisplayName.Equals(ADObjectSchema.Id.LdapDisplayName, StringComparison.Ordinal))
         {
             object obj = null;
             left.propertyBag.TryGetField(adpropertyDefinition, ref obj);
             object obj2 = null;
             right.propertyBag.TryGetField(adpropertyDefinition, ref obj2);
             if (obj != null || obj2 != null)
             {
                 if (adpropertyDefinition.IsMultivalued)
                 {
                     if (!this.AreMultivaluedPropertiesEqual(obj, obj2, adpropertyDefinition))
                     {
                         return(false);
                     }
                 }
                 else
                 {
                     if (obj != null && obj2 == null)
                     {
                         return(false);
                     }
                     if (obj == null && obj2 != null)
                     {
                         return(false);
                     }
                     if (adpropertyDefinition.IsBinary)
                     {
                         byte[] left2  = ADValueConvertor.ConvertValueToBinary(obj, adpropertyDefinition.FormatProvider);
                         byte[] right2 = ADValueConvertor.ConvertValueToBinary(obj2, adpropertyDefinition.FormatProvider);
                         if (!ByteArrayComparer.Instance.Equals(left2, right2))
                         {
                             return(false);
                         }
                     }
                     else
                     {
                         string a = ADValueConvertor.ConvertValueToString(obj, adpropertyDefinition.FormatProvider);
                         string b = ADValueConvertor.ConvertValueToString(obj2, adpropertyDefinition.FormatProvider);
                         if (!string.Equals(a, b, StringComparison.Ordinal))
                         {
                             return(false);
                         }
                     }
                 }
             }
         }
     }
     return(true);
 }
Beispiel #16
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);
        }
Beispiel #17
0
        // Token: 0x060003B5 RID: 949 RVA: 0x00015440 File Offset: 0x00013640
        internal static ADObject CreateAndInitializeRecipientObject <TRecipientObject>(ADPropertyBag propertyBag, ADRawEntry dummyObject, IRecipientSession recipientSession) where TRecipientObject : IConfigurable, new()
        {
            ArgumentValidator.ThrowIfNull("propertyBag", propertyBag);
            ArgumentValidator.ThrowIfNull("dummyObject", dummyObject);
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADObjectSchema.ObjectClass];
            ADObject adobject;

            if (dummyObject is OWAMiniRecipient)
            {
                adobject = new OWAMiniRecipient();
            }
            else if (dummyObject is ActiveSyncMiniRecipient)
            {
                adobject = new ActiveSyncMiniRecipient();
            }
            else if (dummyObject is StorageMiniRecipient)
            {
                adobject = new StorageMiniRecipient();
            }
            else if (dummyObject is TransportMiniRecipient)
            {
                adobject = new TransportMiniRecipient();
            }
            else if (dummyObject is LoadBalancingMiniRecipient)
            {
                adobject = new LoadBalancingMiniRecipient();
            }
            else if (dummyObject is MiniRecipientWithTokenGroups)
            {
                adobject = new MiniRecipientWithTokenGroups();
            }
            else if (dummyObject is FrontEndMiniRecipient)
            {
                adobject = new FrontEndMiniRecipient();
            }
            else if (dummyObject is MiniRecipient)
            {
                adobject = new MiniRecipient();
            }
            else if (dummyObject is RemovedMailbox)
            {
                adobject = new RemovedMailbox();
            }
            else if (dummyObject is DeletedRecipient)
            {
                adobject = new DeletedRecipient();
            }
            else if (multiValuedProperty.Contains(ADComputerRecipient.MostDerivedClass))
            {
                adobject = new ADComputerRecipient();
            }
            else if (multiValuedProperty.Contains(ADUser.MostDerivedClass))
            {
                adobject = new ADUser();
            }
            else if (multiValuedProperty.Contains(ADContact.MostDerivedClass))
            {
                adobject = new ADContact();
            }
            else if (multiValuedProperty.Contains(ADGroup.MostDerivedClass))
            {
                adobject = new ADGroup();
            }
            else if (multiValuedProperty.Contains(ADDynamicGroup.MostDerivedClass))
            {
                adobject = new ADDynamicGroup();
            }
            else if (multiValuedProperty.Contains(ADPublicFolder.MostDerivedClass))
            {
                adobject = new ADPublicFolder();
            }
            else if (multiValuedProperty.Contains(ADSystemAttendantMailbox.MostDerivedClass))
            {
                adobject = new ADSystemAttendantMailbox();
            }
            else if (multiValuedProperty.Contains(ADSystemMailbox.MostDerivedClass))
            {
                adobject = new ADSystemMailbox();
            }
            else if (multiValuedProperty.Contains(ADPublicDatabase.MostDerivedClass))
            {
                adobject = new ADPublicDatabase();
            }
            else
            {
                if (!multiValuedProperty.Contains(ADMicrosoftExchangeRecipient.MostDerivedClass))
                {
                    string objectClass = string.Empty;
                    foreach (string text in multiValuedProperty)
                    {
                        objectClass = text;
                    }
                    ObjectValidationError error = new ObjectValidationError(DirectoryStrings.UnsupportedObjectClass(objectClass), (ADObjectId)propertyBag[ADObjectSchema.Id], string.Empty);
                    ADProviderPerf.UpdateProcessCounter(Counter.ProcessRateCriticalValidationFailures, UpdateType.Update, 1U);
                    Globals.LogEvent(DirectoryEventLogConstants.Tuple_DSC_EVENT_VALIDATION_FAILED_FCO_MODE_RECIPIENT, ((ADObjectId)propertyBag[ADObjectSchema.Id]).ToString(), new object[]
                    {
                        ((ADObjectId)propertyBag[ADObjectSchema.Id]).ToDNString()
                    });
                    throw new DataValidationException(error);
                }
                adobject = new ADMicrosoftExchangeRecipient();
            }
            adobject.m_Session   = recipientSession;
            adobject.propertyBag = propertyBag;
            adobject.Initialize();
            adobject.ResetChangeTracking(true);
            if (recipientSession != null)
            {
                adobject.SetIsReadOnly(recipientSession.ReadOnly);
            }
            ExTraceGlobals.ADReadDetailsTracer.TraceDebug <string, RecipientType>((long)((recipientSession != null) ? recipientSession.GetHashCode() : 0), "ADRecipientObjectSession::CreateObject - Got {0} as {1}", adobject.DistinguishedName, (RecipientType)adobject[ADRecipientSchema.RecipientType]);
            return(adobject);
        }
Beispiel #18
0
        internal static bool IsWithinScope(ADRawEntry obj, ADScope scope)
        {
            bool flag;

            return(ADSession.IsWithinScope(obj, scope, out flag));
        }
Beispiel #19
0
 public static bool TryVerifyIsWithinScopes(ADRawEntry obj, ADScope readScope, IList <ADScopeCollection> writeScopes, ADScopeCollection exclusiveScopes, bool emptyObjectSessionOnException, out ADScopeException exception)
 {
     return(ADSession.TryVerifyIsWithinScopes(obj, readScope, writeScopes, exclusiveScopes, null, emptyObjectSessionOnException, out exception));
 }
        bool IDirectorySession.GetSchemaAndApplyFilter(ADRawEntry adRawEntry, ADScope scope, out ADObject dummyObject, out string[] ldapAttributes, ref QueryFilter filter, ref IEnumerable <PropertyDefinition> properties)
        {
            TSession session = this.GetSession();

            return(session.GetSchemaAndApplyFilter(adRawEntry, scope, out dummyObject, out ldapAttributes, ref filter, ref properties));
        }
        TResult[] IDirectorySession.ObjectsFromEntries <TResult>(SearchResultEntryCollection entries, string originatingServerName, IEnumerable <PropertyDefinition> properties, ADRawEntry dummyInstance)
        {
            TSession session = this.GetSession();

            return(session.ObjectsFromEntries <TResult>(entries, originatingServerName, properties, dummyInstance));
        }
        ADScope IDirectorySession.GetReadScope(ADObjectId rootId, ADRawEntry scopeDeterminingObject, bool isWellKnownGuidSearch, out ConfigScopes applicableScope)
        {
            TSession session = this.GetSession();

            return(session.GetReadScope(rootId, scopeDeterminingObject, isWellKnownGuidSearch, out applicableScope));
        }
 // Token: 0x060000DE RID: 222
 protected abstract ADObject CreateAndInitializeObject <TResult>(ADPropertyBag propertyBag, ADRawEntry dummyInstance) where TResult : IConfigurable, new();
        PooledLdapConnection IDirectorySession.GetReadConnection(string preferredServer, string optionalBaseDN, ref ADObjectId rootId, ADRawEntry scopeDeteriminingObject)
        {
            TSession session = this.GetSession();

            return(session.GetReadConnection(preferredServer, optionalBaseDN, ref rootId, scopeDeteriminingObject));
        }
        private void CacheInsert <TResult>(TResult instance, Func <TResult, List <Tuple <string, KeyType> > > getAdditionalKeys = null, IEnumerable <PropertyDefinition> objectProperties = null) where TResult : IConfigurable, new()
        {
            ArgumentValidator.ThrowIfNull("query", instance);
            Stopwatch stopwatch = Stopwatch.StartNew();

            CachePerformanceTracker.StartLogging();
            bool   isNewProxyObject = false;
            int    retryCount       = 0;
            Guid   activityId       = Guid.Empty;
            string callerInfo       = null;
            string error            = null;

            try
            {
                List <Tuple <string, KeyType> > keys = null;
                TSession session = this.GetSession();
                if (session.ActivityScope != null)
                {
                    TSession session2 = this.GetSession();
                    if (session2.ActivityScope.Status == ActivityContextStatus.ActivityStarted)
                    {
                        TSession session3 = this.GetSession();
                        activityId = session3.ActivityScope.ActivityId;
                    }
                }
                TSession session4 = this.GetSession();
                callerInfo = session4.CallerInfo;
                if (getAdditionalKeys != null)
                {
                    keys = getAdditionalKeys(instance);
                }
                ICacheDirectorySession cacheDirectorySession = this.GetCacheSession() as ICacheDirectorySession;
                bool flag = false;
                if (((IDirectorySession)this).SessionSettings.TenantConsistencyMode == TenantConsistencyMode.IgnoreRetiredTenants && (TenantRelocationStateCache.IsTenantRetired((ADObjectId)instance.Identity) || TenantRelocationStateCache.IsTenantArriving((ADObjectId)instance.Identity)))
                {
                    ExTraceGlobals.SessionTracer.TraceWarning <ObjectId>((long)this.GetHashCode(), "CacheInsert. DN {0}. Tenant Is Retired or Arriving, skipping.", instance.Identity);
                }
                else
                {
                    if (!instance.GetType().Equals(CompositeDirectorySession <TSession> .ExchangeConfigUnitCUType) && (TenantRelocationStateCache.IsTenantLockedDown((ADObjectId)instance.Identity) || TenantRelocationStateCache.IsTenantRetired((ADObjectId)instance.Identity)))
                    {
                        flag = true;
                    }
                    int num = flag ? 30 : Configuration.GetCacheExpirationForObject(instance as ADRawEntry);
                    CacheItemPriority cacheItemPriority = flag ? CacheItemPriority.Default : Configuration.GetCachePriorityForObject(instance as ADRawEntry);
                    if (cacheDirectorySession != null)
                    {
                        cacheDirectorySession.Insert(instance, objectProperties, keys, num, cacheItemPriority);
                    }
                    else
                    {
                        TSession tsession = this.GetCacheSession();
                        tsession.Save(instance);
                    }
                    CacheDirectorySession cacheDirectorySession2 = this.GetCacheSession() as CacheDirectorySession;
                    if (cacheDirectorySession2 != null)
                    {
                        isNewProxyObject = cacheDirectorySession2.IsNewProxyObject;
                        retryCount       = cacheDirectorySession2.RetryCount;
                    }
                    ExTraceGlobals.SessionTracer.TraceDebug((long)this.GetHashCode(), "CacheInsert. DN={0}, IsTenantLockedDownOrRetired={1}, CacheExpiration={2}, Priority={3}", new object[]
                    {
                        instance.Identity,
                        flag,
                        num,
                        cacheItemPriority
                    });
                }
            }
            catch (TransientException ex)
            {
                ExTraceGlobals.SessionTracer.TraceError <ObjectId, TransientException>((long)this.GetHashCode(), "CacheInsert. DN {0}. Exception {1}", instance.Identity, ex);
                error = ex.ToString();
            }
            catch (Exception ex2)
            {
                error = ex2.ToString();
                throw;
            }
            finally
            {
                stopwatch.Stop();
                string     cachePerformanceTracker = CachePerformanceTracker.StopLogging();
                ADRawEntry adrawEntry = instance as ADRawEntry;
                CacheProtocolLog.BeginAppend("Save", (adrawEntry != null) ? adrawEntry.GetDistinguishedNameOrName() : "<NULL>", DateTime.MinValue, stopwatch.ElapsedMilliseconds, -1L, -1L, stopwatch.ElapsedMilliseconds, -1L, isNewProxyObject, retryCount, instance.GetType().Name, cachePerformanceTracker, activityId, callerInfo, error);
            }
        }
Beispiel #26
0
 internal static bool IsWithinScope(ADRawEntry obj, ADScope scope, out bool outOfScopeBecauseOfFilter)
 {
     return(ADDataSession.IsWithinScope(obj, scope, out outOfScopeBecauseOfFilter));
 }