private static int GetCountImmediate(IConfigurationSession session, OrganizationId orgId, string systemAddressListName)
        {
            AddressBookBase systemAddressList = SystemAddressListMemberCount.ReadSystemAddressListFromAD(session, orgId, systemAddressListName);
            SystemAddressListMemberCountCacheValue systemAddressListMemberCountCacheValue = new SystemAddressListMemberCountCacheValue(systemAddressList);

            return(systemAddressListMemberCountCacheValue.GetMemberCountImmediate(session));
        }
Пример #2
0
        private IRecipientSession CreateGalScopedRecipientSession(AddressBookBase globalAddressList)
        {
            ADSessionSettings adsessionSettings = ADSessionSettings.FromOrganizationIdWithAddressListScopeServiceOnly(this.organizationId, (globalAddressList != null) ? globalAddressList.Id : null);

            adsessionSettings.AccountingObject = null;
            return(DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, this.searchRoot, this.lcid, true, this.consistencyMode, null, adsessionSettings, 641, "CreateGalScopedRecipientSession", "f:\\15.00.1497\\sources\\dev\\AirSync\\src\\AirSync\\GalSearch\\ADABSession.cs"));
        }
Пример #3
0
 private void CreateCannedSystemAddressLists(IConfigurationSession session, AddressBookBase parent, out Dictionary <string, bool> addressListsCreated)
 {
     addressListsCreated = new Dictionary <string, bool>();
     foreach (string text in CannedSystemAddressLists.RecipientFilters.Keys)
     {
         AddressBookBase addressBookBase = session.Read <AddressBookBase>(parent.Id.GetChildId(text));
         bool            flag            = false;
         bool            flag2           = false;
         if (addressBookBase == null)
         {
             flag            = true;
             addressBookBase = new AddressBookBase();
             addressBookBase.SetId(parent.Id.GetChildId(text));
             addressBookBase.DisplayName         = text;
             addressBookBase.OrganizationId      = parent.OrganizationId;
             addressBookBase.IsSystemAddressList = CannedSystemAddressLists.SystemFlags[text];
         }
         if (flag || !string.Equals(LdapFilterBuilder.LdapFilterFromQueryFilter(CannedSystemAddressLists.RecipientFilters[text]), addressBookBase.LdapRecipientFilter, StringComparison.OrdinalIgnoreCase))
         {
             flag2 = true;
             addressBookBase.SetRecipientFilter(CannedSystemAddressLists.RecipientFilters[text]);
             addressBookBase[AddressBookBaseSchema.RecipientFilterFlags] = RecipientFilterableObjectFlags.FilterApplied;
             base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(addressBookBase, session, typeof(AddressBookBase)));
             try
             {
                 session.Save(addressBookBase);
             }
             finally
             {
                 base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(session));
             }
         }
         addressListsCreated.Add(text, flag || flag2);
     }
 }
