public override T Read(RequestIndexEntryProvider requestIndexEntryProvider, RequestIndexEntryObjectId identity)
        {
            ArgumentValidator.ThrowIfNull("targetExchangeGuid", identity.TargetExchangeGuid);
            ADRecipient adrecipient = requestIndexEntryProvider.Read <ADRecipient>((IRecipientSession session) => session.FindByExchangeGuidIncludingAlternate(identity.TargetExchangeGuid));

            if (adrecipient == null)
            {
                MrsTracer.Common.Warning("No ADRecipient found with ExchangeGuid '{0}' including alternates.", new object[]
                {
                    identity.TargetExchangeGuid
                });
                return(default(T));
            }
            ADUser aduser = adrecipient as ADUser;

            if (aduser == null)
            {
                MrsTracer.Common.Warning("'{0}' is not a user.", new object[]
                {
                    adrecipient.Id.ToString()
                });
                return(default(T));
            }
            T t = Activator.CreateInstance <T>();

            t.TargetUser         = aduser;
            t.TargetExchangeGuid = identity.TargetExchangeGuid;
            t.TargetMDB          = aduser.Database;
            T result = t;

            result.RequestGuid = identity.RequestGuid;
            result.SetExchangePrincipal();
            return(result);
        }
        public IConfigurable Read <T>(ObjectId identity) where T : IConfigurable, new()
        {
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }
            RequestIndexEntryObjectId requestIndexEntryObjectId = identity as RequestIndexEntryObjectId;

            if (requestIndexEntryObjectId == null)
            {
                throw new ArgumentException("This provider only supports RequestIndexEntryObjectIds", "identity");
            }
            Type typeFromHandle = typeof(T);

            if (!typeFromHandle.IsSubclassOf(typeof(RequestBase)) && !typeof(IRequestIndexEntry).IsAssignableFrom(typeFromHandle))
            {
                throw new ArgumentException("This provider only supports reading types of RequestBase or IRequestIndexEntry");
            }
            IRequestIndexEntry requestIndexEntry = this.Read(requestIndexEntryObjectId);

            if (requestIndexEntry == null || requestIndexEntry is T)
            {
                return(requestIndexEntry);
            }
            if (!typeFromHandle.IsSubclassOf(typeof(RequestBase)))
            {
                return(null);
            }
            return(RequestIndexEntryProvider.CreateRequest <T>(requestIndexEntry));
        }
 public IRequestIndexEntry Read(RequestIndexEntryObjectId objectId)
 {
     if (objectId.IndexId.RequestIndexEntryType == null)
     {
         return(null);
     }
     return(RequestIndexEntryProvider.Handle <IRequestIndexEntry>(objectId.IndexId.RequestIndexEntryType, (IRequestIndexEntryHandler handler) => handler.Read(this, objectId)));
 }
        public override bool Equals(object obj)
        {
            RequestIndexEntryObjectId requestIndexEntryObjectId = obj as RequestIndexEntryObjectId;

            if (requestIndexEntryObjectId != null)
            {
                bool flag = (this.IndexId != null) ? this.IndexId.Equals(requestIndexEntryObjectId.IndexId) : (requestIndexEntryObjectId.IndexId == null);
                return(this.RequestGuid == requestIndexEntryObjectId.RequestGuid && this.RequestType == requestIndexEntryObjectId.RequestType && this.OrganizationId == requestIndexEntryObjectId.OrganizationId && flag && this.TargetExchangeGuid == requestIndexEntryObjectId.TargetExchangeGuid);
            }
            return(false);
        }
Beispiel #5
0
 public SyncRequestIdParameter(RequestIndexEntryObjectId identity) : base(identity)
 {
     if (identity.IndexId != null)
     {
         base.MailboxId = identity.IndexId.Mailbox;
         return;
     }
     if (identity.RequestObject != null)
     {
         base.MailboxId = identity.RequestObject.TargetMailbox;
     }
 }
Beispiel #6
0
        public void Initialize(ObjectId objectId)
        {
            RequestIndexEntryObjectId requestIndexEntryObjectId = objectId as RequestIndexEntryObjectId;

            if (requestIndexEntryObjectId == null)
            {
                throw new ArgumentNullException("objectId");
            }
            if (requestIndexEntryObjectId.RequestGuid == Guid.Empty || requestIndexEntryObjectId.IndexId == null)
            {
                throw new ArgumentException(MrsStrings.InitializedWithInvalidObjectId);
            }
            this.requestGuid = requestIndexEntryObjectId.RequestGuid;
            this.indexToUse  = requestIndexEntryObjectId.IndexId;
        }
