Пример #1
0
        protected override void WriteResult()
        {
            TaskLogger.LogEnter(new object[]
            {
                this.DataObject.Identity
            });
            ConsumerMailbox consumerMailbox = null;
            NetID           netID           = (NetID)base.Fields[ADUserSchema.NetID];

            try
            {
                using (TaskPerformanceData.ReadResult.StartRequestTimer())
                {
                    ADUser aduser = ConsumerMailboxHelper.ReadUser((IRecipientSession)base.DataSession, netID.ToUInt64(), false);
                    if (aduser != null)
                    {
                        consumerMailbox = new ConsumerMailbox(aduser);
                    }
                }
            }
            finally
            {
                base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
            }
            if (consumerMailbox == null)
            {
                base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(netID.ToString(), typeof(ConsumerMailbox).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, netID.ToString());
            }
            using (TaskPerformanceData.WriteResult.StartRequestTimer())
            {
                this.WriteResult(consumerMailbox);
            }
            TaskLogger.LogExit();
        }
Пример #2
0
        protected override SubscribeResults InternalPerformSubscribe(MailboxSession mailboxSession, SharingContext context)
        {
            NetID netID = new NetID(context.MailboxId);
            long  num   = checked ((long)netID.ToUInt64());

            if (num == 0L)
            {
                throw new InvalidOperationException("Invitation does not contain the owner ID.");
            }
            Guid guid;

            if (!Guid.TryParse(context.FolderEwsId, out guid))
            {
                throw new InvalidOperationException("Invitation does not contain the calendar ID.");
            }
            using (Folder folder = Folder.Bind(mailboxSession, DefaultFolderType.Root))
            {
                StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.DeletedItems);
                QueryFilter   queryFilter     = QueryFilter.AndTogether(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.Equal, CalendarFolderSchema.ConsumerCalendarGuid, guid),
                    new ComparisonFilter(ComparisonOperator.Equal, CalendarFolderSchema.ConsumerCalendarOwnerId, num)
                });
                using (IQueryResult queryResult = folder.IFolderQuery(FolderQueryFlags.DeepTraversal, queryFilter, null, new PropertyDefinition[]
                {
                    FolderSchema.Id,
                    FolderSchema.DisplayName,
                    StoreObjectSchema.ParentItemId
                }))
                {
                    bool flag = true;
                    while (flag)
                    {
                        object[][] rows = queryResult.GetRows(100, out flag);
                        if (rows == null || rows.Length == 0)
                        {
                            break;
                        }
                        foreach (object[] array2 in rows)
                        {
                            StoreObjectId storeObjectId = StoreId.GetStoreObjectId((StoreId)array2[2]);
                            if (!defaultFolderId.Equals(storeObjectId))
                            {
                                return(new SubscribeResults(context.DataType, context.InitiatorSmtpAddress, context.InitiatorName, context.FolderName, StoreId.GetStoreObjectId((StoreId)rows[0][0]), false, (string)rows[0][1]));
                            }
                        }
                    }
                }
            }
            SubscribeResults result;

            using (CalendarFolder calendarFolder = CalendarFolder.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Root), StoreObjectType.CalendarFolder))
            {
                calendarFolder[FolderSchema.ExtendedFolderFlags] = (ExtendedFolderFlags.SharedIn | ExtendedFolderFlags.ExclusivelyBound | ExtendedFolderFlags.ExchangeConsumerShareFolder);
                calendarFolder.DisplayName             = (context.FolderName ?? context.InitiatorSmtpAddress);
                calendarFolder.ConsumerCalendarGuid    = guid;
                calendarFolder.ConsumerCalendarOwnerId = num;
                calendarFolder.SaveWithUniqueDisplayName(50);
                calendarFolder.Load();
                result = new SubscribeResults(context.DataType, context.InitiatorSmtpAddress, context.InitiatorName, context.FolderName, StoreId.GetStoreObjectId(calendarFolder.Id), true, calendarFolder.DisplayName);
            }
            return(result);
        }