Пример #4
0
        internal int GetMemberCountImmediate(IConfigurationSession session)
        {
            int num = 0;

            try
            {
                if (!this.cachedCountLock.TryEnterReadLock(SystemAddressListMemberCountCacheValue.readerLockTimeout))
                {
                    throw new TransientException(DirectoryStrings.ErrorTimeoutReadingSystemAddressListMemberCount);
                }
                if (!this.systemAddressListExists)
                {
                    throw new ADNoSuchObjectException(DirectoryStrings.SystemAddressListDoesNotExist);
                }
                num = AddressBookBase.GetAddressListSize(session, this.systemAddressListGuid);
                if (num == -1)
                {
                    throw new ADNoSuchObjectException(DirectoryStrings.SystemAddressListDoesNotExist);
                }
            }
            finally
            {
                try
                {
                    this.cachedCountLock.ExitReadLock();
                }
                catch (SynchronizationLockException)
                {
                }
            }
            return(num);
        }
        // Token: 0x06001DFA RID: 7674 RVA: 0x000ADA28 File Offset: 0x000ABC28
        private void LoadPagedSearch(int startRange, int itemCount, PropertyDefinition[] properties, bool retry)
        {
            int num = startRange;

            if (!string.IsNullOrEmpty(this.cookie))
            {
                num = startRange - (this.cookieIndex + 1);
            }
            int itemsToSkip = num;

            object[][] array;
            int        num2;

            if (DirectoryAssistance.IsEmptyAddressList(this.userContext))
            {
                array = new object[0][];
                num2  = 0;
            }
            else
            {
                array = AddressBookBase.PagedSearch(DirectoryAssistance.IsVirtualAddressList(this.userContext) ? this.userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN : null, DirectoryAssistance.IsVirtualAddressList(this.userContext) ? null : this.addressBookBase, this.userContext.ExchangePrincipal.MailboxInfo.OrganizationId, AddressBookBase.RecipientCategory.All, this.searchString, itemsToSkip, ref this.cookie, itemCount, out num2, ref this.lcid, ref this.preferredDC, properties);
            }
            if (array.Length > 0)
            {
                base.StartRange  = startRange;
                base.EndRange    = base.StartRange + (array.Length - 1);
                this.cookieIndex = base.EndRange;
                base.Items       = array;
                return;
            }
            if (this.cookie != null && this.cookie.Length != 0 && retry)
            {
                this.cookieIndex = 0;
                this.LoadPagedSearch(0, itemCount, properties, false);
                return;
            }
            if (num2 != 0 && retry)
            {
                if (this.cookieIndex > 0)
                {
                    num2 += this.cookieIndex + 1;
                }
                int num3 = num2 - 1;
                startRange = num3 - (itemCount - 1);
                if (startRange < 0)
                {
                    startRange = 0;
                }
                this.cookie      = null;
                this.cookieIndex = 0;
                this.lcid        = Culture.GetUserCulture().LCID;
                this.LoadPagedSearch(startRange, itemCount, properties, false);
                return;
            }
            base.StartRange  = int.MinValue;
            base.EndRange    = int.MinValue;
            this.cookie      = null;
            this.cookieIndex = 0;
            base.Items       = array;
        }
 // Token: 0x06001DEC RID: 7660 RVA: 0x000AD6F0 File Offset: 0x000AB8F0
 private ADListViewDataSource(Hashtable properties, AddressBookBase addressBookBase, string searchString, string cookie, int cookieIndex, int lcid, string preferredDC, UserContext userContext) : base(properties)
 {
     if (!properties.ContainsKey(ADObjectSchema.ObjectCategory) || !properties.ContainsKey(ADObjectSchema.Guid) || !properties.ContainsKey(ADRecipientSchema.RecipientType) || !properties.ContainsKey(ADRecipientSchema.RecipientDisplayType))
     {
         throw new ArgumentException("The objectCategory, objectGuid, recipientType attributes need to be included in the'properties' parameter of the ADListViewDataSource constructor");
     }
     this.addressBookBase = addressBookBase;
     this.searchString    = searchString;
     this.cookie          = cookie;
     this.cookieIndex     = cookieIndex;
     this.lcid            = lcid;
     this.preferredDC     = preferredDC;
     this.userContext     = userContext;
     if (!string.IsNullOrEmpty(searchString))
     {
         this.search = true;
     }
     try
     {
         userContext.GetCachedADCount(this.ContainerId, this.search ? searchString : string.Empty);
     }
     catch (Exception)
     {
         this.Load(2147483597, 50, true, false);
         userContext.SetCachedADCount(this.ContainerId, this.search ? searchString : string.Empty, (base.EndRange >= 0) ? (base.EndRange + 1) : 0);
     }
 }
        private void RenameAllGroupsAddressListToAllDistributionLists()
        {
            AddressBookBase[] array = this.FindAddressList(CannedAddressListsFilterHelper.DefaultAllDistributionLists, CannedAddressListsFilterHelper.DefaultAllDistributionListsFilter);
            if (array == null || array.Length == 0)
            {
                return;
            }
            AddressBookBase addressBookBase = array[0];
            bool            flag            = false;

            if (string.Equals(addressBookBase.DisplayName, Strings.DefaultAllGroups, StringComparison.CurrentCultureIgnoreCase))
            {
                addressBookBase.DisplayName = Strings.DefaultAllDistributionLists;
                flag = true;
            }
            if (string.Equals(addressBookBase.Name, Strings.DefaultAllGroups, StringComparison.CurrentCultureIgnoreCase))
            {
                addressBookBase.Name = Strings.DefaultAllDistributionLists;
                flag = true;
            }
            if (flag)
            {
                try
                {
                    base.DataSession.Save(addressBookBase);
                }
                finally
                {
                    base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
                }
            }
        }
