Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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();
        }