Beispiel #7
0
        internal IEnumerable <T> InternalGetObjects <T>(ObjectId rootId, IConfigDataProvider session, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where T : IConfigurable, new()
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            RequestIndexEntryProvider requestIndexEntryProvider = session as RequestIndexEntryProvider;

            if (requestIndexEntryProvider == null)
            {
                throw new ArgumentException(MrsStrings.MustProvideValidSessionForFindingRequests);
            }
            if (this.requestGuid != Guid.Empty && this.indexToUse != null)
            {
                List <T> list = new List <T>(1);
                RequestIndexEntryObjectId identity = new RequestIndexEntryObjectId(this.requestGuid, this.RequestType, this.OrganizationId, this.indexToUse, null);
                T t = (T)((object)requestIndexEntryProvider.Read <T>(identity));
                if (t != null)
                {
                    list.Add(t);
                    notFoundReason = null;
                }
                else
                {
                    notFoundReason = new LocalizedString?(MrsStrings.NoSuchRequestInSpecifiedIndex);
                }
                return(list);
            }
            if (string.IsNullOrEmpty(this.requestName) || this.indexToUse == null)
            {
                notFoundReason = new LocalizedString?(MrsStrings.NotEnoughInformationSupplied);
                return(new List <T>(0));
            }
            if (this.mailboxId != null)
            {
                QueryFilter filter = new RequestIndexEntryQueryFilter(this.requestName, this.mailboxId, this.RequestType, this.indexToUse, true);
                notFoundReason = new LocalizedString?(MrsStrings.NoSuchRequestInSpecifiedIndex);
                return(requestIndexEntryProvider.FindPaged <T>(filter, rootId, true, null, 2));
            }
            QueryFilter filter2 = new RequestIndexEntryQueryFilter(this.requestName, null, this.RequestType, this.indexToUse, false);

            notFoundReason = new LocalizedString?(MrsStrings.NoSuchRequestInSpecifiedIndex);
            return(requestIndexEntryProvider.FindPaged <T>(filter2, rootId, true, null, 2));
        }
Beispiel #8
0
 protected MRSRequestIdParameter(RequestIndexEntryObjectId identity)
 {
     if (identity == null)
     {
         throw new ArgumentNullException("identity");
     }
     if (identity.RequestType != this.RequestType)
     {
         throw new ArgumentException(MrsStrings.ImproperTypeForThisIdParameter, "identity");
     }
     this.indexToUse       = identity.IndexId;
     this.indexIds         = null;
     this.requestGuid      = identity.RequestGuid;
     this.mailboxName      = null;
     this.mailboxId        = null;
     this.requestName      = null;
     this.organizationId   = identity.OrganizationId;
     this.organizationName = null;
     this.rawIdentity      = null;
 }
Beispiel #9
0
 public RequestIndexEntryQueryFilter(RequestIndexEntryObjectId requestIndexEntryId)
 {
     this.requestGuid          = requestIndexEntryId.RequestGuid;
     this.requestQueueId       = null;
     this.requestType          = requestIndexEntryId.RequestType;
     this.indexId              = requestIndexEntryId.IndexId;
     this.requestName          = null;
     this.mailboxId            = null;
     this.dbId                 = null;
     this.looseMailboxSearch   = false;
     this.wildcardedNameSearch = false;
     this.batchName            = null;
     this.sourceMailbox        = null;
     this.targetMailbox        = null;
     this.sourceDatabase       = null;
     this.targetDatabase       = null;
     this.status               = RequestStatus.None;
     this.flags                = RequestFlags.None;
     this.notFlags             = RequestFlags.None;
 }
Beispiel #10
0
 public MailboxRestoreRequestIdParameter(RequestIndexEntryObjectId identity) : base(identity)
 {
 }
Beispiel #11
0
        public override MRSRequestMailboxEntry Read(RequestIndexEntryProvider requestIndexEntryProvider, RequestIndexEntryObjectId identity)
        {
            this.ValidateRequestIndexId(identity.IndexId);
            ADUser aduser = requestIndexEntryProvider.ReadADUser(identity.IndexId.Mailbox, Guid.Empty);

            if (aduser == null)
            {
                return(null);
            }
            ExchangePrincipal      mailboxOwner = ExchangePrincipal.FromADUser(aduser, RemotingOptions.AllowCrossSite);
            MRSRequestMailboxEntry result;

            using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=MSExchangeMigration"))
            {
                MailboxStoreTypeProvider session = new MailboxStoreTypeProvider(aduser)
                {
                    MailboxSession = mailboxSession
                };
                MRSRequestMailboxEntry mrsrequestMailboxEntry = MRSRequest.Read <MRSRequestMailboxEntry>(session, identity.RequestGuid);
                mrsrequestMailboxEntry.RequestIndexId = identity.IndexId;
                mrsrequestMailboxEntry.OrganizationId = identity.OrganizationId;
                result = mrsrequestMailboxEntry;
            }
            return(result);
        }
 public abstract T Read(RequestIndexEntryProvider requestIndexEntryProvider, RequestIndexEntryObjectId identity);
 public PublicFolderMailboxMigrationRequestIdParameter(RequestIndexEntryObjectId identity) : base(identity)
 {
 }
Beispiel #14
0
 public MergeRequestIdParameter(RequestIndexEntryObjectId identity) : base(identity)
 {
 }
Beispiel #15
0
 public override MRSRequestWrapper Read(RequestIndexEntryProvider requestIndexEntryProvider, RequestIndexEntryObjectId identity)
 {
     return(ADHandler.Read(requestIndexEntryProvider.ConfigSession, identity.RequestGuid, identity.RequestType));
 }
Beispiel #16
0
 public PublicFolderMoveRequestIdParameter(RequestIndexEntryObjectId identity) : base(identity)
 {
 }
        IRequestIndexEntry IRequestIndexEntryHandler.Read(RequestIndexEntryProvider requestIndexEntryProvider, RequestIndexEntryObjectId identity)
        {
            Type typeFromHandle = typeof(T);

            if (identity.IndexId.RequestIndexEntryType != typeFromHandle)
            {
                throw new ArgumentException(string.Format("The provided identity is requesting an IRequestIndexEntry of type {0}, but this handler only supports type {1}.", identity.IndexId.RequestIndexEntryType.Name, typeFromHandle.Name), "identity");
            }
            return(this.Read(requestIndexEntryProvider, identity));
        }