Пример #8
0
        protected override void InternalValidate()
        {
            this.DataObject = (AddressBookMailboxPolicy)base.PrepareDataObject();
            this.DataObject.SetExchangeVersion(ExchangeObjectVersion.Exchange2010);
            this.DataObject.MinAdminVersion = new int?(this.DataObject.ExchangeVersion.ExchangeBuild.ToExchange2003FormatInt32());
            int maxAddressBookPolicies = this.MaxAddressBookPolicies;

            if (maxAddressBookPolicies < 2147483647)
            {
                IEnumerable <AddressBookMailboxPolicy> enumerable = base.DataSession.FindPaged <AddressBookMailboxPolicy>(null, ((IConfigurationSession)base.DataSession).GetOrgContainerId().GetDescendantId(this.DataObject.ParentPath), false, null, ADGenericPagedReader <AddressBookMailboxPolicy> .DefaultPageSize);
                int num = 0;
                foreach (AddressBookMailboxPolicy addressBookMailboxPolicy in enumerable)
                {
                    num++;
                    if (num >= maxAddressBookPolicies)
                    {
                        base.WriteError(new ManagementObjectAlreadyExistsException(Strings.ErrorTooManyItems(maxAddressBookPolicies)), ErrorCategory.LimitsExceeded, base.Name);
                        break;
                    }
                }
            }
            this.DataObject.AddressLists = AddressBookPolicyTaskUtility.ValidateAddressBook(base.DataSession, this.AddressLists, new AddressBookPolicyTaskUtility.GetUniqueObject(base.GetDataObject <AddressBookBase>), this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
            AddressBookBase addressBookBase = (AddressBookBase)base.GetDataObject <AddressBookBase>(this.GlobalAddressList, base.DataSession, null, new LocalizedString?(Strings.ErrorAddressListOrGlobalAddressListNotFound(this.GlobalAddressList.ToString())), new LocalizedString?(Strings.ErrorAddressListOrGlobalAddressListNotUnique(this.GlobalAddressList.ToString())));

            if (addressBookBase != null && addressBookBase.IsGlobalAddressList)
            {
                this.DataObject.GlobalAddressList = (ADObjectId)addressBookBase.Identity;
            }
            else
            {
                base.WriteError(new ArgumentException(Strings.ErrorGlobalAddressListNotFound(this.GlobalAddressList.ToString())), ErrorCategory.InvalidArgument, base.Name);
                this.DataObject.GlobalAddressList = null;
            }
            AddressBookBase addressBookBase2 = (AddressBookBase)base.GetDataObject <AddressBookBase>(this.RoomList, base.DataSession, null, new LocalizedString?(Strings.ErrorAllRoomListNotFound(this.RoomList.ToString())), new LocalizedString?(Strings.ErrorAllRoomListNotUnique(this.RoomList.ToString())));

            if (addressBookBase2 != null)
            {
                this.DataObject.RoomList = (ADObjectId)addressBookBase2.Identity;
            }
            else
            {
                base.WriteError(new ArgumentException(Strings.ErrorAllRoomListNotFound(this.RoomList.ToString())), ErrorCategory.InvalidArgument, base.Name);
                this.DataObject.RoomList = null;
            }
            OfflineAddressBook offlineAddressBook = (OfflineAddressBook)base.GetDataObject <OfflineAddressBook>(this.OfflineAddressBook, base.DataSession, null, new LocalizedString?(Strings.ErrorOfflineAddressBookNotFound(this.OfflineAddressBook.ToString())), new LocalizedString?(Strings.ErrorOfflineAddressBookNotUnique(this.OfflineAddressBook.ToString())));

            if (offlineAddressBook != null)
            {
                this.DataObject.OfflineAddressBook = (ADObjectId)offlineAddressBook.Identity;
            }
            else
            {
                base.WriteError(new ArgumentException(Strings.ErrorOfflineAddressBookNotFound(this.OfflineAddressBook.ToString())), ErrorCategory.InvalidArgument, base.Name);
                this.DataObject.OfflineAddressBook = null;
            }
            ReadOnlyCollection <PropertyDefinition> allProperties = this.DataObject.Schema.AllProperties;

            base.InternalValidate();
        }
Пример #9
0
 internal static GlobalAddressList FromDataObject(AddressBookBase dataObject)
 {
     if (dataObject == null)
     {
         return(null);
     }
     return(new GlobalAddressList(dataObject));
 }
Пример #10
0
        public virtual AddressBookBase ToAddressBookBase()
        {
            AddressBookBase addressBookBase = new AddressBookBase();

            addressBookBase.SetId(this.Id);
            addressBookBase.DisplayName    = this.DisplayName;
            addressBookBase.OrganizationId = this.OrganizationId;
            return(addressBookBase);
        }
Пример #11
0
 internal AddressListInfo(AddressBookBase addressList)
 {
     if (addressList == null)
     {
         throw new ArgumentNullException("addressList");
     }
     this.DisplayName    = addressList.DisplayName;
     this.Id             = addressList.Id;
     this.organizationId = addressList.OrganizationId;
 }
        public override void LoadData(int startRange, int endRange)
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "ADDataSource.LoadData(Start)");
            int    lcid        = Culture.GetUserCulture().LCID;
            string preferredDC = this.userContext.PreferredDC;

            ExTraceGlobals.MailCallTracer.TraceDebug <string>((long)this.GetHashCode(), "AddressBookDataSource.LoadData: preferred DC in user context = '{0}'", preferredDC);
            if (startRange < 1)
            {
                throw new ArgumentOutOfRangeException("startRange", "startRange must be greater than 0");
            }
            if (endRange < startRange)
            {
                throw new ArgumentOutOfRangeException("endRange", "endRange must be greater than or equal to startRange");
            }
            PropertyDefinition[] properties = base.CreateProperyTable();
            int    num         = endRange - startRange + 1;
            int    pagesToSkip = startRange / num;
            string cookie      = null;

            if (DirectoryAssistance.IsEmptyAddressList(this.userContext))
            {
                base.Items = new object[0][];
            }
            else if (!string.IsNullOrEmpty(this.searchString))
            {
                base.Items = AddressBookBase.PagedSearch(DirectoryAssistance.IsVirtualAddressList(this.userContext) ? this.userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN : null, DirectoryAssistance.IsVirtualAddressList(this.userContext) ? null : this.addressBook, this.userContext.ExchangePrincipal.MailboxInfo.OrganizationId, this.recipientCategory, this.searchString, ref cookie, pagesToSkip, num, out this.itemsTouched, ref lcid, ref preferredDC, properties);
            }
            else
            {
                ExTraceGlobals.MailCallTracer.TraceDebug <OrganizationId>((long)this.GetHashCode(), "AddressBookDataSource.LoadData: browse: OrganizationId of address book = '{0}'", this.addressBook.OrganizationId);
                int num2;
                base.Items = this.addressBook.BrowseTo(ref cookie, this.userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN, ref lcid, ref preferredDC, startRange, num + 1, out num2, DirectoryAssistance.IsVirtualAddressList(this.userContext), properties);
                if (base.Items != null && base.Items.Length < num + 1)
                {
                    cookie = null;
                }
            }
            this.userContext.PreferredDC = preferredDC;
            ExTraceGlobals.MailCallTracer.TraceDebug <string>((long)this.GetHashCode(), "AddressBookDataSource.LoadData: stamped preferred DC = '{0}' onto user context.", preferredDC);
            base.Cookie     = cookie;
            base.StartRange = startRange;
            if (base.Items == null || base.Items.Length == 0)
            {
                base.EndRange = 0;
                return;
            }
            if (base.Items.Length < num)
            {
                base.EndRange = startRange + base.Items.Length - 1;
                return;
            }
            base.EndRange = endRange;
        }
 public AddressBookDataSource(Hashtable properties, string searchString, AddressBookBase addressBook, AddressBookBase.RecipientCategory recipientCategory, UserContext userContext) : base(properties)
 {
     if (addressBook == null)
     {
         throw new ArgumentNullException("addresslist");
     }
     this.addressBook       = addressBook;
     this.searchString      = searchString;
     this.recipientCategory = recipientCategory;
     this.userContext       = userContext;
 }
Пример #14
0
        protected override void StampChangesOn(IConfigurable dataObject)
        {
            this.isDefaultGAL = (bool)((ADObject)dataObject)[AddressBookBaseSchema.IsDefaultGlobalAddressList];
            base.StampChangesOn(dataObject);
            AddressBookBase addressBookBase = (AddressBookBase)dataObject;

            if (addressBookBase.IsModified(ADObjectSchema.Name))
            {
                addressBookBase.DisplayName = addressBookBase.Name;
            }
        }
Пример #15
0
 internal AddressBookBase GetGlobalAddressList(IBudget budget)
 {
     if (!this.isGlobalAddressListLoaded)
     {
         IConfigurationSession configurationSession = UserContextUtilities.CreateADSystemConfigurationSession(true, ConsistencyMode.IgnoreInvalid, this, budget);
         IRecipientSession     recipientSession     = UserContextUtilities.CreateADRecipientSession(CultureInfo.CurrentCulture.LCID, true, ConsistencyMode.IgnoreInvalid, false, this, false, budget);
         this.globalAddressList         = AddressBookBase.GetGlobalAddressList(base.LogonIdentity.ClientSecurityContext, configurationSession, recipientSession, this.GlobalAddressListId);
         this.isGlobalAddressListLoaded = true;
     }
     return(this.globalAddressList);
 }
Пример #16
0
        // Token: 0x06001056 RID: 4182 RVA: 0x0004F320 File Offset: 0x0004D520
        private AddressBookBase GetGlobalAddressList(OrganizationId organizationId)
        {
            AddressBookBase globalAddressList;

            using (ClientSecurityContext clientSecurityContext = new ClientSecurityContext(this.securityAccessToken, AuthzFlags.AuthzSkipTokenGroups))
            {
                ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), organizationId, null, false);
                globalAddressList = AddressBookBase.GetGlobalAddressList(clientSecurityContext, DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 512, "GetGlobalAddressList", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RbacScope.cs"), DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, sessionSettings, ConfigScopes.TenantSubTree, 513, "GetGlobalAddressList", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\RbacScope.cs"), true);
            }
            return(globalAddressList);
        }
Пример #17
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if (base.HasErrors)
            {
                return;
            }
            AddressBookMailboxPolicy dataObject = this.DataObject;

            if (this.AddressLists != null && this.AddressLists.Length > 0)
            {
                dataObject.AddressLists = AddressBookPolicyTaskUtility.ValidateAddressBook(base.DataSession, this.AddressLists, new AddressBookPolicyTaskUtility.GetUniqueObject(base.GetDataObject <AddressBookBase>), dataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            if (base.Fields.IsModified(AddressBookMailboxPolicySchema.GlobalAddressList) && this.GlobalAddressList != null)
            {
                AddressBookBase addressBookBase = (AddressBookBase)base.GetDataObject <AddressBookBase>(this.GlobalAddressList, base.DataSession, null, new LocalizedString?(Strings.ErrorAddressListOrGlobalAddressListNotFound(this.GlobalAddressList.ToString())), new LocalizedString?(Strings.ErrorAddressListOrGlobalAddressListNotUnique(this.GlobalAddressList.ToString())));
                if (addressBookBase.IsGlobalAddressList)
                {
                    dataObject.GlobalAddressList = (ADObjectId)addressBookBase.Identity;
                }
                else
                {
                    base.WriteError(new ArgumentException(Strings.ErrorGlobalAddressListNotFound(this.GlobalAddressList.ToString())), ErrorCategory.InvalidArgument, this.Identity);
                    dataObject.GlobalAddressList = null;
                }
            }
            if (base.Fields.IsModified(AddressBookMailboxPolicySchema.RoomList) && this.RoomList != null)
            {
                AddressBookBase addressBookBase2 = (AddressBookBase)base.GetDataObject <AddressBookBase>(this.RoomList, base.DataSession, null, new LocalizedString?(Strings.ErrorAllRoomListNotFound(this.RoomList.ToString())), new LocalizedString?(Strings.ErrorAllRoomListNotUnique(this.RoomList.ToString())));
                if (addressBookBase2 != null)
                {
                    dataObject.RoomList = (ADObjectId)addressBookBase2.Identity;
                }
                else
                {
                    base.WriteError(new ArgumentException(Strings.ErrorAllRoomListNotFound(this.RoomList.ToString())), ErrorCategory.InvalidArgument, this.Identity);
                    dataObject.RoomList = null;
                }
            }
            if (base.Fields.IsModified(AddressBookMailboxPolicySchema.OfflineAddressBook))
            {
                if (this.OfflineAddressBook != null)
                {
                    OfflineAddressBook offlineAddressBook = (OfflineAddressBook)base.GetDataObject <OfflineAddressBook>(this.OfflineAddressBook, base.DataSession, null, new LocalizedString?(Strings.ErrorOfflineAddressBookNotFound(this.OfflineAddressBook.ToString())), new LocalizedString?(Strings.ErrorOfflineAddressBookNotUnique(this.OfflineAddressBook.ToString())));
                    dataObject.OfflineAddressBook = (ADObjectId)offlineAddressBook.Identity;
                }
                else
                {
                    dataObject.OfflineAddressBook = null;
                }
            }
            TaskLogger.LogExit();
        }
Пример #18
0
        protected override void StampChangesOn(IConfigurable dataObject)
        {
            AddressBookBase addressBookBase = (AddressBookBase)dataObject;

            this.originalVersion = addressBookBase.ExchangeVersion;
            base.StampChangesOn(dataObject);
            if (base.Fields.IsModified(AddressBookBaseSchema.RecipientFilter))
            {
                addressBookBase.SetRecipientFilter(this.innerFilter);
            }
        }
Пример #19
0
 internal SystemAddressListMemberCountCacheValue(AddressBookBase systemAddressList)
 {
     this.cachedCountLock = new ReaderWriterLockSlim();
     if (systemAddressList == null)
     {
         this.systemAddressListExists = false;
         this.memberCount             = 0;
         this.lifetime = TimeSpan.MaxValue;
         return;
     }
     this.systemAddressListGuid = systemAddressList.Guid;
 }
Пример #20
0
 private void UpdateMemberCount(object o)
 {
     try
     {
         SystemAddressListMemberCountCacheValue.UpdateInfo updateInfo = (SystemAddressListMemberCountCacheValue.UpdateInfo)o;
         Exception ex  = null;
         int       num = 0;
         try
         {
             num = AddressBookBase.GetAddressListSize(updateInfo.Session, this.systemAddressListGuid);
         }
         catch (Exception ex2)
         {
             ex = ex2;
         }
         try
         {
             this.cachedCountLock.EnterWriteLock();
             if (ex != null)
             {
                 this.asyncException = ex;
             }
             else if (num == -1)
             {
                 this.systemAddressListExists = false;
                 this.memberCount             = 0;
                 this.lastQueriedTime         = updateInfo.Now;
                 this.lifetime = TimeSpan.MaxValue;
             }
             else
             {
                 this.memberCount     = num;
                 this.lastQueriedTime = updateInfo.Now;
                 this.lifetime        = this.CalculateValidLifetime(updateInfo.Quota);
             }
         }
         finally
         {
             try
             {
                 this.cachedCountLock.ExitWriteLock();
             }
             catch (SynchronizationLockException)
             {
             }
         }
     }
     finally
     {
         Interlocked.Decrement(ref this.asyncUpdatesInProgress);
     }
 }
        private void CreateCannedAddressList(string name, QueryFilter recipientFilter)
        {
            bool flag = string.Equals(name, CannedAddressListsFilterHelper.DefaultAllModernGroups, StringComparison.InvariantCulture);

            if (flag && (!this.CreateModernGroupsAddressList.IsPresent || !VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.InstallModernGroupsAddressList.Enabled))
            {
                return;
            }
            ADObjectId id = this.DataObject.Id;

            AddressBookBase[] array = this.FindAddressList(name, recipientFilter);
            if (array == null || array.Length == 0)
            {
                AddressBookBase addressBookBase = new AddressBookBase();
                string          text            = name;
                if (flag)
                {
                    text = Strings.DefaultAllGroups;
                    addressBookBase.IsModernGroupsAddressList = true;
                }
                ADObjectId childId = id.GetChildId(text);
                addressBookBase.SetId(childId);
                addressBookBase.DisplayName = text;
                addressBookBase.SetRecipientFilter(recipientFilter);
                RecipientFilterHelper.StampE2003FilterMetadata(addressBookBase, addressBookBase.LdapRecipientFilter, AddressBookBaseSchema.PurportedSearchUI);
                addressBookBase.OrganizationId = (base.CurrentOrganizationId ?? OrganizationId.ForestWideOrgId);
                base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(addressBookBase, base.DataSession, typeof(AddressBookBase)));
                try
                {
                    base.DataSession.Save(addressBookBase);
                    if (string.Equals(name, CannedAddressListsFilterHelper.DefaultAllRooms, StringComparison.InvariantCulture))
                    {
                        this.PostOrganization(childId);
                    }
                }
                catch (ADObjectAlreadyExistsException)
                {
                    base.WriteVerbose(Strings.VerboseCannedAddressListAlreadyExists(name));
                }
                finally
                {
                    base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
                }
                base.WriteObject(addressBookBase);
            }
        }
Пример #22
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            AddressBookBase dataObject = base.DataObject;

            if (dataObject.CheckForAssociatedAddressBookPolicies() && !this.HandleRemoveWithAssociatedAddressBookPolicies())
            {
                return;
            }
            ADObjectId id = base.DataObject.Id;

            base.InternalProcessRecord();
            if (!base.HasErrors)
            {
                try
                {
                    ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, base.DataObject.OrganizationId, base.ExecutingUserOrganizationId, false);
                    IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.TenantGlobalCatalogSession.DomainController, true, ConsistencyMode.PartiallyConsistent, sessionSettings, 99, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\AddressBook\\RemoveAddressBook.cs");
                    tenantOrRootOrgRecipientSession.UseGlobalCatalog = true;
                    UpdateAddressBookBase <AddressListIdParameter> .UpdateRecipients(base.DataObject, new ADObjectId[]
                    {
                        base.DataObject.Id
                    }, base.DomainController, tenantOrRootOrgRecipientSession, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new WriteProgress(base.WriteProgress), this);
                }
                catch (DataSourceTransientException ex)
                {
                    TIdParameter identity = this.Identity;
                    this.WriteWarning(Strings.ErrorReadMatchingRecipients(identity.ToString(), base.DataObject.LdapRecipientFilter, ex.Message));
                    TaskLogger.Trace("Exception is raised while reading recipients: {0}", new object[]
                    {
                        ex.ToString()
                    });
                }
                catch (DataSourceOperationException ex2)
                {
                    TIdParameter identity2 = this.Identity;
                    this.WriteWarning(Strings.ErrorReadMatchingRecipients(identity2.ToString(), base.DataObject.LdapRecipientFilter, ex2.Message));
                    TaskLogger.Trace("Exception is raised while reading recipients matching filter: {0}", new object[]
                    {
                        ex2.ToString()
                    });
                }
            }
            TaskLogger.LogExit();
        }
Пример #23
0
        internal static AddressListInfo GetAllRoomsAddressBookInfo(UserContext userContext)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN != null)
            {
                return(AddressListInfo.CreateEmpty(userContext.ExchangePrincipal.MailboxInfo.OrganizationId));
            }
            AddressBookBase allRoomsAddressList = userContext.AllRoomsAddressList;

            if (allRoomsAddressList == null)
            {
                return(AddressListInfo.CreateEmpty(userContext.ExchangePrincipal.MailboxInfo.OrganizationId));
            }
            return(new AddressListInfo(allRoomsAddressList));
        }
Пример #24
0
        internal AddressBookBase GetDefaultGlobalAddressList()
        {
            MultiValuedProperty <ADObjectId> defaultGlobalAddressList = this.DefaultGlobalAddressList;
            AddressBookBase result     = null;
            ADObjectId      adobjectId = null;

            foreach (ADObjectId adobjectId2 in defaultGlobalAddressList)
            {
                adobjectId = adobjectId2;
                if (adobjectId2.IsDescendantOf(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest()))
                {
                    break;
                }
            }
            if (adobjectId != null)
            {
                result = base.Session.Read <AddressBookBase>(adobjectId);
            }
            return(result);
        }
Пример #25
0
        private void CreateDefaultGal(ADObjectId defaultGal)
        {
            AddressBookBase addressBookBase = new AddressBookBase();

            addressBookBase.SetId(defaultGal);
            addressBookBase.DisplayName = defaultGal.Name;
            addressBookBase.SetRecipientFilter(GlobalAddressList.RecipientFilterForDefaultGal);
            addressBookBase[AddressBookBaseSchema.RecipientFilterFlags] = (RecipientFilterableObjectFlags.FilterApplied | RecipientFilterableObjectFlags.IsDefault);
            RecipientFilterHelper.StampE2003FilterMetadata(addressBookBase, addressBookBase.LdapRecipientFilter, AddressBookBaseSchema.PurportedSearchUI);
            addressBookBase.OrganizationId = (base.CurrentOrganizationId ?? OrganizationId.ForestWideOrgId);
            base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(addressBookBase, base.DataSession, typeof(AddressBookBase)));
            try
            {
                base.DataSession.Save(addressBookBase);
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
            }
            base.WriteObject(addressBookBase);
        }
        private void UpdateTheAllUsersAddressList()
        {
            AddressBookBase[] array = this.FindAddressList(CannedAddressListsFilterHelper.DefaultAllUsers, CannedAddressListsFilterHelper.DefaultAllUsersFilter);
            if (array == null || array.Length == 0)
            {
                return;
            }
            AddressBookBase addressBookBase = array[0];

            if (!object.Equals(addressBookBase.RecipientFilter, CannedAddressListsFilterHelper.DefaultAllUsersFilter))
            {
                addressBookBase.SetRecipientFilter(CannedAddressListsFilterHelper.DefaultAllUsersFilter);
                try
                {
                    base.DataSession.Save(addressBookBase);
                }
                finally
                {
                    base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
                }
            }
        }
Пример #27
0
        internal static GlobalAddressListInfo GetGlobalAddressListInfo(UserContext userContext)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            ADObjectId            queryBaseDN = userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN;
            GlobalAddressListInfo globalAddressListInfo;

            if (queryBaseDN == null)
            {
                if (userContext.GlobalAddressList != null)
                {
                    globalAddressListInfo = new GlobalAddressListInfo(userContext.GlobalAddressList, GlobalAddressListInfo.GalOrigin.DefaultGlobalAddressList);
                }
                else
                {
                    globalAddressListInfo             = new GlobalAddressListInfo(new AddressBookBase(), GlobalAddressListInfo.GalOrigin.EmptyGlobalAddressList);
                    globalAddressListInfo.DisplayName = LocalizedStrings.GetNonEncoded(1164140307);
                    globalAddressListInfo.Id          = null;
                }
            }
            else
            {
                IConfigurationSession configurationSession = Utilities.CreateADSystemConfigurationSession(true, ConsistencyMode.IgnoreInvalid, userContext);
                AddressBookBase       addressBookBase      = configurationSession.Read <AddressBookBase>(new ADObjectId(null, queryBaseDN.ObjectGuid));
                if (addressBookBase != null)
                {
                    globalAddressListInfo = new GlobalAddressListInfo(addressBookBase, GlobalAddressListInfo.GalOrigin.QueryBaseDNAddressList);
                }
                else
                {
                    globalAddressListInfo             = new GlobalAddressListInfo(new AddressBookBase(), GlobalAddressListInfo.GalOrigin.QueryBaseDNSubTree);
                    globalAddressListInfo.DisplayName = LocalizedStrings.GetNonEncoded(1164140307);
                    globalAddressListInfo.Id          = queryBaseDN;
                }
            }
            return(globalAddressListInfo);
        }
Пример #28
0
 public AddressBookListView(string searchString, UserContext userContext, ColumnId sortedColumn, SortOrder sortOrder, AddressBookBase addressBook, AddressBookBase.RecipientCategory recipientCategory) : base(userContext, sortedColumn, sortOrder, ListView.ViewType.ADContentsListView)
 {
     this.addressBook       = addressBook;
     this.searchString      = searchString;
     this.recipientCategory = recipientCategory;
     base.FilteredView      = !string.IsNullOrEmpty(searchString);
 }
Пример #29
0
        // Token: 0x06001055 RID: 4181 RVA: 0x0004F074 File Offset: 0x0004D274
        internal void PopulateRootAndFilter(OrganizationId organizationId, IReadOnlyPropertyBag propertyBag)
        {
            if (this.Root != null || this.Filter != null)
            {
                return;
            }
            if (this.isFromEndUserRole && propertyBag == null)
            {
                throw new ArgumentNullException("propertyBag");
            }
            if (organizationId != null)
            {
                this.SelfRoot = organizationId.OrganizationalUnit;
            }
            if (propertyBag != null)
            {
                this.SelfFilter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, propertyBag[ADObjectSchema.Id]);
            }
            switch (this.scopeType)
            {
            case ScopeType.None:
                this.Root   = null;
                this.Filter = ADScope.NoObjectFilter;
                return;

            case ScopeType.NotApplicable:
                this.Root   = null;
                this.Filter = null;
                return;

            case ScopeType.Organization:
                this.Root   = organizationId.OrganizationalUnit;
                this.Filter = null;
                return;

            case ScopeType.MyGAL:
            {
                AddressBookBase globalAddressList = this.GetGlobalAddressList(organizationId);
                this.Root = organizationId.OrganizationalUnit;
                if (globalAddressList == null)
                {
                    this.Filter = ADScope.NoObjectFilter;
                    return;
                }
                this.Filter = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.AddressListMembership, globalAddressList.Id);
                return;
            }

            case ScopeType.Self:
                this.Root   = organizationId.OrganizationalUnit;
                this.Filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Id, propertyBag[ADObjectSchema.Id]);
                return;

            case ScopeType.MyDirectReports:
                this.Root   = organizationId.OrganizationalUnit;
                this.Filter = new ComparisonFilter(ComparisonOperator.Equal, ADOrgPersonSchema.Manager, propertyBag[ADObjectSchema.Id]);
                return;

            case ScopeType.OU:
                this.Root   = this.ouId;
                this.Filter = null;
                return;

            case ScopeType.CustomRecipientScope:
            case ScopeType.CustomConfigScope:
            case ScopeType.PartnerDelegatedTenantScope:
            case ScopeType.ExclusiveRecipientScope:
            case ScopeType.ExclusiveConfigScope:
                this.Root   = this.managementScope.RecipientRoot;
                this.Filter = this.managementScope.QueryFilter;
                return;

            case ScopeType.MyDistributionGroups:
            {
                this.Root = organizationId.OrganizationalUnit;
                QueryFilter[] array = new QueryFilter[3];
                array[0] = new ComparisonFilter(ComparisonOperator.Equal, ADGroupSchema.ManagedBy, propertyBag[ADObjectSchema.Id]);
                array[1] = new ComparisonFilter(ComparisonOperator.Equal, ADGroupSchema.CoManagedBy, propertyBag[ADObjectSchema.Id]);
                array[2] = new CSharpFilter <IReadOnlyPropertyBag>(delegate(IReadOnlyPropertyBag obj)
                    {
                        ADGroup adgroup = obj as ADGroup;
                        return(adgroup != null && adgroup.IsExecutingUserGroupOwner);
                    });
                this.Filter = new OrFilter(array);
                return;
            }

            case ScopeType.MyExecutive:
                break;

            case ScopeType.OrganizationConfig:
                this.Root   = organizationId.ConfigurationUnit;
                this.Filter = null;
                return;

            case ScopeType.MailboxICanDelegate:
            {
                this.Root = organizationId.OrganizationalUnit;
                QueryFilter[] array2 = new QueryFilter[2];
                array2[0] = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.MasterAccountSid, this.securityAccessToken.UserSid);
                array2[1] = new CSharpFilter <IReadOnlyPropertyBag>(delegate(IReadOnlyPropertyBag obj)
                    {
                        RawSecurityDescriptor rawSecurityDescriptor = ((ADObject)obj).ReadSecurityDescriptor();
                        if (rawSecurityDescriptor != null)
                        {
                            using (AuthzContextHandle authzContext = AuthzAuthorization.GetAuthzContext(new SecurityIdentifier(this.securityAccessToken.UserSid), false))
                            {
                                bool[] array3 = AuthzAuthorization.CheckExtendedRights(authzContext, rawSecurityDescriptor, new Guid[]
                                {
                                    WellKnownGuid.PersonalInfoPropSetGuid
                                }, null, AccessMask.WriteProp);
                                return(array3[0]);
                            }
                            return(false);
                        }
                        return(false);
                    });
                this.Filter = new OrFilter(array2);
                return;
            }

            default:
                this.Root   = null;
                this.Filter = ADScope.NoObjectFilter;
                break;
            }
        }
Пример #30
0
 // Token: 0x0600513A RID: 20794 RVA: 0x0012CA43 File Offset: 0x0012AC43
 public SystemAddressList(AddressBookBase dataObject) : base(dataObject)
 {
 }